EFFECT name=LAG (variable / WITHIN=variable PERIOD=variable lag-options);
EFFECT name=LAG (variable / WITHIN=(var-list) PERIOD=variable lag-options);
A lag effect is a classification effect for the variable that is specified after the keyword LAG. A lag effect represents the effect of a previous value of the lagged variable when the observations of this variable are inherently ordered. A typical example where lag effects are useful is a study in which different subjects are given sequences of treatments and you want to investigate whether the treatment in the previous period is important in understanding the outcome in the current period. You can do this by including a lagged treatment effect in your model.
The precise definition of a lag effect depends on a subdivision of the data into disjoint subsets and an ordering into units of the observations within a subset. The subsets are often called subjects, and they are specified in the required WITHIN= option. The units are often called periods, and they are specified in the required PERIOD= option. For an observation that belongs to a particular subject at a particular period, the design matrix columns of the lagged variable are the usual design matrix columns of that variable except for the observation at the preceding period for that subject. Observations at the initial period do not have a preceding value, and so the design matrix columns of the lag effect for these observations are set to 0. You can also define lag effects where the number of periods that are lagged is greater than 1. If the number of periods that are lagged is n, then the design matrix columns of observations in periods less than or equal to n are set to 0. The design matrix columns that correspond to a subject at period p, where p > n, are the usual design matrix columns of the lagged variable for that subject at period p – n.
In a valid lag design there is at most one observation for a particular period and subject. For example, the following set of treatments by subject and period form a valid lag design:
Subject |
Period |
Treatment |
---|---|---|
Sheila |
1 |
B |
Joey |
1 |
A |
Athena |
1 |
A |
Gelindo |
1 |
A |
Sheila |
2 |
C |
Joey |
2 |
A |
Athena |
2 |
. |
Gelindo |
2 |
B |
Sheila |
3 |
B |
Joey |
3 |
C |
Athena |
3 |
A |
Gelindo |
3 |
B |
A convenient way to represent the organization of observations into subjects and periods is to form the lag design matrix. The rows and columns of this matrix correspond to the subjects and periods, respectively. The lag design matrix entry is the treatment for the corresponding subject and period.
The associated lag design matrix is
Period |
|||
---|---|---|---|
Subject |
1 |
2 |
3 |
Athena |
A |
A |
|
Gelindo |
A |
B |
B |
Joey |
A |
A |
C |
Sheila |
B |
C |
B |
Note that the subject Athena did not receive a treatment at period 2, and so the corresponding entry in the lag design matrix is missing. The following statements define a lag effect for this lag design:
CLASS treatment; EFFECT Lag = LAG( treatment / WITHIN=subject PERIOD=period);
When GLM coding is used for the variable treatment
, the design matrix columns Lag_A
, Lag_B
, and Lag_C
for the constructed effect Lag
are as follows:
Subject |
Period |
Treatment |
Lag_A |
Lag_B |
Lag_C |
---|---|---|---|---|---|
Athena |
1 |
A |
0 |
0 |
0 |
Athena |
2 |
1 |
0 |
0 |
|
Athena |
3 |
A |
. |
. |
. |
Gelindo |
1 |
A |
0 |
0 |
0 |
Gelindo |
2 |
B |
1 |
0 |
0 |
Gelindo |
3 |
B |
0 |
1 |
0 |
Joey |
1 |
A |
0 |
0 |
0 |
Joey |
2 |
A |
1 |
0 |
0 |
Joey |
3 |
C |
1 |
0 |
0 |
Sheila |
1 |
B |
0 |
0 |
0 |
Sheila |
2 |
C |
0 |
1 |
0 |
Sheila |
3 |
B |
0 |
0 |
1 |
The design matrix columns for each subject at period 1 are all 0 because there are no lagged observations for period 1. You can also see that the design matrix columns at period 3 for subject Athena are missing because Athena did not receive a treatment at period 2. Nevertheless, the design matrix columns for Athena at period 2 are nonmissing and correspond to the treatment "A" that she received in period 1.
You must specify the following required options:
You can also specify the following optional lag-options: