Hi
In my simulation I am trying to compare output from OLS and 2SLS. I have the following code which saves beta for each in a matrix but I also want to save the standard errors for both OLS and 2SLS. Could you please advise how se's can be added.
set seed 10101
capture program drop mcsimb
program mcsimb, eclass
clear
** change this for Nobs
set obs 500
* z1 & z2 are normally distributed
gen z1=rnormal()
gen z2=rnormal()
* create u and v based on the given correlation, and assume that otherwise the variance is 1
matrix corruv=[1,.8\.8,1]
drawnorm u v , corr(corruv)
* generate X
gen x=1+5*z1+10*z2+v
* generate y
gen y=1+x+u
* estimate models
reg y x
matrix b= _b[x]
ivregress 2sls y (x=z1 z2)
matrix b=b,_b[x]
matrix colname b= ols iv
ereturn post b
end
simulate, reps(1000): mcsimb
summarize
Thank you
Kate
Related Posts with Monte Carlo simulation comparing output for OLS and 2SLS by saving beta and se's in matrix
elasticity- price, income etc. do i use a log-log model or employ mfx-eyex?Hi, I am very new to Stata so I apologise for the amateur-ness of my question. How do I calculate pr…
Latent transition analysis in StataHello scholars, I have seen that the question "Can Stata do latent transition analysis?" was asked …
cumulative sum that restarts at 0, if observe "0" in the original column.Hi, I have a simple question. I would like to have a cumulate sum that restarts if observing 0 in th…
GEE and Fixed Effects TobitHello everyone, I have been doing extensive reading for some time to decide upon some appropriate …
teffects - predict pscore, psI estimated the following model before estimating. I need to check the predicted propensity score mo…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo simulation comparing output for OLS and 2SLS by saving beta and se's in matrix
Post a Comment