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: Variation on lincom for bootstrapped coefficients
From
Jessica Ellen Leight <[email protected]>
To
[email protected]
Subject
st: Variation on lincom for bootstrapped coefficients
Date
Mon, 18 Apr 2011 13:06:19 -0400
Good afternoon,
I am resubmitting a previous question on lincom with the code for my estimation
procedure included below.
The question is:
I have estimated a regression using a two-step manual bootstrap procedure,
essentially the following (X is itself an estimated object, hence the two-step
procedure.)
Y = AX + BX^2
I would now like to do a lincom-like procedure to find the standard error of a
linear combination of these parameters A and B. More specifically, I'd like to
find the standard error of (A+BX) at each value of X. Is there any way I can
adapt lincom to manually input the coefficients and standard errors I have
already estimated, rather than using it as a postestimation command, or is
there any other command that can be used for this purpose?
Thank you.
Best,
Jessica Leight
cap prog drop myprogram
prog def myprogram
args variable reps
**************************************
cd
use "Stata data files\Household data collapsed with Gini", clear
tempfile main bootsave
set seed 12345
qui tab year, gen(yearfixed)
qui tab villageid, gen(villagefixed)
qui probit allocation2 residualint yearfixed* villagefixed*
qui predict phat
qui gen phatsq=phat^2
qui reg `variable' yearfixed* villagefixed* phat v3_a057
gen phat_1_`variable'=_b[phat]
qui replace phat_1_`variable'=round(phat_1_`variable', .001)
global phat_1_`variable'=phat_1_`variable'
qui reg `variable' yearfixed* villagefixed* v3_a057 phat phatsq
gen phat_2_`variable'=_b[phat]
gen phatsq_`variable'=_b[phatsq]
qui replace phat_2_`variable'=round(phat_2_`variable', .0001)
qui replace phatsq_`variable'=round(phatsq_`variable', .001)
global phat_2_`variable'=phat_2_`variable'
global phatsq_`variable'=phatsq_`variable'
gen p_0=phat_2_`variable'/(-phatsq_`variable'*2)
replace p_0=round(p_0,.001)
global p_0_`variable'=p_0
gen mteupper=phat_2_`variable'+2*phatsq_`variable'
replace mteupper=round(mteupper, .001)
global mteupper_`variable'=mteupper
drop phat* p_0 mteupper
qui save `main', replace
capture erase `bootsave'
qui postfile bsresults phat_1 phat_2 phatsq_2 using `bootsave', replace
*/ Begin bootstrap replications */
forvalues b=1/`reps' {
use `main', replace
bsample
disp "`variable' iteration # `b'"
noisily capture qui probit allocation2 residualint yearfixed* villagefixed*,
iterate(100)
qui predict phat
qui gen phatsq=phat^2
*/ Regressions */
qui reg `variable' yearfixed* villagefixed* phat v3_a057
local temp1=_b[phat]
qui reg `variable' yearfixed* villagefixed* phat phatsq v3_a057
post bsresults (`temp1') (_b[phat]) (_b[phatsq])
drop phat* `temp*'
}
qui postclose bsresults
use `bootsave', clear
foreach x of varlist phat_1 phat_2 phatsq {
egen se_`x'_`variable'=sd(`x')
qui replace se_`x'_`variable'=round(se_`x'_`variable', .001)
global se_`x'_`variable'=se_`x'_`variable'
}
end
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/