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
How to create two new variables from one?Dear statalists, I'm writing my master thesis and have come across some data handling-issues. I use…
dydx() margins 'not estimable'Hello all I'm doing a difference-in-difference regression with 3 time points (1 pre, and 2 post). M…
help with 3 level meglmHi, I want to look at factors that predict outcome (ordered 0-4). The factors I want to look at are…
IPFraking - How to account for population totals?Hello, I am very new to Stata, so please bear with me.....I would like to adjust my sample to the p…
Using quarterly() to generate date from string.I'm running Stata/SE 15.1 (updated 27/08/19) on MacOS 10.13.5 I would like to convert string data t…
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