Announcement

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

  • Comparing predicted probabilities with the -margin- results

    I'm wrapping my head around divergences of predicted probabilities plots with estimated margins.

    Consider the following code for plotting predicted probabilities
    Code:
    logit dv support, vce(cluster country)
    predict pred_support
    twoway scatter pred_support dv support, connect(l i) msymbol(i O) sort ylabel(0 1)
    { // with Confidence Intervals
    predict support_lr_index, xb
    predict support_se_index, stdp
    gen support_lb = support_lr_index - invnormal(0.975)*support_se_index
    gen support_ub = support_lr_index + invnormal(0.975)*support_se_index
    gen support_plb = exp(support_lb)/(1+exp(support_lb)) // lower bound
    gen support_pub = exp(support_ub)/(1+exp(support_ub)) // upper bound
    twoway scatter pred_support support_plb support_pub dv support, connect(l l l) msymbol(i i i) sort ylabel(0 1) ylabel(0(.125)1)
    }
    where dv = dependent variable: attending a particular conference
    support = independent variable: support for a particular policy decision

    result:
    Click image for larger version

Name:	predprob.png
Views:	1
Size:	5.8 KB
ID:	1385616


    Then I've run (0.547 and 0.967 being the min and max value, respectively):
    logit dv v1 v2 v3 support, vce(cluster country)
    margins, at(support=(0.547(.03)0.967))
    which outputs:
    Predictive margins Number of obs = 181
    Model VCE : Robust

    Expression : Pr(dv), predict()

    1._at : support= .547

    2._at : support= .577

    3._at : support= .607

    4._at : support= .637

    5._at : support= .667

    6._at : support= .697

    7._at : support= .727

    8._at : support= .757

    9._at : support= .787

    10._at : support= .817

    11._at : support= .847

    12._at : support= .877

    13._at : support= .907

    14._at : support= .937

    15._at : support= .967

    ------------------------------------------------------------------------------
    | Delta-method
    | Margin Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    _at |
    1 | .8380664 .0467586 17.92 0.000 .7464213 .9297116
    2 | .8075578 .0463947 17.41 0.000 .7166259 .8984898
    3 | .7733774 .0447351 17.29 0.000 .6856981 .8610566
    4 | .7357583 .0419483 17.54 0.000 .6535412 .8179754
    5 | .6951272 .0385031 18.05 0.000 .6196624 .770592
    6 | .6520866 .0352208 18.51 0.000 .583055 .7211182
    7 | .6073739 .0331829 18.30 0.000 .5423366 .6724112
    8 | .5617994 .0333001 16.87 0.000 .4965324 .6270663
    9 | .5161787 .0356983 14.46 0.000 .4462112 .5861461
    10 | .471269 .0396798 11.88 0.000 .393498 .54904
    11 | .4277223 .044305 9.65 0.000 .340886 .5145586
    12 | .3860601 .0488291 7.91 0.000 .2903569 .4817633
    13 | .3466667 .0527853 6.57 0.000 .2432095 .450124
    14 | .3097993 .0559261 5.54 0.000 .2001861 .4194125
    15 | .275604 .0581506 4.74 0.000 .1616309 .3895772
    ------------------------------------------------------------------------------
    Why do the results differ? For example consider the minimum value of .547. The margin seems a little higher than what the graph indicates, and the confidence intervals are extremely off: -margins- shows .75 for the lower bound, but the plot shows about .625.

    I'm probably missing something extremely obvious, but as a German saying goes "sometimes you can't see the forest because of all the trees". If there is ignorance on my side, please forgive me, I am still quite new to this stuff.

  • #2
    Well, your graphs are based on a model with only a single predictor, support. But you calculated -margins- from a model with three additional predictors. Why are you surprised that the results are different? Why would you expect them to be the same, or even necessarily close?

    Comment


    • #3
      Oh d'oh! Extremely obvious. Thanks Clyde.

      I am however struggling now with
      Code:
       logit dv support, vce(cluster country)
      predict pred_support
      If I am including the other ind. variables, -predict- takes the full model into account, i.e. does not predict margins for support, holding the other variables constant. I've looked into the help file of predict but can't find an option of keeping the others constant. Or maybe this is the wrong approach? How can I plot the margins correctly?

      Comment


      • #4
        Or maybe this is the wrong approach? How can I plot the margins correctly?
        This is what the -margins- command is for. -predict- doesn't do that.

        The -margins- command does a lot of different things and offers many ways to constrain or average over variables. I think the best way to learn this command is to start with Richard Williams' article at http://www.stata-journal.com/sjpdf.h...iclenum=st0260. What you'd like to do sounds like it will be covered in that article. If it is not, then the next step would be the -margins- chapter in the user manuals, which is well written and contains numerous worked examples.

        Comment

        Working...
        X