The GLIMMIX Procedure

Example 46.9 Testing Equality of Covariance and Correlation Matrices

(View the complete code for this example.)

Fisher’s iris data are widely used in multivariate statistics. They comprise measurements in millimeters of four flower attributes, the length and width of sepals and petals for 50 specimens from each of three species, Iris setosa, I. versicolor, and I. virginica (Fisher 1936).

When modeling multiple attributes from the same specimen, correlations among measurements from the same flower must be taken into account. Unstructured covariance matrices are common in this multivariate setting. Species comparisons can focus on comparisons of mean response, but comparisons of the variation and covariation are also of interest. In this example, the equivalence of covariance and correlation matrices among the species are examined.

The iris data set is available in the Sashelp library. The following step displays the first 10 observations of the iris data in multivariate format—that is, each observation contains multiple response variables. The DATA step that follows creates a data set in univariate form, where each observation corresponds to a single response variable. This is the form needed by the GLIMMIX procedure.

proc print data=Sashelp.iris(obs=10);
run;

Output 46.9.1: Fisher (1936) Iris Data

ObsSpeciesSepalLengthSepalWidthPetalLengthPetalWidth
1Setosa5033142
2Setosa4634143
3Setosa4636102
4Setosa5133175
5Setosa5535132
6Setosa4831162
7Setosa5234142
8Setosa4936141
9Setosa4432132
10Setosa5035166


data iris_univ;
   set sashelp.iris;
   retain id 0;
   array y (4) SepalLength SepalWidth PetalLength PetalWidth;
   id+1;
   do var=1 to 4;
      response = y{var};
      output;
   end;
   drop SepalLength SepalWidth PetalLength PetalWidth:;
run;

The following GLIMMIX statements fit a model with separate unstructured covariance matrices for each species:

ods select FitStatistics CovParms CovTests;
proc glimmix data=iris_univ;
   class species var id;
   model response = species*var;
   random _residual_ / type=un group=species subject=id;
   covtest homogeneity;
run;

The mean function is modeled as a cell-means model that allows for different means for each species and outcome variable. The covariances are modeled directly (R-side) rather than through random effects. The ID variable identifies the individual plant, so that responses from different plants are independent. The GROUP=SPECIES option varies the parameters of the unstructured covariance matrix by species. Hence, this model has 30 covariance parameters: 10 unique parameters for a covariance matrix for each of three species.

The COVTEST statement requests a test of homogeneity—that is, it tests whether varying the covariance parameters by the group effect provides a significantly better fit compared to a model in which different groups share the same parameter.

Output 46.9.2: Fit Statistics for Analysis of Fisher’s Iris Data

The GLIMMIX Procedure

Fit Statistics
-2 Res Log Likelihood2812.89
AIC (smaller is better)2872.89
AICC (smaller is better)2876.23
BIC (smaller is better)2963.21
CAIC (smaller is better)2993.21
HQIC (smaller is better)2909.58
Generalized Chi-Square588.00
Gener. Chi-Square / DF1.00


The "Fit Statistics" table shows the –2 restricted (residual) log likelihood in the full model and other fit statistics (Output 46.9.2). The "-2 Res Log Likelihood" sets the benchmark against which a model with homogeneity constraint is compared. Output 46.9.3 displays the 30 covariance parameters in this model.

There appear to be substantial differences among the covariance parameters from different groups. For example, the residual variability of the petal length of the three species is 12.4249, 26.6433, and 40.4343, respectively. The homogeneity hypothesis restricts these variances to be equal and similarly for the other covariance parameters. The results from the COVTEST statement are shown in Output 46.9.4.

Output 46.9.3: Covariance Parameters Varied by Species (TYPE=UN)

