[R] Creating a model with fixed and random variables

S Ellison S.Ellison at lgcgroup.com
Mon Aug 5 13:54:49 CEST 2013


> Code I have used thus far without being able to replicate the 
> data includes:
> 
> Fm<-lmer(Score~(1|Line%in%Set)+Set+(1|Block))
>  (I figured out how to get a p-value, but it didn't yield the 
> same results as those obtained in SAS)

%in% doesn't generally mean 'nested in' in R. It is a set membership test and will return TRUE for those labels in Line that are also in Set and FALSE otherwise. 

Did you mean Score~(1|Set/Line)...?

If you did, bear in mind that , combined with the fixed Set term, (1|Set/Line) implies a random Set grouping effect as well as a fixed effect - not sure that makes sense in your circumstance unless Set is a continuous predictor. May be safer to define SetLine<-interaction(Set, Line) and do
Score~Set + (1|SetLine) + (1|Block)

S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list