I have a dichotomous DV and a single factor with three levels. Is it possible to test for a linear trend in the log-odds for each level of my factor?

  • $\begingroup$ "Linear" as a function of what? This just doesn't make any sense when the domain is a dichotomous variable or an unordered factor, but those are all you say you have. $\endgroup$ – whuber Apr 29 '15 at 18:58
  • $\begingroup$ I might be misunderstanding the purpose of testing for a linear trend, but my aim was to examine if the likelihood of success increases linearly when advancing from level 1 to 2 to 3 of my factor. $\endgroup$ – David Apr 29 '15 at 19:06
  • 2
    $\begingroup$ The crucial information you have added in that comment--and which needs to be included in your question--is that the factor is ordered. You should pause, though, to contemplate what it could mean to be "linear" when the numerical values given to any ordered factor are almost completely arbitrary. For instance, it would be exactly the same thing to encode their values as $-1, \pi, 10^6$ instead of $1,2,3$. The only meaningful sense of "linear" that could survive such recoding would be to ask whether the two successive differences between the coefficients (of factors 1, 2, 3) are equal. $\endgroup$ – whuber Apr 29 '15 at 19:10
  • $\begingroup$ @whuber, OK to edit my answer to include your comment (if I get around to it)? (Alternately, feel free to edit it yourself if you like) $\endgroup$ – Ben Bolker Apr 29 '15 at 19:19

In R, you could specify that the factor is an ordered factor (ordered), which will parameterize a three-level factor in terms of constant, linear, and quadratic terms ... the f.L parameter below essentially measures the linear trend.

d <- data.frame(y=rbinom(60,prob=0.5,size=1),
## ...
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.51667    0.06612   7.815  1.4e-10 ***
## f.L         -0.03536    0.11452  -0.309    0.759    
## f.Q          0.02041    0.11452   0.178    0.859    

The contr.sdif (successive differences) contrast from the MASS package might also be of interest.

  • $\begingroup$ Thanks a lot! So if I were to simply run a logistic regression normally, and use an ordered factor as my predictor, the values associated with that factor in the output would be a test of the linear trend? As a follow up, is there any problem to including random subject and item factors? $\endgroup$ – David Apr 29 '15 at 19:32
  • $\begingroup$ yes, with the caveats pointed out by @whuber above. There aren't any issues associated with random factors other than the usual ones (do your random effects specifications accord with your experimental design? do you have enough data to estimate the random effects reliably? ...) $\endgroup$ – Ben Bolker Apr 29 '15 at 21:15

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.