Specialized on Data processing, Data management Implementation plan, Data Collection tools - electronic and paper base, Data cleaning specifications, Data extraction, Data transformation, Data load, Analytical Datasets, and Data analysis. BJ Data Tech Solutions teaches on design and developing Electronic Data Collection Tools using CSPro, and STATA commands for data manipulation. Setting up Data Management systems using modern data technologies such as Relational Databases, C#, PHP and Android.
Saturday, February 1, 2020
How to save my y and residual errors from a regression loop
Could you tell me why I cannot save my y or residuals here? Everything working except last and I dont know how to store y.
In addition the looping over values is not performing, it only does the 10 obs specified in local mc = 10.
Thanks much!
clear local mc = 10
set obs `mc'
g data_store_x3 =.
g data_store_x2 =.
g data_store_con= .
g data_store_y =.
quietly{
forvalues i = 1(1) `mc' {
if floor((`i'-1)/100) == ((`i'-1)/100) {
noisily display "Working on `i' out of `mc' at $S_TIME"
}
preserve
clear
set obs 10
g x2 = rnormal()
g x3 = rnormal()
g e = runiform()
g y = 1 -3*x2 + 2*x3 + e
reg y x2 x3
local x2coeff = _b[x2]
local x3coeff = _b[x3]
local const = _b[_cons]
restore
replace data_store_x3 = `x3coeff' in `i'
replace data_store_x2 = `x2coeff' in `i'
replace data_store_con = `const' in `i'
}
}
summ data_store_con data_store_x2 data_store_x3 data_store_y
display e(rmse)
predict res, resid
No comments:
Post a Comment