【发布时间】:2022-01-24 21:14:38
【问题描述】:
我正在尝试在混合效果模型上建立放置界限。我通常对我的模型使用 LMER 函数,但我无法找到任何方法来限制系数。我尝试使用 LME,但即使这样也无济于事。有人可以帮忙吗?
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)
【问题讨论】:
-
rstudio-pubs-static.s3.amazonaws.com/…(最后的 cmets 表明我可能没有解决所有的错误......??)
标签: r regression lme4 mixed-models nlme