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
Marginal effects of interaction between continuous and factor variables in fixed effects modelsHello. How may I test the marginal effects of my variables when there is a continuous-factor-interac…
Merge: variable does not uniquely identify observations in the master dataHi everyone, I have a data with a variable household ID that does not uniquely identify observation…
is it possible to create a new variable with otherwise/else function?Hi All, I am trying t create a new variable that defines Car owned status of a person. What I want i…
Generating measures of repeat collaboration between firms over timeDear Statalist. I am trying to generate 2 separate measures of repeat collaboration between firms c…
psmatch2Hello! When I use the syntax psmatch2 chronic1 `covariates' , logit common caliper(.001) neighbor(1)…
Subscribe to:
Post Comments (Atom)
0 Response to Program rclass, "invalid name" returns
Post a Comment