[R-sig-ME] fixed effect testing again (but different)
Daniel Ezra Johnson
danielezrajohnson at gmail.com
Fri Aug 29 20:09:54 CEST 2008
>> If it seems wrong to take the parameter from m1, is there some way to
>> change the specification of m0 so as to obtain a separate random
>> effect for males and females? I've seen that done but I've forgotten
>> how to do it.
>>
>> If I can run something like
>>
>> m00 <- lmer(response~(1|subject-females)+(1|subject-males),data) #
>> how is this specified?
Off list I was shown a way to supposedly do this, by making a pseudo
random slope using a dummy variable. It seems promising but it doesn't
really work properly, as the following example shows.
set.seed(1)
s <- rep(rnorm(200,0,1),each=100)
g <- rep(c(-3,3),each=10000)
p <- inv.logit(s+g)
obs <- data.frame(response=rbinom(20000,1,p),
gender=rep(c("M","F"),each=10000),
subject=rep(paste("S",1:200,sep=""),each=100))
obs$M <- ifelse(obs$gender=="M",1,0)
obs$F <- ifelse(obs$gender=="F",1,0)
test <- lmer(response~(0+M|subject)+(0+F|subject),obs,binomial)
Random effects:
Groups Name Variance Std.Dev.
subject M 0.82563 0.90864 # out of whack
subject F 37.79488 6.14775 # out of whack
Number of obs: 20000, groups: subject, 200
obs.m <- obs[obs$gender=="M",]
test.m <- lmer(response~(1|subject),obs.m,binomial)
Random effects:
Groups Name Variance Std.Dev.
subject (Intercept) 0.85413 0.9242
Number of obs: 10000, groups: subject, 100
obs.f <- obs[obs$gender=="F",]
test.f <- lmer(response~(1|subject),obs.f,binomial)
Random effects:
Groups Name Variance Std.Dev.
subject (Intercept) 0.60097 0.77522
Number of obs: 10000, groups: subject, 100
Is there, then, any way to implement heteroscedastic-by-group random
effects in lme4, as opposed to nlme?
Thanks,
D
More information about the R-sig-mixed-models
mailing list