»  Home »  Resources & support »  FAQs »  Interpreting “outcome-does-not-vary” error message when running logistic

Why do I get the error message “outcome does not vary” when I perform a logistic or logit regression?

Title   Interpreting “outcome does not vary” error message when running logistic
Author Paul Lin, StataCorp

Answer

You probably have a dependent variable that is coded as 1 and 2 for the two outcomes

        1       the event did not occur
        2       the event did occur

Stata wants the coding

        0       the event did not occur
        1       the event did occur

All you have to do to fix the problem is

        . replace dep_var = dep_var - 1

We create variable y and code it as 1 and 2, and this produces the error message. After recoding the variable, we fit the model.

Here is an example:

. sysuse auto
(1978 Automobile Data)

. gen y=foreign+1

. codebook y

-------------------------------------------------------------------------------
y                                                                   (unlabeled)
-------------------------------------------------------------------------------

                  type:  numeric (float)

                 range:  [1,2]                        units:  1
         unique values:  2                        missing .:  0/74

            tabulation:  Freq.  Value
                            52  1
                            22  2


. capture noisily logit y price weight, nolog
outcome does not vary; remember:
                                  0 = negative outcome,
        all other nonmissing values = positive outcome


. replace y=y-1
(74 real changes made)

. logit y price weight, nolog

Logistic regression                             Number of obs     =         74
                                                LR chi2(2)        =      54.11
                                                Prob > chi2       =     0.0000
Log likelihood = -17.976341                     Pseudo R2         =     0.6008

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       price |   .0009296   .0002999     3.10   0.002     .0003418    .0015174
      weight |  -.0058785   .0016986    -3.46   0.001    -.0092078   -.0025493
       _cons |   9.000473   2.627577     3.43   0.001     3.850517    14.15043
------------------------------------------------------------------------------

Details

The coding

        0       the event did not occur
        1       the event did occur

is just an example of the type of coding Stata requires. Stata actually assumes the dependent variable is of the form

         0      the event did not occur
      nonzero   the event did occur 

and draws no distinction between the nonzero numbers. Thus, if you had a dependent variable that recorded the number of times an event occurred and you now wanted to analyze simply whether the event occured 1 or more times, you could use that count variable as a dependent variable with logistic, logit, or probit.

Stata

Shop

Support

Company


The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ YouTube
© Copyright 1996–2017 StataCorp LLC   •   Terms of use   •   Privacy   •   Contact us