### SPSS FAQ How can I perform hypothesis tests in glm?

Sometimes you may want to test hypotheses about the parameters after a linear regression analysis. On this page, we show a couple of examples of how to perform these hypothesis tests using the lmatrix and kmatrix subcommands in the glm procedure. These examples will use data set hsb2.sav. Let's say that we have run a linear regression model as follows.

  glm write with female read math
/print=parameter
/design=female read math.

Written as a regression equation, we have the following:

write = b_0 + b_1* female + b_2*read + b_3*math, where b_0 = 11.896, b_1 = 5.443, b_2 = .325 and b_3 = .397.

#### Example 1

Let's say that we want to test if the coefficient for read is equal to the coefficient for math. The lmatrix subcommand allows us to specify our hypothesis test in terms of the linear combination of the regression coefficients. In our case, our null hypothesis is that b_2 = b_3, or equivalently, b_2-b_3 = 0. This leads to our lmatrix subcommand with 1 following the variable read and -1 following the variable math.

glm write with female read math
/print=parameter
/lmatrix = 'math = read' read 1 math -1.

In the output, we see the difference between the two parameters is -.072 = (.325  -  .397), as we expected. What the output also gives is the standard error for the difference and the confidence interval. The Test Results table shows the F-value and the p-value.

#### Example 2

Let's say that we want to test if the coefficient for female is equal to 4.2.  In order to do this, we need to use the kmatrix subcommand, because we are testing if the value is something other than 0.  You might want to do this, if, for example, you had regression coefficients from a previous model and you wanted to see if they were equal to the coefficients obtained with your current model.  To keep the example simple, we will test only one variable (female) in this example.

glm write with female read math
/print=parameter
/lmatrix = 'female' female 1
/kmatrix  4.2.

#### Example 3

Let's say that we want to test if the coefficient for female is equal to 4.2 and that the coefficient for read is equal to the coefficient for math. This will be a two degree-of-freedom test since there are two hypotheses that we want to test simultaneously.  Notice that the values specified on the kmatrix subcommand are listed in the same order as the tests listed on the lmatrix subcommand.

glm write with female read math
/print=parameter
/kmatrix  4.2; 0.