Professional Documents
Culture Documents
GLM Uni Multivariate
GLM Uni Multivariate
GLM Uni Multivariate
GLM (general linear model) is a general procedure for analysis of variance and
covariance, as well as regression. It can be used for both univariate and multivariate
designs. Repeated measures analysis is also available. Algorithms that apply only to
repeated measures are in the chapter GLM Repeated Measures.
For information on post hoc tests, see Appendix 10. For sums of squares, see
Appendix 11. For distribution functions, see Appendix 12. For Box’s M test, see
Appendix 14.
Notation
The following notation is used throughout this chapter. Unless otherwise stated, all
vectors are column vectors and all quantities are known.
n Number of cases.
N Effective sample size.
p Number of parameters (including the constant, if it exists) in the model.
r Number of dependent variables in the model.
Y n × r matrix of dependent variables. The rows are the cases and the columns
are the dependent variables. The ith row is y ′i , i = 1, K, n .
X n × p design matrix. The rows are the cases and the columns are the
parameters. The ith row is x i′ , i = 1, K, n .
rX Number of nonredundant columns in the design matrix. Also the rank of the
design matrix.
w Regression weight of the ith case.
i
1
2 GLM Univariate and Multivariate
Model
The model is Y = XB and y i′ is independently distributed as a p-dimensional
normal distribution with mean x i′ B and covariance matrix wi−1Σ . The ith case is
ignored if wi ≤ 0 .
1
z i′ = x i′ , y i′ 6
0 5 0 5
Then the p + r × p + r matrix is computed:
∑
n
Z ′WZ = fi wi z i z i′ .
i =1
X′WX X ′WY
Z ′WZ =
Y′WX Y ′WY
The upper left p × p submatrix is X′WX and the lower right r × r submatrix is
Y′WY.
GLM Univariate and Multivariate 3
Sweep Operation
$ , and S, are obtained by sweeping the Z′WZ matrix
Three important matrices, G, B
as follows:
1. Sweep sequentially the first p rows and the first p columns of Z′WZ, starting
from the first row and the first column.
2. After the pth row and the pth column are swept, the resulting matrix is
−G B$
B$ ′ S
where G is a p × p symmetric g2 generalized inverse of X′WX, B $ is the p × r
matrix of parameter estimates and S is the r × r symmetric matrix of sums of
squares and cross products of residuals.
The SWEEP routine is adapted from Algorithm AS 178 by Clarke (1982) and
Remarks R78 by Ridout and Cobby (1989).
Parameter Estimates
Let the elements of Σ$ be σ$ ij , the elements of G, gij, and the elements of B $ , b$ .
ij
$ $ $ $
Then var(bij ) is estimated by σ jj gii for i = 1,K, p; j = 1,K, r and cov(bij , brs ) is
estimated by σ$ js gir for i, r = 1,K, p; j, s = 1, K, r .
4 9
se b$ij = σ$ jj gii
When the ith parameter is redundant, the standard error is system missing.
4 GLM Univariate and Multivariate
The t Statistic
3
The significance value for this statistic is 2 1 − CDF. T t , N − rx 1 68 where CDF.T is
the SPSS function for the cumulative t distribution.
Noncentrality Parameter
c= t
Observed Power
p=& rX ≥ N ,
KKSYSMIS
' or any arguments to NCDF. T
or IDF. T are SYSMIS
1 6
where tc = IDF.T 1 − α / 2, N − rX and α is the user-specified power level
0 5
0 < α < 1 . NCDF.T and IDF.T are the SPSS functions for the cumulative
noncentral t distribution and for the inverse cumulative t distribution, respectively.
The default value is α = 0.05 . The observed power should be within 0 ≤ p ≤ 1.
GLM Univariate and Multivariate 5
Confidence Interval
For the p% level, the individual univariate confidence interval for the parameter is
4 9
b$ij ± tα se b$ij
2 0 5
where tα = IDF.T 0.5 1 + p / 100 , N − rX 7 for i = 1,K, n; j = 1,K, r . The default
value of p is 95 ( 0 < p < 100 ).
Correlation
corr(b$ij , b$rs ) =
K%& 4 4 9 4 99
σ$ js gir se b$ij × se b$rs if the standard errors are positive
K'
SYSMIS otherwise
for i, r = 1,K, p; j, s = 1, K, r .
L Matrix
For each level combination of the between subjects factors in TABLES, identify
the nonmissing cases with positive caseweights and positive regression weights
which are associated with the current level combination. Suppose the cases are
classified by three between-subjects factors: A, B and C. Now A and B are
specified in TABLES and the current level combination is A=1 and B=2. A case in
the cell A=1, B=2, and C=3 is associated with the current level combination,
6 GLM Univariate and Multivariate
whereas a case in the cell A=1, B=3 and C=3 is not. Compute the average of the
design matrix rows corresponding to these cases.
If an effect contains a covariate, then its parameters which belong to the current
level combination are equal to the mean of the covariate, and are equal to 0
otherwise. Using the above example, for effect A*X where X is a covariate, the
parameter [A=1]*X belongs to the current level combination where the parameter
[A=2]*X does not. If the effect contains a product of covariates, then the mean of
the product is applied.
The result is the l vector for the current between-subjects factor level
combination. When none of the between-subjects effects contain covariates, the
vector always forms an estimable function. Otherwise, a non-estimable function
may occur, depending on the data.
M Matrix
The M matrix is formed as a series of Kronecker products
M = I c ⊗ A1 ⊗ L ⊗ A t
where
Standard Error
% 0l′Gl54m′Σ$ m9
4 $
se l ′Bm 9 K&KSYSMIS
= if N − rX > 0 (1)
' otherwise
Since l are coefficients of an estimable function, the standard error is the same for
any generalized inverse G.
GLM Univariate and Multivariate 7
Significance
The t statistic is
%Kl′Bm 4$ 9
$ se l ′Bm
4$
9
t= &KSYSMIS if se l ′Bm >0
' otherwise
If the t statistic is not system missing, then the significance is computed based on a
t distribution with N − rX degrees of freedom.
Pairwise Comparison
Between-Subjects Factor
Suppose the l vectors are indexed by the level of the between-subjects factor as
l i1,K,ib , is = 1,K, ns and s = 1, K, b where ns is the number of levels of between-
subjects factor s and b is the number of between-subjects factors specified inside
TABLES. The difference in estimated marginal means of level is and level is′ of
between-subjects factor s at fixed levels of other between-subjects factors is
′
4l K K
i1 , ,is −1 ,is ,is +1 , ,ib − li1,K,i K,i 9 Bm
s −1 ,is′ ,is +1 ,
$ for i , i ′ = 1,K, n ; i ≠ i ′ .
b s s s s s
Within-Subjects Factor
4 K K K K 9
l ′B m j1, , js −1, js , js +1, , jb − m j1, , js −1, js′ , js +1, , jb for js , js′ = 1,K, ns ; js ≠ js′ .
Confidence Interval
0 5
The 1 − α × 100% confidence interval is
$ ±t
l ′Bm 1−α 2;N − rX 4 9 $
× se l ′Bm
Saved Values
Temporary variables can be added to the working data file. These include predicted
values, residuals, and diagnostics.
Predicted Values
3 8
se y$ij = σ$ jj π ii for i = 1,K, n; j = 1,K, r
Residuals
$ = Y−Y
The n × r matrix of residuals is E $.
$ is e$ ′ = y ′ − y$ ′ , i = 1, K, n .
The ith row of E i i i
$ be e$ ; then
Let the elements of E ij
The deleted residual is the predicted residual for the ith case that results from
omitting the ith case from estimation. It is:
DRESID ij =
%&e$ 11 w − π 6
ij i ii if wi > 0 and wi π ii < 1;
'SYSMIS otherwise.
Standardized Residuals
The standardized residual is the residual divided by the standard deviation of data:
ZRESID ij =
K%&( y − y$ ) 4 σ$ jj wi 9 if wi > 0
K'SYSMIS
ij ij
otherwise
Studentized Residuals
se(e$ij ) =
%K& σ$ (1 w − π ii ) if wi > 0 and wiπ ii < 1;
K'SYSMIS
jj i
otherwise.
for i = 1,K, n; j = 1,K, r . The Studentized residual is the residual divided by the
standard error of the residual.
SRESID ij =
%&e$ij se(e$ij ) if wi > 0 and se(e$ij ) > 0
'SYSMIS otherwise
10 GLM Univariate and Multivariate
Diagnostics
Cook’s Distance
Cook’s Distance D measures the change to the solution that results from omitting
each observation. The formula is
2 π 1
=
e$ij
6 11 w − π 6 r
ii
1
Dij
σ$ jj 1 wi − π ii i ii X
3
Dij = e$ij se(e$ij ) 8 4se3 y$ 8 se3e$ 89 r
2
ij ij X 3 8
provided wi > 0 and se e$ij > 0 .
3 8
When wi ≤ 0 or se e$ij = 0 , Dij is system missing.
Leverage (Uncentered)
The leverage for the ith case ( i = 1, K, n ) for all dependent variables is
LEVER i =
%&wiπ ii if wi > 0
'SYSMIS otherwise
Hypothesis Testing
Let L be an l × p known matrix, M be an r × m known matrix and K be an l × m
known matrix. The test hypotheses H 0 :LBM = K versus H1 :LBM ≠ K are
testable if and only if LB is estimable.
The following results apply to testable hypotheses only. Nontestable hypotheses are
excluded.
$ − K )′ LGL ′
The hypothesis SSCP matrix is S H = (LBM 0 5 −1 $ − K) and the
(LBM
error SSCP matrix is S E = M ′SM .
GLM Univariate and Multivariate 11
Wilks’ Lambda
1 6 m
6 ∏ 11 + λ 6 .
det S E 1
Λ=
1
det S H + S E
=
k =1 k
1ςτ − 2υ 6 41 − Λ 9
τ 1
F=
lrE Λ1 τ
ς = ne − 12 rE − l + 1 1 6
υ= 1
4 1lr − 26
E
%K
τ = & 4l r − 49 4l
2 2 2
+ rE2 − 5 9 4 9
if l 2 + rE2 − 5 > 0
K' 1
E
otherwise
1 6
The degrees of freedom are lrE , ςτ − 2υ . The F statistic is exact if s = 1, 2 . See
Rao (1951) and Section 8c.5 of Rao (1973) for details.
The eta-squared statistic is η 2 = 1 − Λ1/ s .
Hotelling-Lawley Trace
In the SPSS software, the name Hotelling-Lawley trace is shortened to Hotelling’s
trace
4
T = trace S −E1S H = 9 ∑ m
k =1
λk
F=
4
2 sn∗ + 1
T 9
4
s 2m + s + 1 s∗
9
follows asymptotically an F distribution with degrees of freedom
4 s4 2 m *
9 4 99
+ s + 1 , 2 sn + 1 . The F statistic is exact if s = 1.
*
0 50 5
The eta-squared statistic is η 2 = T / s / T / s + 1 .
Pillai’s Trace
4 1
V = trace S H S H + S E 6 9=∑
−1 m
k =1
λk 1+ λk1 6
When Ho is true, the F statistic
42n + s + 19 V
∗
42m + s + 19 0s − V 5
F=
∗
GLM Univariate and Multivariate 13
4 9 4 9
The noncentrality parameter is λ = s 2n * + s + 1 η 2 / 1 − η 2 .
The power is 1 − NCDF. F4Fα , s42 m * + s + 19, s42n* + s + 19, λ 9 where Fα is the
upper 100α percentage point of the central F distribution and α is user-specified on
the ALPHA keyword on the CRITERIA subcommand.
Θ = λ1
1
F = Θ ne − ω + rH ω 6
1 6
where ω = max l, rE is an upper bound of F that yields a lower bound on the
1
significance level. The degrees of freedom are ω , ne − ω + rH . The F statistic is6
exact if s = 1.
The eta-squared statistic is η 2 = Θ / 1 + Θ . 0 5
1 6 4 9
The noncentrality parameter is λ = ne − ω + rH η 2 / 1 − η 2 .
S H ;i l
F=
1
S E;i n − rX 6 , i = 1,K, m
where SH;i and SE;i are the ith diagonal elements of the matrices SH and SE
respectively. Under the null hypothesis, the F statistic has an F distribution with
1
degrees of freedom l, n − rX . 6
3 8
The partial eta-squared statistic is η 2 = S H ;i / S H ;i + S E;i .
1 6
The noncentrality parameter is λ = n − rX S H ;i S E;i .
1 6
The power is 1 − NCDF. F Fα ,1, n − rX , λ where Fα is the upper 100α percentage
point of the central F distribution and α is user-specified on the ALPHA keyword on
the CRITERIA subcommand.
Hypotheses
In Bartlett’s test of sphericity the null hypothesis is Ho :Σ = σ 2 I r versus the
alternative hypothesis H1: Σ ≠ σ 2 I r where σ 2 > 0 is unspecified and I r is an r × r
identity matrix.
%K A n2
05
if trace A > 0
λ=&
K 1trace0A5 r6 nr 2
KKSYSMIS 05
if trace A ≤ 0
'
GLM Univariate and Multivariate 15
4 9 4
$ ′ W Y − XB
where A = Y − XB 9
$ is the r × r matrix of residual sums of squares
and cross products.
Chi-Square Approximation
Define W = λ2 n . When n is large and under the null hypothesis that for n − rX ≥ 1
and r ≥ 2 ,
2 1 6 7 4 9 4 4 9 4
Pr − ρ n − rX log W ≤ c = Pr χ 2f ≤ c + ω 2 Pr χ 2f + 4 ≤ c − Pr χ 2f ≤ c + O n −3 99 4 9
where
0 5
f = r r +1 2 −1
ρ = 1 − 42r + r + 29 26r1n − r 67
2
X
ω =
0r + 250r − 150r − 2542r + 6r
3 2
+ 3r + 2 9
288r 1n − r 6 ρ
2 2 2 2
X
Chi-Square Statistic
c=
%&− ρ1n − r 6 log W
X if W > 0
'SYSMIS otherwise
Degrees of Freedom
0 5
f = r r +1 2 −1
16 GLM Univariate and Multivariate
Significance
0 5 2 0 5
1 − CDF.CHISQ c, f − ω 2 CDF.CHISQ c, f + 4 − CDF.CHISQ c, f 0 57
where CDF.CHISQ is the SPSS function for the cumulative chi-square
distribution. The significance is reset to zero whenever the computed value is less
than zero due to floating point imprecision.
Notation
The following notation is used in this section:
Error Term
Mean Squares
If the error term is a linear combination of effects, the error mean square is
S
MSQ = ∑ q × MS s s
s =1
If the user supplied the mean squares, MSQ is equal to the number specified after
the keyword VS. If MSQ < 0 , the custom error term is invalid, and MSQ is equal
to the system-missing value and an error message is issued.
Degrees of Freedom
If MSQ ≥ 0 and the user did not supply the error degrees of freedom, then the error
degrees of freedom is approximated using the Satterthwaite (1946) method. Define
ds =
K%&1q MS 6 2
ls if ls > 0
K'0
s s
otherwise
S
Then D = ∑ d . The approximate error degrees of freedom is
s
s =1
%K3MS 8 D 2
lQ = &KSYSMIS
Q if D > 0
' otherwise
If MSQ ≥ 0 and the user supplied the error degrees of freedom, lQ is equal to the
number following the keyword DF. If lQ < 0 , the custom degrees of freedom is
invalid. In this case, lQ is equal to the system-missing value and an error message
is issued.
18 GLM Univariate and Multivariate
Hypothesis Test
F Statistic
The null hypothesis is that all parameters of the hypothesis effect are zero. The F
statistic is used for testing this null hypothesis. Suppose the mean square and the
degrees of freedom of the hypothesis effect are MS H and lH ; then the F statistic is
MS H%K
F = MSQ &K if MSQ > 0 & MS H ≥ 0
SYSMIS' otherwise
Significance Level
significance =
%&1 − CDF. F( F, lH , lQ ) if l H > 0, lQ > 0 & F ≠ SYSMIS
'SYSMIS otherwise
where CDF.F is the SPSS function for the F cumulative distribution function.
Notation
The following notation is used throughout this section. Unless otherwise stated, all
vectors are column vectors and all quantities are known.
Relationships between these symbols and those defined at the beginning of the
chapter are:
• p = p0 + p1 + L + pk
• X = X 0 | X1|K| X k
β "#
0
β #
M #
1
• B=
!β #$
k
Model
The mixed model is represented, following Rao (1973), as
k
Y = X 0β 0 + ∑X β + e
i i
i =1
cov0Y 5 = ∑ σ i2 X i X i′ + σ e2 W −1
k
i =1
20 GLM Univariate and Multivariate
1 6 1
E SSL = E Y ′W 2 A L W 2 Y
1
1
= β ′0 X ′0 W 2 A L W 2 X 0β 0 +
1
∑σ
k
2
i
1 1
trace X ′k W 2 A L W 2 X k + σ 2e trace A L 1 6
i =1
where
1
0
A L = W 2 XGL ′ LGL ′ 5 −1
LGX ′W 2
1
1 6
Since L = LGX ′WX , trace A L = s and X ′W 2 A L W 2 X = L ′ LGL ′
1 1
0 5 −1
L . The
1 1
matrix X ′W A L W X can therefore be computed in the following way:
2 2
C "#0
C=
C
#
M #
1
!C #$k
1 1
where Ci is a pi × s submatrix—then X ′k W 2 A L W 2 X k = Ci Ci′ , i = 0,1,K, k .
GLM Univariate and Multivariate 21
1 6
Since trace Ci Ci′ is equal to the sum of squares of the elements in Ci , denoted
1 6
by SSQ Ci , the matrices Ci Ci′ need not be formed. The preferred computational
formula for the expected sum of squares is
k
1 6
E SSL = β ′0 C0 C′0β 0 + ∑σ 2
i SSQ 1C 6 + sσ
i
2
e
i =1
k
1 6
E MSL =
1
s
1 6
1
E SSL = β ′0 C0 C′0β 0 +
s
1
s ∑σ 2
i SSQ 1C 6 + σ
i
2
e
i =1
For the residual term, the expected residual mean square is: E MSE = σ 2e . 0 5
1
Note: GLM does not compute the term β ′0 C0 C′0β 0 but reports the fixed effects
s
whose corresponding row block in C0 contains nonzero elements.
MSL
F=
05
MSE L
05 05
where MSE L is the mean square of the error term with s E L degrees of freedom.
If the effect being tested is a fixed effect, its expected mean square is
1 6
E MSL = σ e2 + c1σ 12 + L + ckσ 2k + Q L 05
22 GLM Univariate and Multivariate
05
where c1,K, ck are coefficients and Q L is a quadratic term involving the fixed
05
effects. Under the null hypothesis, it is assumed that Q L = 0 . Although the
quadratic term may involve effects that are unrelated to the effect being tested, such
effects are assumed to be zero in order to draw a correct inference for the effect
being tested. Therefore, under the null hypothesis, the expected mean square is
1 6
E MSL = σ e2 + c1σ 12 + L + ckσ 2k
0 5
If the effect being tested is a random effect, say the jth 1 ≤ j ≤ k random effect, its
expected mean square is
1 6
E MSL = σ e2 + c1σ 12 + L + ckσ 2k
1 6
E MSL = σ 2e + ∑c σ 2
i i
1≤i ≤ k ,i ≠ j
0 5
Let MSi be the mean square of the ith i = 1,K, k random effect. Let si be the
corresponding degrees of freedom. The error term is then found as a linear
combination of the expected mean squares of the random effects:
4
E MSE 0 L5 9 = q1E1 MS1 6 + L + qk E1 MSk 6 + qk +1E0 MSE 5 = σ 2e + c1σ 12 + L + ckσ 2k
0 5
If si = 0 1 ≤ i ≤ k then qi = 0 .
GLM Univariate and Multivariate 23
The error degrees of freedom is computed using the Satterthwaite (1946) method:
4MS 0 5 9
2
E L
05
sE L =
∑ 1q MS 6 i i
2
si
1≤i ≤ k ;si > 0
References
Belsley, D. A., Kuh, E., and Welsch R. E. 1980. Regression diagnostics. New
York: John Wiley & Sons, Inc.
Rao, C. R. 1973. Linear statistical inference and its applications, 2nd ed. New
York: John Wiley & Sons, Inc.
Searle, S. R., Speed, F. M., and Milliken, G. A. 1980. Population marginal means
in the linear model: an alternative to least squares means. The American
Statistician, 34: 216–221.