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
How to omit one category of margins from marginsplotDear Statalisters, I have the following easy issue to solve. I would like to plot margins of employ…
Generate sum of preceding values conditional on dates, id, and illness typeDear Sir/Madam, I am Masters student and working on Stata 14.2 obtained by my University. I am att…
Loops within loopsDear everyone, I have trouble when create a loop to generate a new variable for my dataset. My data…
create dummy variable based on condition of other variablesDear Statalist, I am struggling with this problem which is very difficult to explain. I am trying m…
Time-series regression loop (approximately 250 regressions) and saving their coefficientsHi all, I've performed a time-series regression loop by using the following code (approximately 250…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo--How to see B variability
Post a Comment