Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • error: depvar may not be a factor variable

    Hey everybody,

    I want to run a regression with binary variables but I am getting this error: depvar may not be a factor variable.

    I don't know why "no_ma_deals_binary" might not be a factor variable. It only contains 0 and 1.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(no_ma_deals_binary CTO_presence)
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    1 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    0 0
    end
    I hope someone can help me.

    Kind regards,
    Jana

  • #2
    Please show your regress (or other) code.

    See 12.1 at https://www.statalist.org/forums/help#stata

    If you want to know why a command did not work, show us that command.

    If your code started

    Code:
    regress i.no_ma_deals_binary
    that's illegal. It's also unnecessary as

    Code:
    regress no_ma_deals_binary

    is all that regress needs here for a linear probability model. The clue is that you're getting an error message about the dependent variable (outcome or response) which is the first variable to be named in most modelling commands.
    Last edited by Nick Cox; 28 Dec 2021, 10:33.

    Comment


    • #3
      Jana:
      as an aside to Nick's helpful advice, please note that the very same holds switching from -regress- to -logit- or -logistic- (which are the most frequent used tools when it comes to a binomial yes/no regressand and the researcher is not interested in linear probability models via -regress-), as you can see from the following toy-example that benefit from your data excerpt:

      Code:
      . logistic i.no_ma_deals_binary i.CTO_presence
      depvar may not be a factor variable
      r(198);
      
      . logistic no_ma_deals_binary i.CTO_presence
      note: 0.CTO_presence omitted because of collinearity.
      
      Logistic regression                                     Number of obs =    100
                                                              LR chi2(0)    =   0.00
                                                              Prob > chi2   =      .
      Log likelihood = -5.6001534                             Pseudo R2     = 0.0000
      
      ------------------------------------------------------------------------------------
      no_ma_deals_binary | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
      -------------------+----------------------------------------------------------------
          0.CTO_presence |          1  (omitted)
                   _cons |    .010101   .0101519    -4.57   0.000     .0014089    .0724193
      ------------------------------------------------------------------------------------
      Note: _cons estimates baseline odds.
      
      .
      In addition, I'm confident that you do not have one predictor only.
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        Yes, sorry!

        But actually, you already helped me.

        Code:
        regress i.no_ma_deals_binary
        I used this and it worked without the i.

        Comment


        • #5
          Jana:
          no wonder that you were successful omitting the -i.- prefix.
          Before the invoked procedure starts, Stata carries out a consistency check behind the curtain; as the -fvvarlist- notation does niot apply to regressand, you received an error messages.
          In addition, please be sure to have enough variation in your predictors (this does not seem to be the case for the one included in your laudable -dataex- excerpt/example).
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment

          Working...
          X