TITLE: two-level time series analysis with a univariate first-order autoregressive AR(1) model
for a continuous dependent variable with a covariate, linear trend, random slopes,
and a random residual variance
Set up as a cross-classified model with empty Level2A (time) model
Montecarlo:
names are y x w xm;
nobservations = 20000;
nreps = 1;
CSIZES = 200[100(1)];
ncsize = 1[1];
lagged = y(1);
Between = (level2b)w (level2b)xm;
within = x;
save = ex9.37.dat;
ANALYSIS: TYPE = CROSS random;
estimator=bayes; process=2;
fbiter = (100); ! doesn't need to go to convergence to generate the data
model population:
%within%
sx | y ON x;
sy | y ON y&1;
y*1; x*1;
%between LEVEL2A% ! time
! empty
y@0; sx@0; sy@0;
%between LEVEL2B% ! subject
y*.5; [y*2];
w*1; xm*1;
w with xm*.5;
[sx*.5]; sx*.2;
[sy*.3]; sy*.02;
y on w*.3 xm*.4;
sx on w*.2 xm*.3;
sy on w*.05 xm*.05;
model:
%within%
sx | y ON x;
sy | y ON y&1;
y*1; x*1;
%between LEVEL2A% ! time
! empty
y@0; sx@0; sy@0;
%between LEVEL2B% ! subject
y*.5; [y*2];
[sx*.5]; sx*.2;
[sy*.3]; sy*.02;
y on w*.3 xm*.4;
sx on w*.2 xm*.3;
sy on w*.05 xm*.05;
output: tech8 tech9;