1
$\begingroup$

3 variables (1 continuous (X) and 2 categorical (A & B)) predict 1 dichotomous variable in logistic regression.

Both variables A and B are dichotomous and are coded with 1 (reference category) and 2. Criterion is coded with 0 & 1.

We have the following results:

Fixed effects:
                                   Estimate Std. Error z value Pr(>|z|)    
(Intercept)                         1.47384    0.04094  35.997  < 2e-16 ***
X                                  -0.03252    0.01612  -2.017  0.04370 *  
A2                                 -0.46066    0.04853  -9.492  < 2e-16 ***
B2                                 -0.61576    0.04811 -12.799  < 2e-16 ***
X:A2                                0.07502    0.01810   4.144 3.41e-05 ***
X:B2                                0.08031    0.01945   4.129 3.64e-05 ***
A2:B2                               0.62260    0.06653   9.358  < 2e-16 ***
X:A2:B2                            -0.06789    0.02367  -2.868  0.00413 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Now, the slopes for different conditions are:

    A1      A2 
B1  X       X+X:A2
B2  X+X:B2  X+X:A2+X:B2+X:A2:B2

How can I test the following hypothesis

X+X:B2 = X+X:A2 + X:B2 + X:A2:B2 which equals to
0 = X:A2 + X:A2:B2 and finally

X:A2 = -X:A2:B2

$\endgroup$
  • $\begingroup$ The model is estimated with maximum likelihood so standard general tests include Likelihood Ratio, Wald test and Lagrange multiplier. The following link provides some introduction to the test types ... stats.idre.ucla.edu/other/mult-pkg/faq/general/… $\endgroup$ – Jesper for President Dec 5 '18 at 12:16
  • $\begingroup$ Yes, that I am aware. However, I don't know how to set up tests that will test the particular hypothesis that I asked about. The model I presented tests whether all these coefficients are different from 0, and not whether they are the same as other coefficients and this is precisely what I need. Alsoi the model in question is a mixed model, but I left out the subject-related variance in order to make the question simpler... $\endgroup$ – User33268 Dec 5 '18 at 21:52
3
$\begingroup$

Assume you have a logit model with linear index

$$ P_j \propto \exp\left(\sum_{k=1}^K \beta_{k} x_{jk}\right)$$

and assume for the sake of example that $$\beta = (\beta_1,...,\beta_6)^\top$$ that is $K=6$ and I want to test $$\beta_4 = \beta_5$$

Then I first isolate all coefficients on one side

$$\beta_4 - \beta_5 = 0$$

then I define $R = (0,0,0,1,-1,0)$ such that

$$R\beta= (0,0,0,1,-1,0)\begin{pmatrix} \beta_1 \\ \beta_2 \\ \beta_3 \\ \beta_4 \\ \beta_5 \\ \beta_6\end{pmatrix} = \beta_4 - \beta_5$$

I am now able to write the hypothesis I'm interested in the way it is standardly done in the statitical theory so my null hypothesis is

$$R\beta = \beta_4 - \beta_5 = 0$$

To perform such a test in the software R

install.packages("aod")
library(aod)
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
## view the first few rows of the data
head(mydata)
mydata$rank <- factor(mydata$rank)
mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
summary(mylogit)
# Test if coefficient 4 is same as 5 
R <- cbind(0, 0, 0, 1, -1, 0)
wald.test(b = coef(mylogit), Sigma = vcov(mylogit), L = R)

In your case there is a total of 8 coefficients including the constant term and you want to test if the sum of coefficient 5 and 8 are 0 so in youre case

$$R = (0,0,0,0,1,0,0,1)$$

The example I used here was borrowed from this webpage wald test example

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Dear Jesper, is your answer also applicable to fixed effects in mixed models? $\endgroup$ – User33268 Feb 11 '19 at 9:34
  • $\begingroup$ It could very well be that the procedure is very similar and the main difference in how the covariance matrix is actually calculated. However I would have to look into it to make sure, I think it is a fair question but maybe you should raise it as an actual question rather than a comment here. $\endgroup$ – Jesper for President Feb 11 '19 at 13:11
  • $\begingroup$ Would you mind taking a look at stats.stackexchange.com/questions/391933/… ? I would be very grateful! $\endgroup$ – User33268 Feb 25 '19 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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