Hi all, I am hoping someone can help me. I am trying to simulate data with autocorrelation. When I enter the program name regLDV Stata returns an error "invalid name"
global nobs = 200
global nmc = 1000
set seed 10101
set obs $nobs
gen time = _n
tsset time
scalar theta = .8 /*autocorrelation in x */
scalar beta = 10 /* slope for x */
scalar sigma = 20 /*variance of y */
scalar delta = .5 /*coeff for lagged y */
scalar rho = .8 /*auto correlation in errors */
gen x = rnormal()
replace x = theta*L.x + rnormal() in 2/$nobs
gen u = 0
gen y = 0
program regLDV, rclass
tempname sim
postfile 'sim' b1 b2 se1 se2 using results, replace
quietly {
forvalues i = 1/$nmc {
*generate errors and samples of y
replace u = rho.L.u + rnormal(0,sigma) in 2/$nobs
replace y = beta*x+delta*L.y + u in 2/$nobs
*run the regression
reg y x /*b1 OLS, w/o LDV */
*save the estimated slopes and its std error of b
scalar b1 = _b[x]
scalar se1 = _se[x]
*repeat for other
post 'sim' (b1) (b2) (se1) (se2)
}
}
postclose 'sim'
end
regLDV
use results, clear
summarize
Thanks
Kate
Related Posts with Program rclass, "invalid name" returns
MANCOVA outliersDear all, I have performed the following Mahalanobis distance command to test for multivariate outli…
How to capture a folder path in a macroHi everyone, I intend to capture a folder path in a macro and use it later in a program to save fil…
Bringing gen() into Margins, at()Hi guys, I am trying to work with counterfactuals using margins and I'm having a hard time includin…
Cumulative returns with asrolHi, I'm probably doing something wrong with the "asrol" syntax from Attaullah Shah. I'm not getting…
Error Correction Model: Specification in StataHi all, I am trying to perform an EC model but I do not know how to specify the last two elements (E…
Subscribe to:
Post Comments (Atom)
0 Response to Program rclass, "invalid name" returns
Post a Comment