I found the following script from one of the other threads to be helpful in calculating IV standard errors manually. I want to find out how I can get STATA to use the vcorr from this script in the regression table to generate t-statistics and p-values.
I need to estimate the two stages in my model manually because in the second stage, I use the prediction from the first stage, as well as the interaction of the prediction with another variable. It seemed like this requirement could not be handled by ivreg2. I would appreciate any advice on how I can use the manually calculated SE's in reporting my results. Apologies, I am not an advanced user of STATA and would appreciate any insights on this question.
/ how to fix 2SLS estimates done 'by hand'
sysuse auto, clear
ivreg2 price (weight = turn foreign) headroom, small
estat vce
di e(rmse)
mat v2sls = e(V)
// First stage reg
qui reg weight turn foreign headroom
predict double what, xb
// Second stage reg
qui reg price what headroom
scalar rmsebyhand = e(rmse)
// the 'wrong' VCE, calculated from the instruments
mat vbyhand = e(V)
scalar dfk = e(df_r)
// the correct resids: orig regressors * second stage coeffs
g double eps2 = (price - _b[what]*weight - _b[headroom]*headroom - _b[_cons])^2
qui su eps2
// corrected RMSE, based on the correct resids
scalar rmsecorr = sqrt(r(sum) / dfk)
// corrected VCE, using the right s^2
mat vcorr = (rmsecorr / rmsebyhand)^2 * vbyhand
mat li vcorr
// check to see that it equals the real 2SLS VCE
mat diff = v2sls - vcorr
mat li diff
Related Posts with Manually calculating IV standard errors and getting STATA to use them in the regression table
Generating a new numeric variable that gives the proportion of a value count and the total count of anotherHello Statalist, I'm working with an integer variable "ind" (for industry) and a 0-1 binary float v…
strange behaviour in logit with clustering of standard errors.In performing a logistic regression with 'logit', I am encountering very significant association's (…
Selecting multiple variables (with * or ?)Dear all, Can I please ask you a question about selecting multiple variables by the use of the aste…
Exporting of Stata Graphs as .pngI am using Stata/IC 14.2 for Windows (64-bit). I am also using Windows 10 I have a long .do file whe…
Unable to reshape multiply imputed dataHello, I am unable to reshape my data into long format to run a fixed effects model. As can be seen…
Subscribe to:
Post Comments (Atom)
0 Response to Manually calculating IV standard errors and getting STATA to use them in the regression table
Post a Comment