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
Problem with creating followup time for survival analysis accounting for disease, death and migrationHello! I would need some help with the coding of my stset for survival analysis. I have a population…
Low within variation independent variable and fixed effectsDear all, I am running a regression where one of my (independent) variables of interest has low wit…
Fixed effect model for hospital and patietn level data (really need some help)Hi, I am exploring a dataset of patient data from 20 hospitals for 3 years. Among which 9 hospitals…
weighting variables before collapsing survey data in STATAHello everyone, I am using 4 rounds of a labor force panel survey for the years (1998, 2006, 2012 a…
insert page break when appending output into a .tex file with -esttab-Dear all, a question on a general problem with no specific reference to particular data. Suppose y…
Subscribe to:
Post Comments (Atom)
0 Response to Monte Carlo--How to see B variability
Post a Comment