Question about the re-coded level-1 variables

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!

Go to R2MLwiN: Running MLwiN from within R >> http://www.bris.ac.uk/cmm/software/r2mlwin/
Post Reply
divasong
Posts: 13
Joined: Tue Sep 26, 2017 2:35 pm

Question about the re-coded level-1 variables

Post by divasong »

Dear,

Hello, I have a problem with the output of a binary model in R2MLwiN. I have recoded an ordered level-1 variable (1<2<3<4) and input it for a three level binary model using MCMC. In the output, it only shows the coefficient of its reference level but not of other three levels as for unordered categorical variables. Just wander why this happened and how to explain it if it is right. I have listed the results for your reference. Many thanks.

> r_temp.df$coef
est se stat p lwr upr ess
FP_Intercept -1.2461333 2.677351e-01 -4.6543512 3.250025e-06 -1.762658028 -0.7756006 73.06440
FP_Age_15-24 -0.1464940 3.333534e-01 -0.4394556 6.603315e-01 -0.829658486 0.4840200 511.57278
RP3_var_Intercept 0.2920189 5.101553e-01 0.5724117 5.670431e-01 0.001720491 1.7420080 45.11112
RP2_var_Intercept 3.9726860 9.247642e-01 4.2958908 1.739932e-05 2.442040654 6.0415510 368.77411
RP1_var_bcons_1 0.9999998 1.414214e-05 70710.6639765 0.000000e+00 1.000000000 1.0000000 5000.00000

> result_b2.df[[1]]$contrasts
$Age.f
.L .Q .C
1 -0.6708204 0.5 -0.2236068
2 -0.2236068 -0.5 0.6708204
3 0.2236068 -0.5 -0.6708204
4 0.6708204 0.5 0.2236068

Regards.

Diva
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Question about the re-coded level-1 variables

Post by ChrisCharlton »

Is this variable defined as a factor within R? If not then it will be treated as continuous. For an example of this kind of model see http://www.bristol.ac.uk/cmm/media/r2ml ... CGuide10.R (the lc variable has four categories with the values 0: no children, 1: one child, 2: two children, 3: three or more children).
divasong
Posts: 13
Joined: Tue Sep 26, 2017 2:35 pm

Re: Question about the re-coded level-1 variables

Post by divasong »

Thanks, Chris.

The "Age" here is an ordered factor, and I have recorded it using Polynomial Coding, and there is also this function in MLwiN. And once I tick this choice when I add the individual variable, the result shows that it only estimates the coefficient of reference level (e.g. Here I defined "Age_15-24" as the reference level of "Age", then it only shows the coefficient of Age_15-24. Does that mean I can not record categorical variable like this? Because I have a set of categorical individual variables, I recorded them just for the grand mean and wave their possible influences on the estimations of other variables.

> r_temp.df$coef
est se stat p lwr upr ess
FP_Intercept -1.2461333 2.677351e-01 -4.6543512 3.250025e-06 -1.762658028 -0.7756006 73.06440
FP_Age_15-24 -0.1464940 3.333534e-01 -0.4394556 6.603315e-01 -0.829658486 0.4840200 511.57278
RP3_var_Intercept 0.2920189 5.101553e-01 0.5724117 5.670431e-01 0.001720491 1.7420080 45.11112
RP2_var_Intercept 3.9726860 9.247642e-01 4.2958908 1.739932e-05 2.442040654 6.0415510 368.77411
RP1_var_bcons_1 0.9999998 1.414214e-05 70710.6639765 0.000000e+00 1.000000000 1.0000000 5000.00000

And as I build up a three-level model (individual, subdistrict, district), when I try to explore the random effects of individual variables at level-2, the results only tells me the random effect is 0.000000000. Does that mean there is no random effect of this variable or maybe it was not estimated in the model? Many thanks.

RP3_var_Intercept RP2_var_Intercept RP2_cov_Intercept_ICAge4 RP2_var_ICAge4 RP1_var_bcons_1
RP3_var_Intercept 0.09577996 -0.05865885 0 0 0
RP2_var_Intercept -0.05865885 0.49250499 0 0 0
RP2_cov_Intercept_Age_15-24 0.00000000 0.00000000 0 0 0
RP2_var_Age_15-24 0.00000000 0.00000000 0 0 0
RP1_var_bcons_1 0.00000000 0.00000000 0 0 0

Best.

Diva
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: Question about the re-coded level-1 variables

Post by ChrisCharlton »

Would it be possible to provide some example syntax so that I can attempt to replicate what you are seeing?
divasong
Posts: 13
Joined: Tue Sep 26, 2017 2:35 pm

Re: Question about the re-coded level-1 variables

Post by divasong »

Dear Chris,

Thanks. I have read the manual you mentioned, and I think maybe R2MLwiN would treat ordered factors as un-ordered categorical factors. In my case, as the predictor is not a strict ordered factor (e.g. one level of "Age" is 55+), thus I could just treat it as un-ordered categorical factors. Many thanks.

Regards.

Diva
Post Reply