Solved – Defining a contrast matrix to test the null hypothesis $H_0: \beta_5=\beta_6=0$

contrastshypothesis testinglogisticregression

In the book Applied Longitudinal Analysis, 2nd Edition there is an example in the chapter "Marginal Models: Generalized Estimating Equations (GEE)" in "Muscatine Coronary Risk Factor Study" sub-section. I am illustrating it below :

Let $Y_{ij}=1$ if the $i^{\text{th}}$ child is classified as obese at the $j^{\text{th}}$ occasion, and $Y_{ij}=0$ otherwise.

The marginal probability of obesity at each occasion follows the logistic model

$$log\frac{\Pr(Y_{ij}=1)}{\Pr(Y_{ij}=0)}= \beta_1+\beta_2\text{gender}_i+\beta_3\text{age}_{ij}+\beta_4\text{age}_{ij}^2+\beta_5\text{gender}_i\times\text{age}_{ij}+\beta_6\text{gender}_i\times\text{age}_{ij}^2.$$

If one construct the hypothesis that changes in the log odds of obesity are the same for boys and girls, then $H_0:\beta_5=\beta_6=0$.

To test the hypothesis $$H_0:\beta_5=\beta_6=0$$
$$\Rightarrow\mathbf L\mathbf\beta = 0,$$

where $\mathbf\beta =
\begin{pmatrix}
\beta_1
&\beta_2
&\beta_3
& \beta_4
&\beta_5
& \beta_6\\
\end{pmatrix}'
$ and $\mathbf L$ is the contrast matrix.

But I can't write the contrast matrix for the $H_0:\beta_5=\beta_6=0$.

Because if the $H_0$ were $H_0:\beta_5=\beta_6$ (notice that there ISN'T equal to $0$ at the most right ), then I can construct the contrast matrix easily as :
$\mathbf L =
\begin{pmatrix}
0& 0&0& 0&1& -1\\
\end{pmatrix}$ so that

$$\mathbf L\mathbf\beta = 0$$
$$\Rightarrow \begin{pmatrix}
0& 0&0& 0&1& -1\\
\end{pmatrix}\begin{pmatrix}
\beta_1\\
\beta_2\\
\beta_3\\
\beta_4\\
\beta_5\\
\beta_6\\
\end{pmatrix}=0$$

$$\Rightarrow \beta_5=\beta_6.$$

But When the $H_0$ is $H_0:\beta_5=\beta_6 = 0$ (notice that there IS equal to $0$ at the most right ), then
$\mathbf L =
\begin{pmatrix}
0& 0&0& 0&1& 0\\
0& 0&0& 0&0& 1\\
\end{pmatrix}$ so that

$$\mathbf L\mathbf\beta = 0$$
$$\Rightarrow \begin{pmatrix}
0& 0&0& 0&1& 0\\
0& 0&0& 0&0& 1\\
\end{pmatrix}\begin{pmatrix}
\beta_1\\
\beta_2\\
\beta_3\\
\beta_4\\
\beta_5\\
\beta_6\\
\end{pmatrix}=0$$

$$\Rightarrow \beta_5=0 \quad \text{and}\quad \beta_6=0,$$

but necessarily the contrast matrix is NOT correct as the row sum of a contrast matrix is equal to $0$. How can I define the contrast matrix?

Best Answer

The strict traditional definition of "contrasts" requiring row sums of 0 (e.g., in Wikipedia) seems to have been relaxed in practice. See, for example this page on contrast coding in R (note that R displays your contrast rows as columns), or this Cross Validated page on sum versus treatment contrasts.

In dummy or treatment coding, the default for the lm() function in R, "contrast" coefficients can sum to 1, not 0, for individual predictor variables, and they can have higher sums when interactions are considered. This makes it easier to identify individual treatment effects in output summaries, although I suppose it doesn't meet the strict definition of a "contrast" and it does lead to non-orthogonality.

For testing your hypothesis $H_0:\beta_5=\beta_6=0$, you can simply compare the full model against the model that omits both $\beta_5$ and $\beta_6$, and avoid the definition of "contrasts" completely. In R, that could be provided by anova(fullModel,reducedModel), which works on logistic regressions (or other generalized linear models) produced by glm() as well as on standard linear models.

Related Question