Announcement

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

  • Margins "option continuous implied because a factor with only one level was specified in option dydx()"

    Hi,

    I am running the following simulation of a probit estimation:
    Code:
    clear all
    set obs 1000000
    set seed 134
    
    * categorical variable with 3 levels
    gen cat=mod(_n, 3)+1
    
    * generating latent LHS variable, with only cat==3 having a significant effect
    gen y_l=rnormal(0,.1)
    replace y_l=y_l+1 if cat==3
    
    * generating LHS variable
    gen y=rbinomial(1, normal(y_l))
    
    * estimation
    probit y 3bn.cat
    margins, dydx(*)
    For margins, Stata gives me the following output:

    Code:
    . margins, dydx(*)
    note: option continuous implied because a factor with only one level was specified in option dydx().
    
    Conditional marginal effects                         Number of obs = 1,000,000
    Model VCE: OIM
    
    Expression: Pr(y), predict()
    dy/dx wrt:  3.cat
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           3.cat |   .3461805    .000876   395.17   0.000     .3444635    .3478975
    ------------------------------------------------------------------------------
    Could someone please explain to me why it makes sense (from an econometric perspective) that "option continuous implied because a factor with only one level was specified in option dydx()"?
    I can imagine calculating discrete marginal effects as:

    Code:
    probit y 3bn.cat
    local bcat=_b[3bn.cat]
    local bcons=_b[_cons]
    
    * evaluating CDF at cat == 3 vs at cat == some base value 
    quietly forval i=2/3{
            preserve 
            replace cat=`i'
         * evaluated normal pdf() for each observation in the training sample
            gen cdf_eval=normal(`bcat'*3bn.cat+`bcons')
         * the marginal effect of the given variable for each observation 
            su cdf_eval
            if `i'==2 {
                    local at_0=r(mean)
            }
            if `i'==3 {
                    local at_1=r(mean)
            }
            restore 
    }
    * taking the difference of these 
    local discrete_marginal_effect=`at_1'-`at_0'
        
    di "`discrete_marginal_effect'"
    For this the output is: .34095.

    Thank you!


  • #2
    Code:
     * estimation
    probit y 3b.cat
    margins, dydx(*)

    Comment


    • #3
      Hi George,

      Thank you very much for your response.
      I think you may not have sent the full message, however. Could you please share your full answer if you intended to write one?

      Thank you again,
      Gabor

      Comment


      • #4
        run the code I posted and see if it gives you the result you want. using 3bn eliminates the base, causing your dichotomous problem.

        Comment

        Working...
        X