Search code examples
rlogistic-regressionlme4

Using glmer for logistic regression, how to verify response reference


My question is quite simple, but I've been unable to find a clear answer in either R manuals or online searching. Is there a good way to verify what your reference is for the response variable when doing a logistic regression with glmer?

I am getting results that consistently run the exact opposite of theory and I think my response variable must be reversed from my intention, but I have been unable to verify.

My response variable is coded in 0's and 1's.

Thanks!


Solution

  • You could simulate some data where you know the true effects ... ?simulate.merMod makes this relatively easy. In any case,

    • the effects are interpreted in terms of their effect on the log-odds of a response of 1
    • e.g., a slope of 0.5 implies that a 1-unit increase in the predictor variable increases the log-odds of observing a 1 rather than a 0 by 0.5.
    • for questions of this sort, glmer inherits its framework from glm. In particular, ?family states:

    For the ‘binomial’ and ‘quasibinomial’ families the response can be specified in one of three ways:

       1. As a factor: ‘success’ is interpreted as the factor not
          having the first level (and hence usually of having the
          second level).
    
       2. As a numerical vector with values between ‘0’ and ‘1’,
          interpreted as the proportion of successful cases (with the
          total number of cases given by the ‘weights’).
    
       3. As a two-column integer matrix: the first column gives the
          number of successes and the second the number of failures.
    

    Your data are a (common) special case of #2 (the "proportion of successes" is either zero or 100% for each case, because there is only one case per observation; the weights vector is a vector of all ones by default).