Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Bootstrap vectors from 2 estimators
From
Alfonso S <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Bootstrap vectors from 2 estimators
Date
Sun, 29 Sep 2013 08:14:51 -0700 (PDT)
Hi everyone,
I am estimating a panel data fractional probit model, and I want to be able to bootstrap both the coefficients and the marginal effects. This code works but you can see that it is in fact bootstrapping the xtgee command twice (using mfx instead of margins because I have to run it in Stata 10):
capture program drop geeMargins
program geeMargins, eclass
tempname b
xtgee ysm $xlist2 mldis_totcurexppp mlunch mlenrol, family(binomial) link(probit) corr(exch)
mfx
matrix `b' = e(Xmfx_dydx)
ereturn post `b'
end
xtgee ysm $xlist2 mldis_totcurexppp mlunch mlenrol, family(binomial) link(probit) corr(exch) vce(bootstrap, reps(`repnum') seed(10101))
bootstrap _b, reps(500) seed(10101) nowarn: geeMargins
I find this inefficient, because I would like to just have to run the command geeMargins with the bootstrap and return the coefficients of the xtgee estimation and the marginal effects from mfx. I have tried many things but I can't seem to be able to return both. The following is what I currently have:
capture program drop geeMargins2
program geeMargins2, eclass
xtgee ysm $xlist2 mldis_totcurexppp mlunch mlenrol, family(binomial) link(probit) corr(exch)
ereturn matrix coeffs = e(b)
mfx
ereturn matrix apes = e(Xmfx_dydx)
ereturn local cmd = "bootstrap"
end
bootstrap geecs=e(coeffs) apes=e(apes), reps(500) seed(10101) nowarn: geeMargins2
This throws an error of varlist not conforming. I would really appreciate any help on this, because this can easily be extended to bootstrapping the results from several estimation methods in one command, instead of having to right a bootstrap command for each estimation. For example, you can estimate the above model with glm and xtgee, bootstrapping the coefficients of both in one command, thus only having to do the resampling once, and getting the results for both (as well as the marginal effects for that matter).
Thanks for any help you can provide.
Alfonso
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/