[R-sig-ME] LMER vs MLwiN

W Robert Long longrob604 at gmail.com
Fri Feb 17 15:50:11 CET 2012


Hi Federico

Thank you very much.

However, the model I'm trying to fit has no fixed effects. The MLwiN 
output gives me:
beta_0_hat: 1.012(0.107)  conditional log odds
var_f0_hat: 0.031(0.066)  variance between communues
var_v0_hat: 0.760(0.141)  variance between schools within commune
var_u0_hat: 0.186(0.38)   variance between classes within schools

This is what I am trying to duplicate in R with the same data.

BTW I am using 64 bit R

Thanks again
RL

On 17/02/2012 1:06 PM, Federico Calboli wrote:
> On 17 Feb 2012, at 12:52, W Robert Long wrote:
>
>> Hello
>>
>> I'm new to using mixed models in R. Thus far I've been using MLwiN. I am trying to duplicate the results in MLwiN of a logistic mixed effects model.
>>
>> At the moment I have no covariates, and a data hierarchy of
>> pupil within class within school within commune with random effects at each level above pupil.
>>
>> There are 9000 observations in total;
>>
>> 300 classes
>> 100 schools
>> 20 communes
>> These have been set as factors with as.factor(). I'm not sure if this is correct as they were not categorical in MLwiN (they were just ints) but I was getting this error before I did that:
>> "Error: length(f1) == length(f2) is not TRUE"
>>
>> I have tried to fit a model with glmer like this:
>>
>> glmer(LOSS~(1|COMMUNE/SCHOOL/CLASS/PUPIL),data=dt,family=binomial(link = "logit"))
>
> you seem to specify COMMUNE and SCHOOL as random effects, with no fixed effects. If I were you I would:
>
> 1) code PUPIL from 1:n so that you never have two different pupils in two different classes coded with the same code.
> 2) code CLASS from 1:n (see above)
>
> then I'd try
>
> glmer(LOSS~ COMMUNE + SCHOOL + (1|CLASS) + (1|PUPIL) ,data=dt,family=binomial(link = "logit")) #coding class and pupil as I said will automatically take care of the nesting
>
> as see what happens.
>
> If you are using R 32 bits you might want to use R 64 bits to have more RAM available.
>
> BW
>
> F
>
>
>
>>
>> However this generates the error
>> "Error: cannot allocate vector of size 9.5 Gb"
>>
>> I have also tried glmmPQL in the MASS package:
>> glmmPQL(LOSS~1,data=dt, random = ~1|COMMUNE/SCHOOL/CLASS/PUPIL,family=binomial(link = "logit"))
>>
>> However this generates /completely/ wrong estimates so I can only assume that I am specifying the model incorrectly in R.
>>
>> If anyone can advise, I would be very grateful
>> Thanks
>> RL
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> --
> Federico C. F. Calboli
> Neuroepidemiology and Ageing Research
> Imperial College, St. Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel +44 (0)20 75941602   Fax +44 (0)20 75943193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>




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