Predicted probabilities after multilevel logit model
Posted: Sun Jun 24, 2012 9:08 pm
Hi everyone,
I am currently working on a research project for which I am running 3-level logit models (households are nested within municipality which are nested within states) to predict out-migration in relation to a environmental variable (measured at the state-level). I found a pretty interesting quadratic association. I used the following model (abbreviated version is displayed and the real model contains a lot more controls).
In this equation env is the continuous environmental variable of interest and env2 is the squared term (env x env). Both regression coefficients are highly significant (b env = -.481, p=.002; b env2 = -.317, p<.001) suggesting a concave association. I would now like to display this association by means of a graph. I used the following equation to obtain predicted values (I changed the name of the environmental measures from env to lraind and env2 to lraind2).
I then transformed the yhat values so that the y-axis reflects predicted probabilities instead of the meaningless log odds scale…
And finally, I have plotted this association using a simplistic scatter plot.
However, this a rather crude way of displaying the association and I am not sure whether the use of the constant (_b[cons]*cons) term in my equation for yhat makes sense. I would rather like to use STATA’s margins command to obtain predicted probabilities. However, it appears that it is not possible to use this post-estimation command after estimating a logit model using runmlwin. Or am I wrong? Has anyone used STATA’s margins command in combination with runmlwin? Or is there another way to correctly calculate and display predicted probabilities (holding all other variables at the mean)?
Thanks so much for your help!
Best,
Raphael
I am currently working on a research project for which I am running 3-level logit models (households are nested within municipality which are nested within states) to predict out-migration in relation to a environmental variable (measured at the state-level). I found a pretty interesting quadratic association. I used the following model (abbreviated version is displayed and the real model contains a lot more controls).
Code: Select all
runmlwin mig cons ageh eduh env env2 , ///
level3(state: cons) ///
level2(muni: cons) ///
level1(hhID: ) ///
discrete(distribution(binomial) link(logit) denominator(cons)) batch
Code: Select all
gen yhat = (_b[cons]*cons) + (_b[lraind]*lraind) + (_b[lraind2]*lraind2)
Code: Select all
replace yhat=((exp(yhat))/(1+(exp(yhat))))
Code: Select all
twoway (scatter yhat lraind)
Thanks so much for your help!
Best,
Raphael