Bookmark and Share

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]

Re: st: Bootstrap vectors from 2 estimators


From   Alfonso Sanchez-Penalver <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Bootstrap vectors from 2 estimators
Date   Sun, 29 Sep 2013 14:55:34 -0400

Gracias Jorge,

That works great!!!

Alfonso Sánchez-Peñalver

> On Sep 29, 2013, at 1:39 PM, Jorge Eduardo Pérez Pérez <[email protected]> wrote:
> 
> You can append the matrices estimated from both commands in one vector
> and bootstrap it:
> 
> clear
> version 10
> webuse union
> xtset id year
> cap program drop myxtgee
> *Run once to get e(sample)
> xtgee union age grade not_smsa south, family(binomial) link(logit)
> keep if e(sample)
> * Define names for coef vector
> glo vars "age grade not_smsa south"
> glo mfx ""
> foreach x in $vars  {
> glo mfx "${mfx} mfx_`x'"
> }
> * Define program for bootstrap
> program define myxtgee, eclass
> * Estimate
> xtgee union ${vars}, family(binomial) link(logit)
> matrix b=e(b)
> mfx
> matrix mfx=e(Xmfx_dydx)
> matrix colnames mfx = ${mfx}
> matrix coefs = (b,mfx)
> ereturn post coefs
> end
> * Bootstrap
> bs , rep(20) : myxtgee
> 
> 
> Hope this helps,
> 
> --------------------------------------------
> Jorge Eduardo Pérez Pérez
> Graduate Student
> Department of Economics
> Brown University
> 
> 
>> On Sun, Sep 29, 2013 at 11:14 AM, Alfonso S <[email protected]> wrote:
>> 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/
> 
> *
> *   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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index