I have searched for this online for hours but none of online posts is what I am looking for. My question is very easy to implement in SAS Proc mixed procedure but I am not sure how to do it in lme and/or lmer packages. Assume, I have a model, $y = \mu + \alpha + \beta +\alpha\beta + e$, where $\alpha$ is fixed but $\beta$ and $\alpha\beta$ are random. My R code is
f1 = lme(y ~ factor(a), data = mydata,
random = list(factor(b) = ~ 1, factor(a):factor(b) = ~ 1))
Error: unexpected =
in:
f1 = lme(y ~ factor(a), data = mydata,
random = list(factor(a) =
Could someone please tell me how to specify these random effects in lme? many thanks in advance
dput
to get the code needed to recreate your data. From the comment you left, the result isstructure(list(method = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("1", "2"), class = "factor"), day = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L), .Label = c("1", "2", "3", "4"), class = "factor"), level = c(142.3, 144, 134.9, 146.3, 148.6, 156.5, 152, 151.4, 142.9, 147.4, 125.9, 127.6, 135.5, 138.9, 142.9, 142.3)), .Names = c("method", "day", "level"), row.names = c(NA, -16L), class = "data.frame")
$\endgroup$