[R-sig-ME] random factor of type integer

Henrik Parn henrik.parn at bio.ntnu.no
Tue Jan 29 15:26:26 CET 2008


Dear all,

I have a dataset where the variables that I later will use as random 
grouping factors in a lmer-model are integers. Do I first need to 
convert them to factors?

I just tried if the example on the help page for lmer (where the 
grouping factor 'Subject' actually is a factor)...

str(sleepstudy$Subject)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
summary(fm1)

...differed from:

Subject2 <- as.integer(as.character(sleepstudy$Subject))
fm2 <- lmer(Reaction ~ Days + (Days|Subject2), sleepstudy)
summary(fm2)

...but it did not.

Is this a general case or could the use of a random factor of integer 
type may cause problems in lmer?

Thanks in advance!

Henrik




More information about the R-sig-mixed-models mailing list