Announcement

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

  • "Equation not found" - Hurdle model using suest

    Hi there,
    I am using Stata 15.

    I am trying to estimate the marginal effects for a logit-truncated negative binomial hurdle model. Unfortunately I do not have the citation because I am using photocopies of pages from a book given to me by my advisor. The author of the book estimates the two parts of the model and then uses suest followed by a series of local macros followed by margins to estimate the marginal effects. I am following his method and it seems I am running into a silly error that I can't figure out.

    Here's my code:
    Code:
    quietly svy linearized, subpop(SPD):logit useanyhcru i.yearind i.sex i.raceeth2 i.region i.married i.education ib1.natstat c.pcs ib1.agecat ib1.povcat2 i.insstat1
    estimates store anyh1
    quietly svy linearized, subpop(SPD):tnbreg anyhcru i.yearind i.sex i.raceeth2 i. region i.married i.education ib1.natstat c.pcs ib1.agecat ib1.povcat2 i.insstat1 if anyhcru>0, ll(0)
    estimates store anyh2
    quietly suest anyh1 anyh2
    
    /*hurdle nb model marginal effects*/
    local logit "invlogit(predict(eq(anyh1_useanyhcru))) "
    local ey "exp(predict(eq(anyh2_anyhcru))) "
    local pygt0 "(nbinomialtail(exp(-predict(eq(/anyh2:lnalpha))),1,""1/(1+exp(predict(eq(anyh2_anyHCRU)))/exp(-predict(eq(/anyh2:lnalpha))))))"
    margins, dydx(*) expression("`logit'*`ey'/`pygt0'")
    where "anyhcru" is the number of health care visits and "useanyhcru" is the number of health care visits conditional on having at least one visit (useanyhcru>0).

    When I run the model, I get the following error:
    Code:
    . /*hurdle nb model suest*/
    . quietly svy linearized, subpop(SPD):logit useanyhcru i.yearind i.sex i.raceeth2 i.region i.married i.education ib1.natstat c.pcs ib1.agecat ib1.povcat2 i.insstat1
    
    . estimates store anyh1
    
    . quietly svy linearized, subpop(SPD):tnbreg anyhcru i.yearind i.sex i.raceeth2 i. region i.married i.education ib1.natstat c.pcs ib1.agecat ib1.povcat2 i.insstat1 if anyhcru>0, ll(0)
    
    . estimates store anyh2
    
    . quietly suest anyh1 anyh2
    
    . /*hurdle nb model marginal effects*/
    . local logit "invlogit(predict(eq(anyh1_useanyhcru))) "
    
    . local ey "exp(predict(eq(anyh2_anyhcru))) "
    
    . local pygt0 "(nbinomialtail(exp(-predict(eq(/anyh2:lnalpha))),1,""1/(1+exp(predict(eq(anyh2_anyHCRU)))/exp(-predict(eq(/anyh2:lnalpha))))))"
    
    . margins, dydx(*) expression("`logit'*`ey'/`pygt0'")
    Warning: cannot perform check for estimable functions.
    equation anyh2_anyHCRU not found
    r(303);
    I don't understand why it can seem to find the equation anyh1_useanyhcru but it can't find the equation anyh2_anyhcru. Any thoughts?

  • #2
    **EDIT: ' "useanyhcru" is the number of health care visits conditional on having at least one visit (anyhcru>0).'

    Comment


    • #3
      I don't understand why ... it can't find the equation anyh2_anyhcru.
      What it tells you it cannot find is the equation anyh2_anyHCRU (upper or lower case makes a difference).

      Comment

      Working...
      X