I am trying to build put bounds on Mixed effect model. I usually use LMER function for my models but I am not able to find any way to put bounds on the coefficients. I tried using LME but even this was not helpful. Can anyone help here?
library(nlme)
library(lmerTest)
myDat = structure(list(Score = c(1.62, 2.18, 2.3, 3.46, 3.85, 4.7, 1.41,
2.21, 3.32, 2.73, 3.34, 3.27, 2.14, 2.73, 2.74, 3.39, 3.59, 4.01,
1.81, 1.83, 3.22, 3.64, 3.51, 4.26), Subject = structure(c(1L,
1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L,
6L, 7L, 7L, 7L, 8L, 8L, 8L), .Label = c("A", "B", "C", "D", "E",
"F", "G", "H"), class = "factor"), Condition = structure(c(1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("No", "Yes"), class = "factor"),
Time = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L,
2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), .Label = c("1PM",
"2PM", "3PM"), class = "factor")), .Names = c("Score", "Subject",
"Condition", "Time"), class = "data.frame", row.names = c(NA,
-24L))
m1 <- lmer(Score ~ Condition + Time + Condition*Time + (1 | Subject),
data = myDat)
fixef(m1)
ranef(m1)
# This is a lame attempt to get positive coeffiecients but I am not sure what objective function, I need to spcify
m2 <- lme(Score ~ Condition + Time + Condition*Time,
data = myDat, random=c(~1 | Subject)
# ,
# nlminb(start = c(0,0,0,0,0),lower = c(0,0,0,0,0))
)
fixef(m2)
ranef(m2)