Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!
Hi, I was trying to replicate the analysis from module 9 Practice using R2MLwiN.
I used the following codes to calculate the residual for random intercept and slope:
## to calculate random intercept residual
u0 <- model03@residual$lev_2_resi_est_Intercept.123/2
## to calculate random slope residual
u1 <- model03@residual$lev_2_resi_est_agecen50.123/2
However, when I compared with the residuals calculated using MLwiN, u0 obtained from the above code correspond to the random slope residual (agecen50.123) from MLwiN while u1 obtained from R2MLwiN correspond to the random intercept (cons.123) from MLwiN.
The random part estimates at the state1 level:
var_Intercept_123 0.00013 0.00005
cov_Intercept_123_agecen50_123 0.004 0.00161
var_agecen50_123 0.28027 0.08268
In this case, should I reverse the random effect obtained from R2MLwin?
Thank you for letting us know about this. I will look into it as soon as I get the chance. Can you please provide the syntax for the model that corresponds to these results?
Hi, I'm using data (9.1wsz) from Module 9. The data is converted to dta and then imported to R. The categorical variable (occtype) is converted into dummy variables. Here is the syntax for replicating the random slope model:
I have had an initial look into this and it appears that the problem is that cons[1:3] term is in the random part, but not the fixed part. R2MLwiN is assuming that the parameters in MLwiN are in the order that they appear in the equation, however as agecen50[1:3] is in the fixed part, but 1[1:3] isn't the order is reversed due to the way the variables are added to the model. I will attempt to fix this for the next version of the software but in the mean time the workaround is to reorder the terms in the random part so that any terms shared with the fixed part come first and are in the same order. In your case this would mean changing the model to the following:
Just to let you know we have just released a new version of R2MLwiN (0.8-5) to CRAN which should fix both of the bugs that you reported. Please let us know if you find any further problems.