TITLE: this is an example of two-level univariate first-order
autoregressive AR(1) model with a random intercept,
random AR(1), and random residual variance
Step 1: although we are interested in a twolevel model
we generate data using cross-classified analysis
with an empty Between time model to be able to
save data with subject and time variables.
Missing data on y is created by Model Missing
MONTECARLO: NAMES ARE y w z u;
NOBS = 20000;
NREPS = 1;
CSIZES = 200[100(1)];
NCSIZES = 1[1];
lagged = y(1);
between = (level2b) w z;
missing = y;
! u is needed if there are several y's to make all of them
! have missing at the same time
generate = u(1);
categorical = u;
within = u;
save = ex9.30step1.dat;
MODEL MISSING:
[y@-15]; ! no MCAR missing
y on u@30; ! missing 50% on y;
ANALYSIS: TYPE = CROSSCLASSIFIED RANDOM;
estimator=bayes;
proc=2;
fbiter=(200); ! full convergence not needed to save the right data
MODEL POPULATION:
%WITHIN%
s | y on y&1;
logv | y;
[u$1*0];
%BETWEEN level2a% ! empty
y@0; s@0;
%BETWEEN level2b%
w*1;
y on w*.3;
y*0.09;
s on w*.1;
s*.01; [s*.3];
logv on w*.3;
logv*0; [logv*0];
z on y*.5 s*.7 logv*.3;
z*0.05;
MODEL:
%WITHIN%
s | y on y&1;
logv | y;
[u$1*0];
%BETWEEN level2a% ! empty
y@0; s@0;
%BETWEEN level2b%
y on w*.3;
y*0.09;
s on w*.1;
s*.01; [s*.3];
logv on w*.3;
logv*0; [logv*0];
z on y*.5 s*.7 logv*.3;
z*0.05;
OUTPUT:
tech8;