How can I test differences in means using a cell means model in SPSS?

How can I test differences in means using a cell means model in SPSS?

The cell means model in SPSS is a statistical method used to analyze and compare the means of different groups or categories within a data set. To test for differences in means using this model, one can follow these steps:
1. Input the data into SPSS and organize it into separate columns for each group.
2. Go to the “Analyze” tab and select “General Linear Model” followed by “Univariate.”
3. In the “Dependent Variable” box, enter the variable for which you want to compare the means.
4. In the “Fixed Factors” box, enter the grouping variable that represents the different categories.
5. Click on the “Model” button and select “Custom” from the drop-down menu.
6. In the “Custom Model” window, select “Cell Means Model” and click “Continue.”
7. Finally, click on “OK” to run the analysis and view the results, which will include the mean values for each group and any significant differences between them. This method is useful for comparing means when there are multiple groups or factors involved and can provide valuable insights into the differences between them.

How can I test differences in means using a cell means model? | SPSS FAQ

Suppose we have an ANOVA model, and we would like to compare means between one group and
another group.  This is commonly done with the lmatrix subcommand in
SPSS. 
Let’s look at a simple example using a data set called https://stats.idre.ucla.edu/wp-content/uploads/2016/02/elemapi2.sav
. The dependent variable is the school’s API index (a continuous variable).  The variables mealcat and collcat
are categorical variables, both with three levels.  These will be used as
the predictor variables.  This model is shown below.  We have included
the emmeans subcommand to get the expected means for each group. 
This can be helpful if you want to calculate the contrast estimate by hand.

glm api00 by collcat mealcat
/design = collcat mealcat collcat*mealcat
/emmeans = tables (collcat*mealcat).

Image

Let’s say that we want to look at a simple comparison of group 1
versus 2 and above of collcat when mealcat = 1.  One way of doing this
using the glm command with lmatrix subcommand.  We use the
test(lmatrix)

option on the print subcommand to have SPSS print out the contrast
coefficients that are applied to each group. 

glm api00 by collcat mealcat 
/design = collcat mealcat collcat*mealcat
/print = test(lmatrix)
/lmatrix 'collcat 1 vs 2+ within mealcat = 1'
              collcat 1 -.5 -.5
              collcat*mealcat 1   0   0
		             -.5  0   0
		             -.5  0   0.

While this lmatrix subcommand will run the analysis we want, it is a
little difficult to write.  Another way of accomplishing the same thing is to use a cell means model.  A cell means model estimates only
one parameter for each cell and sets the intercept to 0.  In general, the cell means model is
not used to produce an overall test of model fit, but it is often used
to write simpler lmatrix subcommands.  So, in practice, we need to
write the glm code twice, once for the model fit and the second time for the
estimates.  In the code shown below, the first glm command is
for model fit and the second one with the lmatrix subcommand is used to estimate
the simple comparison. 

In the second call to glm, which is a cell means model, the main effects
are omitted; only the interaction is included in the model.  We use the
exclude
option on the
intercept subcommand
to specify that we are not going to estimate the intercept; therefore, we will
estimate one parameter per cell.  We use the test(lmatrix) option on
the print subcommand to show us the
contrast codes that were used.  This is a useful way to be sure that the
contrast codings were assigned as you intended.

* estimating the overall model.
glm api00 by collcat mealcat
/design = collcat mealcat collcat*mealcat.
* estimating the cell means model to get the desired estimate.
glm api00 by collcat mealcat 
/design = collcat mealcat collcat*mealcat
/print = test(lmatrix)
/lmatrix 'collcat 1 vs 2+ within mealcat = 1'
              collcat 1 -.5 -.5
              collcat*mealcat 1   0   0
		             -.5  0   0
		             -.5  0   0.

Notice that the order of categorical variables on the lmatrix
subcommand decides which variable is the row variable and which is the
column variable.  For example, in the code above, collcat will be the row
variable and mealcat will be the column variable.  Therefore, the simple
comparison we are interested in can be formulated as shown in the following table.  Writing
the numbers in the table one row at a time, we can write our lmatrix
subcommand
as:

 lmatrix 'simple comparison'
              collcat*mealcat 1 0 0 -.5 0 0 -.5 0 0
collcat /mealcatmealcat = 1mealcat = 2mealcat = 3
collcat = 1100
collcat =2-.500
collcat = 3-.500

If we switch the order of variables on the lmatrix subcommand, we will have to rewrite our
terms accordingly.  For example, we can rewrite the above lmatrix
subcommand as the
following; it produces exactly the same result from the lmatrix
subcommand, since the corresponding table is simply being transposed.
 

