4
$\begingroup$

I have a dataset with 7 factor levels none of which are a reasonable reference group, so I've chosen to set up my GLM (negative binomial) analysis using deviation coding. I've studied this question along with this very helpful post to figure out how to calculate the coefficient of the 'left out' factor, the number 7 by default using R contr.sum. This calculation is useful as sign and magnitude will be useful for my discussion on the relationships suggested with the model.

My question is how to find the z or t value, depending on the type of test, for the 'left out' factor? I assume it has to be related to the statistic calculated for the (Intercept) because the intercept is the grand mean and the test is for difference against the grand mean it wouldn't make sense that my models are finding a significant test statistic here. I also need to get a SE for the 'left out' factor, I'm not sure how to proceed on that calculation, I could use the same method for finding the coefficient but I haven't seen a discussion on this and would like some supporting evidence.

Here is an example of a set of models that perform the calculation that I'd like to get at. The first model is with the default contrast settings for deviation coding, in the second model I've re-arranged the contrasts to make a different factor 'left out'. I'm reassured that the intercept and common factors to both models do not change; for brevity sake I didn't include other model metrics but deviance, and AIC were exactly the same for both models (as expected).

Surely there is a more elegant way to do the calculations for the 'left out' factor of any single model.

enter image description here

$\endgroup$

1 Answer 1

3
$\begingroup$

The simplest way without resorting to statistics is simply to refit your model with a different category as the "left out" category. All the other coefficients, including the intercept, should remain the same. Note that whether you compute the effect estimate and standard error manually using contrast matrices or by just refitting the model, the additional test is not orthogonal to the others and is subject to an elevated type I error rate, though with 7 comparisons you should be correcting for that anyway.


With deviation coding, you have that $$ \hat \beta_1 + \hat \beta_2 + \hat \beta_3 + \hat \beta_4 + \hat \beta_5 + \hat \beta_6 + \hat \beta_7^* = 0 $$ $\hat \beta_7^*$ is missing and is the quantity of interest. To get it, we can do some algebra to arrive at

\begin{align} \hat \beta_7^* &= 0\hat\beta_0 - \hat\beta_1 - \hat\beta_2 - \hat\beta_3 - \hat\beta_4 - \hat\beta_5 - \hat\beta_6 \\ &=\mathbf{C}\boldsymbol{\hat\beta} \end{align} where $$\mathbf{C}=\begin{bmatrix}0 && -1 && -1 && -1 && -1 && -1 && -1\end{bmatrix}$$ and $$\boldsymbol{\hat\beta}'=\begin{bmatrix}\hat\beta_0 && \hat\beta_1 && \hat\beta_2 && \hat\beta_3 && \hat\beta_4 && \hat\beta_5 && \hat\beta_6 \end{bmatrix}$$

To get the standard error of $\hat \beta_7^*$, we can perform the following operation on the variance-covariance matrix $\hat\Sigma_\beta$ of the estimated parameters (extracted from the model using vcov)

$$\hat \sigma_{\hat \beta_7^*} = \sqrt{\mathbf{C} \hat\Sigma_\beta \mathbf{C}'}$$

We can compute a Z-statistic in the usual way (which is only approximately correct in finite samples, same as the other Z-statistics for the coefficients. With the other coefficients in the model, you can just insert $0$s into $\mathbf{C}$.

If you want to estimate the coefficients and standard errors of two coefficients at the same time (e.g., for both the "main effect" and interaction of the missing category), you can add another row to $\mathbf{C}$ that contains the contrast coefficients that correspond to the parameter to be estimated. Then $\mathbf{C} \hat\Sigma_\beta \mathbf{C}'$ is the variance-covariance matrix of the desired parameters, and the square roots of the diagonal elements are the standard errors for each.

$\endgroup$
4
  • $\begingroup$ You say "without resorting to statistics" – but if one wants to compute this rather than rerunning the model, is there a way of doing so? You mention the idea of "[computing] the effect estimate and standard error manually using contrast matrices" but I'm unsure on how to do this and haven't been able to find a reference in my searches. Any chance you can provide more insight? $\endgroup$ Aug 7, 2020 at 5:49
  • $\begingroup$ See my edit. If you look up "linear combination of regression coefficients" you might find more info on this. $\endgroup$
    – Noah
    Aug 7, 2020 at 6:46
  • $\begingroup$ I see. Thank you, that’s helpful. If I’m not mistaken, $\hat\beta_1$ through $\hat\beta_7^*$ sum to 0 with deviation coding, so the first element of $\mathbf C$ should be 0, not 7. $\endgroup$ Aug 7, 2020 at 8:17
  • $\begingroup$ Oh yes, you're right. When I wrote this originally wrote it in terms of sample means but realized that didn't generalize to the GLM in the question. I'll edit it for future reference. $\endgroup$
    – Noah
    Aug 7, 2020 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.