Announcement

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

  • Plot predicted probability in probit model

    Dear Statalist,

    I have question about estimating probit model for each year and plot probability of predicted value for "au" (dependent variable) for two groups (au=1 and au=0) as below:
    This is my data
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long gvkey double year float(au size roa mtb aqe exf)
    1004 2009 1   7.313915  .029731346   1.0414093   .033695575     .006125473
    1004 2010 1   7.440574   .04098427    1.255999            0    -.001381535
    1004 2013 1   7.695985  .033143897    .9617889   .001764136    -.008624665
    1004 2014 1   7.323171  .006732673   1.2381912 .00013460762      -.0834298
    1004 2015 1   7.273856  .033076763    .9731014            0    -.004971087
    1004 2016 1    7.31595   .03756399   1.3129827  .0021213768   -.0014934492
    1013 2005 1   7.336286   .07211726   2.6268575    .02922615    .0022948938
    1013 2006 1   7.384859     .040772   1.9200138            0     .001525553
    1013 2007 1   7.475793   .06023346   2.1825328  .0014365263    .0007108584
    1034 2007 0   7.160974 -.010542904    1.206971  .0015534413      .06981232
    1050 2007 0  4.5699058    .0653131    3.967728    .03116333      .02306806
    1050 2011 0  4.3738055   .10425358   1.8740126            0    -.002851378
    1050 2012 0  4.5444007   .11529797    2.721909   .011530767   -.0005995999
    1072 2004 1   7.432335  .032982413   1.4720843 -.0004835262   -.0012897506
    1072 2005 1   7.423693    .0488011    2.104968            0     -.00149675
    1072 2006 1   7.549365   .08100136   1.5957184            0   -.0014539503
    1072 2008 1   7.535045   .04317477    .9265363  .0008384805   -.0009911828
    1072 2009 1   7.626323   .06963615   1.3409446 8.027479e-06   -.0004590954
    1072 2010 1   7.749099    .1051972   1.2438934            0 -.000021391113
    1072 2011 1   7.811168    .0619142   1.0604296            0   -.0007725336
    1072 2012 1   7.864034  -.02471642   1.0171332   .007850877   -.0010281052
    1072 2013 1   7.776949   .05326526   1.0827607  .0001604176   -.0006092862
    1072 2014 1   7.807516   .09185426   1.1257565            0  -.00015286943
    1072 2015 1   7.787307   .04213387    .9670519            0    -.000973231
    1072 2016 1    7.81497   .05077272   1.2410194            0    .0005406946
    1072 2017 1   7.890869 .0018370482   1.2425467   .028181544   -.0015216947
    1072 2018 1   7.942106    .0966179   1.2278615  .0011225757   .00003928149
    1078 2003 1  10.192993   .10305812    5.577196   .004883957    -.004811323
    1078 2004 1     10.267    .1124829     5.08001    .02097785     .004158493
    1078 2013 1  10.667862   .05997253    2.357419   .002631867     .002640942
    1084 2008 0    -1.7487  -4.5632186   -2.961447            0          .4625
    1084 2009 0  -5.521461     -181.75   -1.249938            0        .502809
    1084 2010 0  -.9113032   -1.482587   -3.474963            0       .6699507
    1084 2011 0 -1.2765435   -6.075269   -2.843761            0      .23788546
    1084 2012 0  -1.439695   -7.021097   -4.854805            0      .45348835
    1084 2013 0 -1.1147417  -12.585366   -3.493628            0       .9097345
    1084 2014 0  -3.575551  -35.107143   -3.050291            0      .14044943
    1084 2015 0  -3.649659  -155.26923   -.6544932            0       4.435185
    1084 2016 0 -2.3751557  -12.182796  -1.1653346            0       3.142857
    1084 2017 0 -1.6928195  -14.929348  -2.1432517            0       .5758123
    1084 2018 0  1.3470336    .4560582  -20.052353            0       .1085608
    1094 2003 1   4.816395   .06148852    2.253776            0    -.001789133
    1094 2004 1   5.008613   .08728966    2.816428    .00847681    -.000611238
    1094 2005 1   5.004134  .067202136    1.687143            0    .0009574023
    1094 2006 0   5.115548   .05544684   1.4602293            0   -.0007239719
    1094 2007 0   5.238981   .05418139   1.8029152            0    .0003407779
    1094 2008 0   5.403771   .06062283    1.330167            0   .00007547703
    1094 2009 0   5.325271   .04199763   1.1670898            0    .0006078928
    1094 2010 0   5.446095   .02838461   1.0428514  .0009981364     .002588523
    1109 2003 0  1.6823165    -.097434   3.4589114            0     .019037424
    1109 2004 0  2.0700223 -.008580442    3.401972    .07889198      .09433962
    1109 2005 0  2.1475673 -.002452125   1.7976558  .0006974346     .013129965
    1109 2006 0  1.9095426   -.4022222   1.9219157            0     .007640068
    1111 2004 1   7.175461   .10584462    2.704997    .00469773     .015962439
    1111 2005 1   7.257183   .02838065    3.124528   .001264119     .008272366
    1111 2006 1   7.492174   .04782026     3.80148   .004754527     .002950624
    1111 2007 1   7.836241   .13628113   4.1310906   .007954109     .005551008
    1117 2005 0   3.437722    .3307623    3.451609            0    -.006180007
    1117 2006 0   3.564053   .09706566   2.4783134            0    .0017238265
    1117 2007 0   3.406019   .06123735   1.5182197            0    .0009396342
    1117 2008 0  3.4217186  -.05309908    .3781489            0     .012440963
    1117 2009 0  3.4474764   .07520448   1.4697592            0     -.01208839
    1117 2010 0  3.5493875  -.01896988    .8565058            0     .015759746
    1117 2011 0   3.460943 -.015480265     .529798            0    -.015006227
    1117 2012 0  3.5251834   .06080683    .7538961            0   .00017475344
    1117 2013 0   3.527037   .03356553    1.457509            0   .00038244855
    1117 2014 0  3.6105394   .04388147    1.973701            0     .001013956
    1117 2015 0   3.675009    .0263885   1.5537088            0    .0006018186
    1117 2016 0   3.750539   .06320515    1.822378            0   -.0008049468
    1117 2017 0  3.7565615  -.08471765   1.5141876            0    -.002724237
    1117 2018 0   3.668447 -.004975632   1.7345374            0     -.02001415
    1121 2003 1    5.34835  .014753093   1.3533316            0              0
    1121 2004 1   5.475852  .036038753   1.5008677            0              0
    1121 2005 1   5.745123   .05642195   1.4673315            0              0
    1121 2006 1   5.667419   .03623737   1.7077773            0    -.007039633
    1121 2007 1   5.877946   .04776588   1.2119876            0    -.002320681
    1121 2008 1   5.351507  -.02641685    .8770196            0              0
    1121 2009 1   5.519062   .01663586   1.1098543            0              0
    1121 2010 1   5.708123   .02864539   1.1376506            0              0
    1121 2011 1   5.937114   .06052951   1.1093962            0              0
    1121 2012 1   6.039066  .066247754   1.0888226            0              0
    1121 2013 1   6.104976   .04822778     1.86788            0              0
    1121 2014 1   5.831337   .01913947    1.337734            0              0
    1121 2015 1   5.493946 -.005242276   1.0620366            0              0
    1121 2016 1    5.50887  .010179364   1.1052904            0              0
    1161 2003 1   8.867053  -.03869138   2.1403224 .00024639114   -.0022868165
    1161 2017 1   8.171882  .012146893   16.269657            0   -.0014575134
    1165 2004 0  2.0192933  -.12677552 -.003211403            0    -.005392768
    1165 2005 0  2.0090191  -.15008047 -.003057106            0    -.004903596
    1165 2006 0  2.1525757   .05611711 -.004956734            0     -.02916641
    1166 2003 1    6.74158  -.04361092   3.7424004            0     .037149664
    1166 2004 1   7.016884  .029179435    2.481453   .003076133     .033667497
    1166 2005 1   6.868947  -.04950958   3.1341565  .0003138779    -.022232614
    1166 2006 1   7.001594    .0412525    3.088033  .0003720301     .002980852
    1166 2007 1    7.11244   .07256315    2.766611 .00008815233    -.010363704
    1166 2008 1   6.974196   .02397871   1.0165823 .00005335747    -.023687014
    1166 2009 1   7.107144  -.12511551   3.8524864 .00001572496     .035828665
    1166 2010 1   7.384618    .0911272    3.394258            0    -.015197933
    1166 2014 1   7.701097   .07515746   1.3044246            0    -.003420236
    1166 2015 1   7.720596   .07576045   1.1082753            0     -.00823872
    end
    I have some questions as below:

    Q1: How can I estimate probit model for each year in a quickly way? Because now I write command and run manually for each year and compute the predicted value for "au" as following:
    Code:
    probit au size roa mtb aqe exf if year==2003, vce(robust)
    predict pprobit2003, pr
    replace pprobit2003=. if year>2003
    The following years are done similarly by only changing the year. But if doing like this, I have to repeat the command for the whole period.

    Q2. Is this Likelihood ratio index as Pseudo R2 from results of probit model?
    Q3. I need to plot the predicted value (or prob of "au" hat) in each year for 2 groups of firms ( firms have "au"=1 and firms have "au"=2) like an image below. In particular, I need to split the range into 20 intervals. And the percentage of each firms in each interval is plotted against the mid-value of the interval for both groups. So, it likes a discrete approximation.
    Click image for larger version

Name:	Screen Shot 2020-03-11 at 10.54.44 PM.png
Views:	1
Size:	70.5 KB
ID:	1540911


    Q4. How can obtain the value of cut-off point of two line in this graph?


    Thank you so much for your consideration.
    I am really appreciated to receive your help.

  • #2
    Can anyone please help me or give me some hints to move on? Thank you so much

    Comment


    • #3
      Regarding question 1, something like this might be what you want:
      Code:
      sum year
      forvalues year=r(min)/r(max){
      probit au size roa mtb aqe exf if year==`year', vce(robust)
      predict pprobit`year' if esample, pr // predict only for those who are in the estimation sample
      *replace pprobit2003=. if year>2003 // you should not need this line any more
      }
      About your other questions: I could not run the code because in your example dataset, I receive the following error message
      Code:
      outcome = size > 1.682317 predicts data perfectly
      indicating the example dataset is not suitable for experimentation.

      Comment

      Working...
      X