Announcement

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

  • Probit margins "Factor not found in list of covariates"

    Dear Stata users,

    I am running a probit model with three binary indep. vars. and some other continuous dep. vars. The probit model runs perfectly, however, whenever I want to take the margings (which I only want for the three binary Independent variables), Stata tells me that the "Factor was not found in the list of covariates". I posted the log below. The variables I want the margins of (
    drought_025 MMdrought_025 MM_use) are three binary indicators. What can I do to fix this?
    Best, Anne




    . probit hh_q14 drought_025 MMdrought_025 MM_use hhsize phoneowner wealthscore bankaccount part_assoc, vce(cluster hhid)

    Iteration 0: log pseudolikelihood = -912.3496
    Iteration 1: log pseudolikelihood = -904.10648
    Iteration 2: log pseudolikelihood = -904.04121
    Iteration 3: log pseudolikelihood = -904.04102
    Iteration 4: log pseudolikelihood = -904.04102

    Probit regression Number of obs = 1,585
    Wald chi2(8) = 13.38
    Prob > chi2 = 0.0993
    Log pseudolikelihood = -904.04102 Pseudo R2 = 0.0091

    (Std. Err. adjusted for 1,585 clusters in hhid)
    ------------------------------------------------------------------------------
    | Robust
    hh_q14 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    drought_025 | -.0134295 .2133811 -0.06 0.950 -.4316488 .4047898
    MMdrough~025 | -.6939054 .5643085 -1.23 0.219 -1.79993 .4121191
    MM_use | -.2033974 .0956013 -2.13 0.033 -.3907726 -.0160223
    hhsize | -.0233613 .0143946 -1.62 0.105 -.0515741 .0048516
    phoneowner | .2052696 .0794024 2.59 0.010 .0496437 .3608956
    wealthscore | .0028154 .0276162 0.10 0.919 -.0513113 .0569422
    bankaccount | -.1351624 .1538211 -0.88 0.380 -.4366463 .1663215
    part_assoc | .1581335 .1736723 0.91 0.363 -.182258 .4985251
    _cons | -.5774606 .103155 -5.60 0.000 -.7796407 -.3752805


    . margins drought_025 MMdrought_025 MM_use, post
    factor drought_025 not found in list of covariates
    r(322);




  • #2
    Put a toy sample of your data with -dataex- so that we can check what is going on, if what I say below is not it.

    But I think Stata wants you to tell her that these are binary variables like this

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . summ mpg, meanonly
    
    . gen mpgdummy = mpg>r(mean)
    
    . probit foreign mpgdummy headroom, nolog
    
    Probit regression                               Number of obs     =         74
                                                    LR chi2(2)        =      11.28
                                                    Prob > chi2       =     0.0036
    Log likelihood = -39.393062                     Pseudo R2         =     0.1252
    
    ------------------------------------------------------------------------------
         foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        mpgdummy |    .712355   .3542323     2.01   0.044     .0180725    1.406638
        headroom |  -.3535888   .2334736    -1.51   0.130    -.8111886     .104011
           _cons |   .1344065   .7590577     0.18   0.859    -1.353319    1.622132
    ------------------------------------------------------------------------------
    
    . margins mpgdummy
    factor 'mpgdummy' not found in list of covariates
    r(322);
    
    . probit foreign i.mpgdummy headroom, nolog
    
    Probit regression                               Number of obs     =         74
                                                    LR chi2(2)        =      11.28
                                                    Prob > chi2       =     0.0036
    Log likelihood = -39.393062                     Pseudo R2         =     0.1252
    
    ------------------------------------------------------------------------------
         foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
      1.mpgdummy |    .712355   .3542323     2.01   0.044     .0180725    1.406638
        headroom |  -.3535888   .2334736    -1.51   0.130    -.8111886     .104011
           _cons |   .1344065   .7590577     0.18   0.859    -1.353319    1.622132
    ------------------------------------------------------------------------------
    
    . margins i.mpgdummy
    
    Predictive margins                              Number of obs     =         74
    Model VCE    : OIM
    
    Expression   : Pr(foreign), predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        mpgdummy |
              0  |    .188038   .0642029     2.93   0.003     .0622025    .3138735
              1  |   .4198893   .0923938     4.54   0.000     .2388007    .6009778
    ------------------------------------------------------------------------------
    
    .

    Comment


    • #3
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input byte hh_q14 float(MM_use drought_025 MMdrought_025)
      1 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
      1 0 0 0
      0 0 0 0
      0 0 0 0
      0 1 0 0
      0 0 0 0
      0 0 0 0
      0 1 0 0
      0 0 0 0
      0 1 0 0
      1 0 0 0
      0 0 0 0
      1 0 0 0
      0 0 0 0
      1 0 0 0
      0 0 0 0
      1 0 0 0
      1 0 0 0
      0 0 0 0
      1 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 1 0 0
      1 0 0 0
      0 0 0 0
      0 0 0 0
      1 0 0 0
      1 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 1 0 0
      0 0 0 0
      0 0 0 0
      1 0 0 0
      1 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
      1 0 0 0
      0 1 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 1 0 0
      0 0 0 0
      0 1 0 0
      0 1 0 0
      0 0 0 0
      0 1 0 0
      0 1 1 1
      0 0 1 0
      0 0 0 0
      0 1 1 1
      0 0 1 0
      0 0 0 0
      0 0 1 0
      0 1 0 0
      0 1 0 0
      0 1 0 0
      end
      label values hh_q14 hh_q14
      label def hh_q14 1 "YES", modify

      This is the dataex - shall I really put i. also before only binary, not categorical variables?

      Comment


      • #4
        Indeed, it worked, thank you!

        Comment


        • #5
          You are welcome !

          These are called factor variables, a bit misleadingly because they include also continuous variables and interactions. Check the help

          Code:
          help fvvarlist
          to see how exactly they work. Basically factor variables are i.var, continuous variables are c.var, interactions are #, and all levels interactions are ##.

          You use them as you need, in this case as you do not need to apply -margins- on the continuous controls, I think it is not necessary to tell Stata that the controls are continuous.

          Originally posted by Anne Klein View Post
          Indeed, it worked, thank you!

          Comment


          • #6
            As a general rule, anything to the left of the comma has to be a categorical variable, designated by something like i.var in the preceding estimation command. i.var is often a dichotomy but it can have more categories, e.g. i.relig where relig is coded 1 = Catholic, 2 = Protestant, 3 = Jewish, 4 = Muslim, etc.

            As an aside, your output would be far easier to read if you used code tags. See section 12 of the Statalist FAQ. https://www.statalist.org/forums/help#stata
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            StataNow Version: 19.5 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              Thank you, Richard and Joro. Joro, how do you interpret the marginal effect for mpgdummy = 0?

              Comment

              Working...
              X