Covariance Parameter Estimates
Cov ParmSubjectGroupEstimateStandard
Error
UN(1,1)idSpecies Setosa12.42492.5102
UN(2,1)idSpecies Setosa9.92162.3775
UN(2,2)idSpecies Setosa14.36902.9030
UN(3,1)idSpecies Setosa1.63550.9052
UN(3,2)idSpecies Setosa1.16980.9552
UN(3,3)idSpecies Setosa3.01590.6093
UN(4,1)idSpecies Setosa1.03310.5508
UN(4,2)idSpecies Setosa0.92980.5859
UN(4,3)idSpecies Setosa0.60690.2755
UN(4,4)idSpecies Setosa1.11060.2244
UN(1,1)idSpecies Versicolor26.64335.3828
UN(2,1)idSpecies Versicolor8.51842.6144
UN(2,2)idSpecies Versicolor9.84691.9894
UN(3,1)idSpecies Versicolor18.28984.3398
UN(3,2)idSpecies Versicolor8.26532.4149
UN(3,3)idSpecies Versicolor22.08164.4612
UN(4,1)idSpecies Versicolor5.57801.6617
UN(4,2)idSpecies Versicolor4.12041.0641
UN(4,3)idSpecies Versicolor7.31021.6891
UN(4,4)idSpecies Versicolor3.91060.7901
UN(1,1)idSpecies Virginica40.43438.1690
UN(2,1)idSpecies Virginica9.37633.2213
UN(2,2)idSpecies Virginica10.40042.1012
UN(3,1)idSpecies Virginica30.32906.6262
UN(3,2)idSpecies Virginica7.13802.7395
UN(3,3)idSpecies Virginica30.45886.1536
UN(4,1)idSpecies Virginica4.90942.5916
UN(4,2)idSpecies Virginica4.76291.4367
UN(4,3)idSpecies Virginica4.88242.2750
UN(4,4)idSpecies Virginica7.54331.5240


Output 46.9.4: Likelihood Ratio Test of Homogeneity

Tests of Covariance Parameters
Based on the Restricted Likelihood
LabelDF-2 Res Log LikeChiSqPr > ChiSqNote
Homogeneity202959.55146.66<.0001DF

DF: P-value based on a chi-square with DF degrees of freedom.



Denote as the covariance matrix for species with elements . In processing the COVTEST hypothesis , the GLIMMIX procedure fits a model that satisfies the constraints

where is the covariance between the ith and jth variable for the kth species. The –2 restricted log likelihood of this restricted model is 2959.55 (Output 46.9.4). The change of 146.66 compared to the full model is highly significant. There is sufficient evidence to reject the notion of equal covariance matrices among the three iris species.

Equality of covariance matrices implies equality of correlation matrices, but the reverse is not true. Fewer constraints are needed to equate correlations because the diagonal entries of the covariance matrices are free to vary. In order to test the equality of the correlation matrices among the three species, you can parameterize the unstructured covariance matrix in terms of the correlations and use a COVTEST statement with general contrasts, as shown in the following statements:

ods select FitStatistics CovParms CovTests;
proc glimmix data=iris_univ;
   class species var id;
   model response = species*var;
   random _residual_ / type=unr group=species subject=id;
   covtest 'Equal Covariance Matrices'  homogeneity;
   covtest 'Equal Correlation Matrices' general
        0  0  0  0  1  0  0  0  0  0
        0  0  0  0 -1  0  0  0  0  0,
        0  0  0  0  1  0  0  0  0  0
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0 -1  0  0  0  0  0,
        0  0  0  0  0  1  0  0  0  0
        0  0  0  0  0 -1  0  0  0  0,
        0  0  0  0  0  1  0  0  0  0
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0  0 -1  0  0  0  0,
        0  0  0  0  0  0  1  0  0  0
        0  0  0  0  0  0 -1  0  0  0,
        0  0  0  0  0  0  1  0  0  0
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0  0  0 -1  0  0  0,
        0  0  0  0  0  0  0  1  0  0
        0  0  0  0  0  0  0 -1  0  0,
        0  0  0  0  0  0  0  1  0  0
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0  0  0  0 -1  0  0,
        0  0  0  0  0  0  0  0  1  0
        0  0  0  0  0  0  0  0 -1  0,
        0  0  0  0  0  0  0  0  1  0
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0  0  0  0  0  -1 0,
        0  0  0  0  0  0  0  0  0  1
        0  0  0  0  0  0  0  0  0 -1,
        0  0  0  0  0  0  0  0  0  1
        0  0  0  0  0  0  0  0  0  0
        0  0  0  0  0  0  0  0  0 -1 / estimates;
run;

