Solved – How to specify random effects in lme

biostatisticscross-validationmixed modelr

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

Best Answer

Try this, it's a standard way to do a split plot. The notation / means that method is nested in day.

lme(level~method, random=~1|day/method, data=d)