mealcat
/collcat
collcat = 1collcat =2collcat=3
mealcat = 11-.5-.5
mealcat = 2000
mealcat = 3000

Let’s run the analysis model.  Notice that both collcat and the
collcat*mealcat interaction need to be specified on the lmatrix
subcommand.

glm api00 by collcat mealcat 
/design = collcat mealcat collcat*mealcat
/print = test(lmatrix)
/lmatrix 'collcat 1 vs 2+ within mealcat = 1'
              collcat 1 -.5 -.5
              collcat*mealcat 1   0   0
		             -.5  0   0
		             -.5  0   0.
< some output omitted >

ImageImage

This simple comparison is not statistically significant (t = 0.96, p = 0.3367).

Now let’s run the cell means model.  Notice that only the interaction term
is used on the design and the lmatrix subcommands.

glm api00 by collcat mealcat
/design = collcat*mealcat
/intercept = exclude
/print = test(lmatrix)
/lmatrix = 'collcat 1 vs 2+ within mealcat = 1'
               collcat*mealcat 1 0 0 -.5 0 0 -.5 0 0.
< some output omitted >

ImageImage

Brief
summary

Example 2

In our second example, we will compare the means between two cells in the
design.  Specifically, we will compare collcat=2 at mealcat=1 to collcat=3
at mealcat=2. 

collcat /mealcatmealcat = 1mealcat = 2mealcat = 3
collcat = 1000
collcat =2100
collcat = 30-10

The lmatrix subcommand for this comparison is shown below.

glm api00 by collcat mealcat 
/design = collcat mealcat collcat*mealcat
/print = test(lmatrix)
/lmatrix = 'collcat 2/mealcat 1 vs. collcat 3/mealcat 2'
              collcat 0 1 -1
			  mealcat 1 -1 0
              collcat*mealcat 0 0 0
		             1   0  0
		             0  -1  0.
< some output omitted >

ImageImage

This comparison is statistically significant (t = 12.79, p < .0001).

Using the cell means model, the lmatrix subcommand is constructed as
shown below.

glm api00 by collcat mealcat 
/design = collcat*mealcat
/intercept = exclude
/print = test(lmatrix)
/lmatrix = 'collcat 2/mealcat 1 vs. collcat 3/mealcat 2'
collcat*mealcat 0 0 0 1 0 0 0 -1 0.
< some output omitted >

ImageImage

Example 3

In our last example, we will look at a difference in differences.  We
will take the difference between the difference of ([collcat=1 and mealcat=1]
and [collcat=1 and mealcat=3]) and ([collcat=3 and mealcat=1] and [collcat=3 and
mealcat=3]).

Remember that a little bit of math needs to be done to get the correct signs
of the contrast coefficients:  (collcat=1/mealcat=1 – collcat=1/mealcat=3)
– (collcat=3/mealcat=1 – collcat=3/mealcat=3) = collcat=1/mealcat=1 – collcat=1/mealcat=3
– collcat=3/mealcat=1 + collcat=3/mealcat=3.

collcat /mealcatmealcat = 1mealcat = 2mealcat = 3
collcat = 110-1
collcat =2000
collcat = 3-101
glm api00 by collcat mealcat 
/design = collcat mealcat collcat*mealcat
/print = test(lmatrix)
/lmatrix = 'differences in differences'
               collcat*mealcat 1 0 -1
		              0 0 0
		             -1 0 1.
< some output omitted >

ImageImage

The comparison is statistically significant (t = 3.38, p = .0008).

Here is the lmatrix subcommand using the cell means model.

glm api00 by collcat mealcat 
/design = collcat*mealcat
/intercept = exclude
/print = test(lmatrix)
/lmatrix = 'differences in differences'
               collcat*mealcat 1 0 -1 0 0 0 -1 0 1.
< some output omitted >

ImageImage

Cite this article

stats writer (2024). How can I test differences in means using a cell means model in SPSS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-test-differences-in-means-using-a-cell-means-model-in-spss/

stats writer. "How can I test differences in means using a cell means model in SPSS?." PSYCHOLOGICAL SCALES, 30 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-test-differences-in-means-using-a-cell-means-model-in-spss/.

stats writer. "How can I test differences in means using a cell means model in SPSS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-test-differences-in-means-using-a-cell-means-model-in-spss/.

stats writer (2024) 'How can I test differences in means using a cell means model in SPSS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-test-differences-in-means-using-a-cell-means-model-in-spss/.

[1] stats writer, "How can I test differences in means using a cell means model in SPSS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I test differences in means using a cell means model in SPSS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top