Announcement

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

  • Equivalence between margins and predictnl

    Hello,

    I am using Stata 17 to estimate the impact of variable X on a probability P.

    I run a regression of the log odds ratio on the variable X.
    I would like to get the predicted probability for different years.

    I cannot obtain similar confidence intervals when I use predictnl or margin.

    Code:
    gen log_odds_ratio = ln(P/(1-P))
    reg log_odds_ratio X
    margins if year == 2010 , expression(exp(predict(xb))/(1+exp(predict(xb))))
    which differs from the confidence intervals computed by hand using predictnl:

    Code:
    gen log_odds_ratio = ln(P/(1-P))
    reg log_odds_ratio X
    predictnl pred_prob=exp(predict(xb))/(1+exp(predict(xb))) , var(variance)
    egen tot_var = total(variance) if year == 2010
    count if year == 2010
    gen standard_error= 1/r(N)*sqrt(tot_var)
    These two give very different standard errors.
    I'm confused since the standard error of the average probability should be 1/n sqrt(sum(Variances)).
    Any idea what I might doing wrong?

    Thanks a lot,

    Best,
    Nicholas




    Last edited by Nicholas Delam; 04 May 2022, 17:57. Reason: margins

  • #2
    Nicholas:
    have you already checked in the respective Stata .pdf manual entries whether the issue you're facing is not related to different appraoches in SE calculation?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,
      Thanks for your reply.
      I did, both are computed using the delta method.
      Also, the order of the magnitude of the difference between the two is much larger than different approaches in SE calculation would give I think.

      Thanks!
      Best,
      Nicholas

      Comment

      Working...
      X