filmov
tv
Introductory Stata 54: Simulation for Properties of OLS under Measurement Error

Показать описание
In the previous two videos, I have shown you how to use simulation to examine the properties of OLS and IV estimation methods in the presence of endogeneity due to omitted variables. In this video, we will take a look at the properties of the OLS estimator when variables have measurement errors. It often happens. For example, instead of the actual annual income, what we have in the dataset is the reported annual income with measurement errors.
There are two cases of measurement errors. One is the measurement error in an explanatory variable. The other is the measurement error in the outcome variable.
#MeasurementError #Simulation #DataGeneratingProcess
*********************************************
*54. Simulation for Properties of OLS under *
* Measurement Error *
*********************************************
clear
program drop _all
capture log close
*Measurement Error in an Explanatory Variable
program define simu1
clear
set obs 5000
generate mu=rnormal()
generate nu=rnormal()
generate xstar=rnormal()
generate y=1-2*xstar+mu
generate x=xstar+nu
regress y x
end
simu1
simulate, rep(300) seed(8964): simu1
summarize
*Measurement Error in the Outcome Variable
program define simu2, rclass
clear
set obs 5000
generate mu=rnormal()
generate nu=rnormal()
generate x=rnormal()
generate ystar=1+1*x+mu
generate y=ystar+nu
regress ystar x
return scalar beta1=_b[x]
regress y x
return scalar beta2=_b[x]
end
simu2
simulate b_actual=r(beta1) b_measure=r(beta2), rep(300) seed(8964): simu2
summarize
log close
There are two cases of measurement errors. One is the measurement error in an explanatory variable. The other is the measurement error in the outcome variable.
#MeasurementError #Simulation #DataGeneratingProcess
*********************************************
*54. Simulation for Properties of OLS under *
* Measurement Error *
*********************************************
clear
program drop _all
capture log close
*Measurement Error in an Explanatory Variable
program define simu1
clear
set obs 5000
generate mu=rnormal()
generate nu=rnormal()
generate xstar=rnormal()
generate y=1-2*xstar+mu
generate x=xstar+nu
regress y x
end
simu1
simulate, rep(300) seed(8964): simu1
summarize
*Measurement Error in the Outcome Variable
program define simu2, rclass
clear
set obs 5000
generate mu=rnormal()
generate nu=rnormal()
generate x=rnormal()
generate ystar=1+1*x+mu
generate y=ystar+nu
regress ystar x
return scalar beta1=_b[x]
regress y x
return scalar beta2=_b[x]
end
simu2
simulate b_actual=r(beta1) b_measure=r(beta2), rep(300) seed(8964): simu2
summarize
log close