Hi everyone,
I created a monte carlo simulation. I am trying to see attentuation bias which I see, but I am trying to see that the betas for run with measurement error in it are more variable and also the standard errors are less accurate. I created a code with an x_true and an x_observed. Can you help me find a code so I can figure out the variability of the betas in my simulations? I ran with this code:
cap prog drop fivesample /*note need to drop the program if already exists */
program fivesample, rclass
drop _all
set obs 50
generate x_true = rnormal()
generate eps = rnormal()
generate measerr= rnormal()
generate x_observed= x_true + measerr
generate y = 1 + 1*x_true + eps
regress y x_true
return scalar betatrue = _b[x]
return scalar stderrtrue = _se[x]
regress y x_observed
return scalar betaobs = _b[x]
return scalar stderrobs = _se[x]
end
fivesample
return list
simulate betat = r(betatrue) set = r(stderrtrue) betao = r(betaobs) seo = r(stderrobs) vartrue=r(vartrue) varobs=r(varobs), seed(4553) reps(1000) nodots: fivesample
summarize betat betao set seo vartrue varobs
Related Posts with Monte Carlo--How to see B variability
Question about spregdpdDear all, After we use xtabond or xtabond2, we can use "estat serial" to get AR(1) and AR(2) .But if…
Lagged Dependent Variable (Panel)Is it appropriate to include the dependent variable as a control in an FE panel regression. Previous…
Fixed Effects: Variables Indexed by Country, Sector and TimeI am trying to run a regression for fixed effects specifications. The dependent variable is Volatili…
A few questions about my analysis in StataDear all, I am new on this forum, so I hope I'm posting these questions on the right place. I am n…
event study linear regression modelDear all, I read previous posts about event study, but I still cannot find my starting point for co…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo--How to see B variability
Post a Comment