Several times I've seen or received queries about how, after -cmp-, to run -margins- on the probability of certain outcomes, such as (1,1) from a bivariate probit model. It turns out that this already was possible for some models, using a sort of trick. But the trick was undocumented and it would crash for ordered-probit and non-alternative-specific multinomial probit models. The latest version of the cmp package documents the trick and makes it work for pretty much all models. Install with "ssc install cmp, replace".
Somewhat unusually I think, you can predict the observation-level log likelihood after fitting with cmp, using "predict XXX, lnl". So to get marginal effects on the probability of given outcomes, you run the estimate, preserve the data set, modify the outcome variables to represent the outcome of interest, run -margins- to get marginal effects on the exponential of the log likelihood, then restore the original data. The process is fairly intuitive, if inelegant. It is slow because margins calls cmp's predict command many times, and each time cmp sets up the entire estimation problem again. But it works. Here are some examples that illustrate by replicating output from -biprobit- and -mprobit-:
Somewhat unusually I think, you can predict the observation-level log likelihood after fitting with cmp, using "predict XXX, lnl". So to get marginal effects on the probability of given outcomes, you run the estimate, preserve the data set, modify the outcome variables to represent the outcome of interest, run -margins- to get marginal effects on the exponential of the log likelihood, then restore the original data. The process is fairly intuitive, if inelegant. It is slow because margins calls cmp's predict command many times, and each time cmp sets up the entire estimation problem again. But it works. Here are some examples that illustrate by replicating output from -biprobit- and -mprobit-:
Code:
cmp setup webuse laborsup gen byte anykids = kids > 0 biprobit (anykids = fem_inc male_educ) (fem_work = male_educ) margins, dydx(fem_inc) predict(p11) // average marginal impact of fem_inc on probability of (1,1) cmp (anykids = fem_inc male_educ) (fem_work = male_educ), ind($cmp_probit $cmp_probit) preserve replace anykids=1 replace fem_work=1 margins, dydx(fem_inc) expression(exp(predict(lnl))) force restore webuse sysdsn3 mprobit insure age male nonwhite site2 site3 margins, dydx(nonwhite) predict(outcome(2)) // average marginal impact of nonwhite on probability of outcome 2 cmp (insure = age male nonwhite site2 site3, iia), nolr ind($cmp_mprobit) qui preserve replace insure = 2 margins, dydx(nonwhite) expression(exp(predict(lnl))) force restore
Comment