Consider the data in Table 32.2 (Stokes, Davis, and Koch, 2000).
Table 32.2: Colds in Children
Periods with Colds |
|||||
---|---|---|---|---|---|
Sex |
Residence |
0 |
1 |
2 |
Total |
Female |
Rural |
45 |
64 |
71 |
180 |
Female |
Urban |
80 |
104 |
116 |
300 |
Male |
Rural |
84 |
124 |
82 |
290 |
Male |
Urban |
106 |
117 |
87 |
310 |
For male and female children in rural and urban counties, the number of periods (of two) in which subjects report cold symptoms are recorded. So 45 subjects who are female and in rural counties report no cold symptoms, and 71 subjects who are female and from rural counties report colds in both periods.
The question of interest is whether the mean number of periods with colds reported is associated with gender or type of county. There is no reason to believe that the mean number of periods with colds is normally distributed, so a weighted least squares analysis of these data is performed with PROC CATMOD instead of an analysis of variance with PROC ANOVA or PROC GLM.
The input data for categorical data are often recorded in frequency form, with the counts for each particular profile being
the input values. For the colds data, the input SAS data set colds
is created with the following statements. The variable count
contains the frequency of observations that have the particular profile described by the values of the other variables in
that input line.
data colds; input sex $ residence $ periods count @@; datalines; female rural 0 45 female rural 1 64 female rural 2 71 female urban 0 80 female urban 1 104 female urban 2 116 male rural 0 84 male rural 1 124 male rural 2 82 male urban 0 106 male urban 1 117 male urban 2 87 ;
In order to fit a model to the mean number of periods with colds, you have to specify the response function in PROC CATMOD. The default response function is the logit if the response variable has two values, and it is generalized logits if the response variable has more than two values. If you want a different response function, then you specify that function in the RESPONSE statement. To request the mean number of periods with colds, you specify the MEANS option in the RESPONSE statement.
You can request a model consisting of the main effects and interaction of the variables sex
and residence
just as you would in the GLM procedure. Unlike the GLM procedure, PROC CATMOD does not require you to use a CLASS statement
to treat a variable as a classification variable. In the CATMOD procedure, all variables in the MODEL statement are treated
as classification variables unless you specify otherwise with a DIRECT
statement. To verify that your model is specified correctly, you can specify the DESIGN
option in the MODEL statement to display the design matrix.
The PROC CATMOD statements needed to model mean periods of colds with a main-effects and interaction model are as follows:
proc catmod data=colds; weight count; response means; model periods = sex residence sex*residence / design; run;
The results of this analysis are shown in Figure 32.1 through Figure 32.3.
In Figure 32.1, the CATMOD procedure first displays a summary of the contingency table you are analyzing. The "Population Profiles" table lists the values of the explanatory variables that define each population, or row of the underlying contingency table, and labels each group with a sample number. The number of observations in each population is also displayed. The "Response Profiles" table lists the variable levels that define the response, or columns of the underlying contingency table.
The "Response Functions and Design Matrix" table in Figure 32.2 contains the observed response functions—in this case, the mean number of periods with colds for each of the populations—and
the design matrix. The first column of the design matrix contains the coefficients for the intercept parameter. The second
column contains the coefficients for the sex
parameter. (Note that the sum-to-zero constraint of the default full-rank parameterization PARAM=EFFECT
implies that the coefficient for males is the negative of that for females; the parameter is called the differential effect for females.) The third column is similarly set up for residence
, and the last column is for the interaction.
The model-fitting results are displayed in the "Analysis of Variance" table (Figure 32.3), which is similar to an ANOVA table. The effects from the right side of the MODEL statement are listed in the Source column.
You can see in Figure 32.3 that the interaction effect is nonsignificant, so the data are reanalyzed using a main-effects model. Since PROC CATMOD is an interactive procedure, you can analyze the main-effects model by simply submitting the new MODEL statement as follows. The resulting tables are displayed in Figure 32.4 and Figure 32.5.
model periods = sex residence / design; run;
From the ANOVA table in Figure 32.4, you can see that the goodness-of-fit chi-square statistic is 0.09 with one degree of freedom and a p-value of 0.7594; hence, the model fits the data. Note that the chi-square tests in Figure 32.4 check whether all the parameters for a given effect are zero. In this model, each effect has only one parameter and therefore only one degree of freedom.
The "Analysis of Weighted Least Squares Estimates" table in Figure 32.5 lists the parameters and their estimates for the model, as well as the standard errors, Wald statistics, and p-values. These chi-square tests are one-degree-of-freedom tests that the individual parameter is equal to zero. They are equal to the tests shown in Figure 32.4 since each effect is composed of exactly one parameter.
You can compute the mean number of periods with colds for the first population (Sample 1, females in rural residences) from Table 32.2 as follows:
This is the same value reported in the Response Function column for Sample 1 in the "Response Functions and Design Matrix" table displayed in Figure 32.4.
PROC CATMOD is fitting a model to the mean number of colds in each population as follows:
where the design matrix is the same one displayed in Figure 32.4, is the mean number of colds averaged over all the populations, is the differential effect for females, and is the differential effect for rural residences. The parameter estimates are shown in Figure 32.5; the expected number of periods with colds for rural females from this model is computed as
and the expected number for rural males from this model is
Notice also, in Figure 32.5, that the differential effect for residence is nonsignificant (p = 0.3839). If you continue the analysis by fitting a single-effect model (sex
), you need to include a POPULATION
statement to maintain the same underlying contingency table:
population sex residence; model periods = sex; run;