The TYPE=UNR structure is a reparameterization of TYPE=UN. The models provide the same fit, as seen by comparison of the "Fit Statistics" tables in Output 46.9.2 and Output 46.9.5. The covariance parameters are ordered differently, however. In each group, the four variances precede the six correlations (Output 46.9.5). The first COVTEST statement tests the homogeneity hypothesis in terms of the UNR parameterization, and the result is identical to the test in Output 46.9.4. The second COVTEST statement restricts the correlations to be equal across groups. If is the correlation between the ith and jth variable for the kth species, the 12 restrictions are

The ESTIMATES option in the COVTEST statement requests that the GLIMMIX procedure display the covariance parameter estimates in the restricted model (Output 46.9.5).

Output 46.9.5: Fit Statistics, Covariance Parameters (TYPE=UNR), and Likelihood Ratio Tests for Equality of Covariance and Correlation Matrices

The GLIMMIX Procedure

Fit Statistics
-2 Res Log Likelihood2812.89
AIC (smaller is better)2872.89
AICC (smaller is better)2876.23
BIC (smaller is better)2963.21
CAIC (smaller is better)2993.21
HQIC (smaller is better)2909.58
Generalized Chi-Square588.00
Gener. Chi-Square / DF1.00

Covariance Parameter Estimates
Cov ParmSubjectGroupEstimateStandard
Error
Var(1)idSpecies Setosa12.42492.5102
Var(2)idSpecies Setosa14.36902.9030
Var(3)idSpecies Setosa3.01590.6093
Var(4)idSpecies Setosa1.11060.2244
Corr(2,1)idSpecies Setosa0.74250.06409
Corr(3,1)idSpecies Setosa0.26720.1327
Corr(3,2)idSpecies Setosa0.17770.1383
Corr(4,1)idSpecies Setosa0.27810.1318
Corr(4,2)idSpecies Setosa0.23280.1351
Corr(4,3)idSpecies Setosa0.33160.1271
Var(1)idSpecies Versicolor26.64335.3828
Var(2)idSpecies Versicolor9.84691.9894
Var(3)idSpecies Versicolor22.08164.4612
Var(4)idSpecies Versicolor3.91060.7901
Corr(2,1)idSpecies Versicolor0.52590.1033
Corr(3,1)idSpecies Versicolor0.75400.06163
Corr(3,2)idSpecies Versicolor0.56050.09797
Corr(4,1)idSpecies Versicolor0.54650.1002
Corr(4,2)idSpecies Versicolor0.66400.07987
Corr(4,3)idSpecies Versicolor0.78670.05445
Var(1)idSpecies Virginica40.43438.1690
Var(2)idSpecies Virginica10.40042.1012
Var(3)idSpecies Virginica30.45886.1536
Var(4)idSpecies Virginica7.54331.5240
Corr(2,1)idSpecies Virginica0.45720.1130
Corr(3,1)idSpecies Virginica0.86420.03616
Corr(3,2)idSpecies Virginica0.40100.1199
Corr(4,1)idSpecies Virginica0.28110.1316
Corr(4,2)idSpecies Virginica0.53770.1015
Corr(4,3)idSpecies Virginica0.32210.1280

Tests of Covariance Parameters
Based on the Restricted Likelihood
LabelDF-2 Res Log LikeChiSqPr > ChiSqEstimates H0Note
Est1Est2Est3Est4Est5Est6Est7Est8Est9Est10Est11Est12Est13Est14Est15Est16Est17Est18Est19Est20Est21Est22Est23Est24Est25Est26Est27Est28Est29Est30
Equal Covariance Matrices202959.55146.66<.000126.500411.539518.51794.18830.53020.75620.37790.36450.47050.484526.500411.539518.51794.18830.53020.75620.37790.36450.47050.484526.500411.539518.51794.18830.53020.75620.37790.36450.47050.4845DF
Equal Correlation Matrices122876.3863.49<.000116.471514.86564.84271.43920.56120.68270.40160.38440.49760.521924.40209.156617.44343.00210.56120.68270.40160.38440.49760.521935.054410.835027.35938.13950.56120.68270.40160.38440.49760.5219DF

DF: P-value based on a chi-square with DF degrees of freedom.



The result of the homogeneity test is identical to that in Output 46.9.4. The hypothesis of equality of the correlation matrices is also rejected with a chi-square value of 63.49 and a p-value of . Notice, however, that the chi-square statistic is smaller than in the test of homogeneity due to the smaller number of restrictions imposed on the full model. The estimate of the common correlation matrix in the restricted model is