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
Tabstar for three variables?Hi! I have two dummy variables and one continuous (age). I want to check mean, median, sd, max and m…
Controls, fixed effect models, and an issueDear Statalist, I am estimating the effect of parental separation on the amount of time a child spe…
Food price seasonality and volatility analysisI would want to do an analysis on food price seasonality and volatility using trigonometric and sawt…
Question about numerical overflowDear STATA users, I am very new to stata, so maybe this is a dumb question. I am trying to create a…
looping over variables in a local macroDear members of the Statalist community, I am a grad student with experience in R, currently workin…
Subscribe to:
Post Comments (Atom)
0 Response to Program rclass, "invalid name" returns
Post a Comment