Page 1 of 1
testing for random slope
Posted: Fri Nov 02, 2012 10:27 am
by Sschaffnit
I am running discrete time event history analyses using runmlwin.
How do I test for a random slope in stata after running the model? I tried using test, but couldn’t seem to make it work. Here is an example of what I’m running:
runmlwin y1 ///
i.yrrange Ragegrp lwp i.md i.fd i.partstat ///
PartIn i.edugrp wealth socmob nsib ///
y2_Ragegrp y3_Ragegrp y4_Ragegrp y6_Ragegrp y7_Ragegrp y8_Ragegrp ///
y7_fd y9_fd y9_md y2_lwp y9_lwp ///
y2_wealth y3_wealth y4_wealth y5_wealth y6_wealth y7_wealth y8_wealth y9_wealth ///
y2_egrp3 y3_egrp3 y4_egrp3 y5_egrp3 y6_egrp3 y7_egrp3 y8_egrp3 y9_egrp3 ///
y2_partstat y3_partstat y4_partstat y5_partstat y6_partstat y7_partstat ///
y8_partstat y9_partstat cons, ///
level2(acountry: liveswparents cons) ///
level1(time: ) ///
discrete(distribution(binomial) link(logit) denom(cons)) ///
maxi(5000) nopause
Re: testing for random slope
Posted: Fri Nov 02, 2012 10:49 am
by GeorgeLeckie
Hi Sschaffnit,
LR tests (the -lrtest- command) are advised when testing for random slopes, not Wald tests (the -test- command)
So simply fit the random intercept model, then store the model results using -estimates store ri-
Then fit random slope model and store results using -estimates store rs-
Then do LR test using -lrtest ri rs-
Note, I see that you have specified maxi(5000). Be careful this is very high and if you need this many iterations then there is very likely something wrong with your model.
Your model is quite complex (at least in the fixed part) so you may want to consider building your model up sequentially using the previous model estimates as the starting values of the next model and so on
Also, you should fit any final model certainly by PQL2 and preferably by MCMC
See previous posts on discussions of these issues, also see the help file
Best wishes
George
Re: testing for random slope
Posted: Fri Nov 02, 2012 11:08 am
by Sschaffnit
Thank you!
Re: testing for random slope
Posted: Fri Nov 02, 2012 1:25 pm
by Sschaffnit
Hello again,
I tried using the lrtest command after running (and storing) the two models, but have gotten this error:
. lrtest ri rs
ri does not contain scalar e(ll)
r(498);
I have included the code that I used below. Do I need to specify a certain option while using runmlwin to make sure e(11) is stored? When I view the ereturn list, e(11) is indeed skipped.
Thank you again for the previous response!
/*random intercept*/
runmlwin y1 ///
i.yrrange Ragegrp liveswparents i.motherdead i.fatherdead i.partstat ///
PartIn i.edugrp SES socmobedu nsib ///
y2_Ragegrp y3_Ragegrp y4_Ragegrp y6_Ragegrp y7_Ragegrp y8_Ragegrp ///
y7_fatherdead y9_fatherdead y9_motherdead y2_liveswparents y9_liveswparents ///
y2_SES y3_SES y4_SES y5_SES y6_SES y7_SES y8_SES y9_SES ///
y2_egrp3 y3_egrp3 y4_egrp3 y5_egrp3 y6_egrp3 y7_egrp3 y8_egrp3 y9_egrp3 ///
y2_partstat y3_partstat y4_partstat y5_partstat y6_partstat y7_partstat ///
y8_partstat y9_partstat cons, ///
level2(acountry: cons) ///
level1(time: ) ///
discrete(distribution(binomial) link(logit) denom(cons) pql2) ///
maxi(500) nopause
estimates store ri
/*random slope*/
runmlwin y1 ///
i.yrrange Ragegrp liveswparents i.motherdead i.fatherdead i.partstat ///
PartIn i.edugrp SES socmobedu nsib ///
y2_Ragegrp y3_Ragegrp y4_Ragegrp y6_Ragegrp y7_Ragegrp y8_Ragegrp ///
y7_fatherdead y9_fatherdead y9_motherdead y2_liveswparents y9_liveswparents ///
y2_SES y3_SES y4_SES y5_SES y6_SES y7_SES y8_SES y9_SES ///
y2_egrp3 y3_egrp3 y4_egrp3 y5_egrp3 y6_egrp3 y7_egrp3 y8_egrp3 y9_egrp3 ///
y2_partstat y3_partstat y4_partstat y5_partstat y6_partstat y7_partstat ///
y8_partstat y9_partstat cons, ///
level2(acountry: cons liveswparents) ///
level1(time: ) ///
discrete(distribution(binomial) link(logit) denom(cons) pql2) ///
maxi(500) initsprevious nopause
estimates store rs
/*lrtest*/
lrtest ri rs
Re: testing for random slope
Posted: Fri Nov 02, 2012 1:42 pm
by GeorgeLeckie
Hi Sschaffnit,
I apologise, what I wrote previously only applies to continuous response models in MLwiN as these are the only models where maximum likelihood is used.
Discrete response models are fitted by quasi-likelihood (i.e. an approximation to maximum likelihood) and so the log-likelihood (ll) statistics are not valid (and so not reported) and therefore neither are likelihood ratio tests.
So when you have discrete response models and you have fitted by PQL2 (the most accurate quasi-likelihood estimation procedure available in MLwiN) the best you can do is a Wald test. However, you have to be cautious as Wald tests assume that the parameters involved have normal sampling distributions and this is unlikely to be the case for variance parameters. So you need something like this
test [RP2]var(liveswparents) = 0 [RP2]cov(liveswparents,cons) = 0
A better approach would be to fit the model by MCMC (as MCMC parameter estimates don't suffer from the downwards biases seen when using quasilikelihood estmation) and then compare model fit using the bayesian DIC statistic (analogous to AIC statistic when using maximum likelihood
George
Re: testing for random slope
Posted: Fri Nov 02, 2012 1:59 pm
by Sschaffnit
Thank you. That is really helpful!