I have the following model, how do I add a random intercept(no random effects included yet):
modelid3 <- nlme(y ~ TPMRM0(M, v0, v1, v2, v3, v4, v5, v6, v7, v8, b, b, b, b, b, b, b, b),
fixed =list(v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 ~ 1,
b ~ act + 0),
random = -----,
groups = ~ id,
data = dat,
weights = varIdent(form = ~ 1 | visit),
correlation = corSymm(value = covmmrmvec, form = ~ as.numeric(visit) | id),
start = init,
method = "ML",
control=nlmeControl(maxIter=1000, msMaxIter = 1000, returnObject = TRUE),
verbose = TRUE)
given that:
TPMRM0 <- function(t, v0, v1, v2, v3, v4, v5, v6, v7, v8, b1, b2, b3, b4, b5, b6, b7, b8) {
months <- seq(0,24,3)
b <- cbind(0, b1, b2, b3, b4, b5, b6, b7, b8)
t_out <- (1 - b[cbind(1:length(t), match(t, months))]) * t
spline(x = months,
y = c(v0[1], v1[1], v2[1], v3[1], v4[1], v5[1], v6[1], v7[1], v8[1]),
method = 'natural',
xout = t_out)$y
}
Tried random = 1 ~id
. Still getting the same error.
Here is some of the data if that helps:
id visit M y trt act mod_trt act_vis
1 1 1 0 109.3006 pbo 0 pbo pbo.0
2 1 2 3 111.0854 pbo 0 pbo pbo.3
3 1 3 6 102.1718 pbo 0 pbo pbo.6
4 1 4 9 106.1363 pbo 0 pbo pbo.9
.
.
.
8997 1000 6 15 92.61685 act 1 act act.15
8998 1000 7 18 86.69760 act 1 act act.18
8999 1000 8 21 87.87717 act 1 act act.21
9000 1000 9 24 94.08110 act 1 act act.24
Would this give the wanted random intercept, without interfering with the rest of the model?
nlme(y ~ TPMRM0(M, v0, v1, v2, v3, v4, v5, v6, v7, v8, b, b, b, b, b, b, b, b) + b0,
fixed =list(v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 ~ 1,
b ~ act + 0),
random = list(b0 ~ 1),
groups = ~ id,
data = dat,
weights = varIdent(form = ~ 1 | visit),
correlation = corSymm(value = covmmrmvec, form = ~ as.numeric(visit) | id),
start = init,
method = "ML",
control=nlmeControl(maxIter=1000, msMaxIter = 1000, returnObject = TRUE),
verbose = TRUE)