Announcement

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

  • Post estimation after probit

    Hi All,

    For the following sample I run a probit model on a set of variables (x1 x2 x3 x4 i.yearmo),

    Code:
    probit dv x1 x2 x3 x4 i.yearmo
    but I want to calculate the probability of DV happening using the coefficients of the x variables and do not want to include the effects of i.yearmo in the post estimation. I don't think adding _b[variable]s is the most efficient and accurate approach. I really appreciate your help with it.





    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(unit_id yearmonth x1 x2 x3 x4 dv)
    3 648 -1.673604 -1.0363818 3.271517 3.790306 1
    3 649 .4038841 -1.0363818 3.174138 3.809004 1
    3 650 .562588 -1.0363818 3.425862 3.77931 1
    3 651 1.291389 -1.0363818 3.412346 3.6407406 1
    3 652 .8052794 -1.0363818 3.7186666 3.967077 1
    3 653 -.03675416 -1.0363818 3.219872 3.798276 1
    3 654 1.0632977 -1.0363818 3.466667 3.8156135 1
    3 655 -.5068667 -1.0363818 2.842949 3.8489246 1
    3 656 .5646673 -1.0363818 3.360119 3.63149 1
    3 657 .934234 -1.0363818 3.3083334 3.7305555 1
    3 658 .32183555 .7075664 3.7373564 3.793548 1
    4 648 -2.053771 -1.0363818 3.267277 3.7204175 1
    4 649 -.28470853 -1.0363818 3.773889 3.989841 1
    4 650 .1102932 -1.0363818 3.4863095 3.9390345 1
    4 651 .5085503 -1.0363818 3.5165405 3.55 1
    4 652 .4732249 -1.0363818 3.5431216 3.605337 1
    4 653 -.3396801 -1.0363818 3.7653334 3.3848386 1
    4 654 -.8023075 -1.0363818 3.746795 3.404524 1
    4 655 .524676 -1.0363818 3.7515874 3.2825396 1
    4 656 -.0806455 -1.0363818 3.571839 3.4154506 1
    4 657 .7601319 -1.0363818 4.146528 3.3850396 1
    4 658 -.29708236 .7053064 4.07963 3.9800696 1
    5 648 -.09884956 -1.0363818 4.0142856 3.9034524 1
    5 649 .3637376 -1.0363818 3.627564 3.9173334 1
    5 650 .5272369 -1.0363818 3.279167 3.396795 1
    5 651 .4010301 -1.0363818 3.641667 3.996528 1
    5 652 .03462299 -1.0363818 3.607143 3.503472 1
    5 653 -.8958375 -1.0363818 3.972222 3.9333334 1
    5 654 -.8420179 -1.0363818 3.8314815 3.6791666 1
    5 655 -1.972452 -1.0363818 3.801587 3.4958334 1
    5 656 -.8649931 -1.0363818 3.795833 3.6608696 1
    5 657 -.13952091 -1.0363818 3.608696 3.4591954 1
    5 658 -.035976883 .8973646 3.625 3.270988 1
    6 648 .6677211 -1.0363818 3.5735295 3.5553334 0
    6 649 .997246 -1.0363818 4.1704545 3.642529 0
    6 650 .6545075 -1.0363818 3.142593 4.140199 0
    6 651 .8990768 -1.0363818 3.4585884 4.068254 0
    6 652 .4727888 -1.0363818 3.5944445 4.099575 0
    6 653 -.5000833 -1.0363818 3.852193 3.8843474 0
    6 654 1.8032534 -1.0363818 3.210563 3.9385715 0
    6 655 -.9693494 -1.0363818 3.6065714 3.866164 0
    6 656 .05690836 -1.0363818 3.5489795 3.842613 0
    6 657 .463342 -1.0363818 3.4930556 3.975397 0
    6 658 .16892995 .6388407 3.357471 3.988834 0
    7 648 .7216926 -1.0363818 3.864368 4.069512 0
    7 649 .8041119 -1.0363818 3.4160714 3.954662 0
    7 650 .7418164 -1.0363818 4.1182795 4.158704 0
    7 651 .8701565 -1.0363818 4.010552 4.4940276 0
    7 652 .7349644 -1.0363818 4.110931 4.38009 0
    7 653 .12824593 -1.0363818 4.4591713 4.4671345 0
    7 654 .58063346 -1.0363818 4.526656 4.651618 0
    7 655 .10464822 -1.0363818 4.379938 4.608889 0
    7 656 .4740608 -1.0363818 4.61358 4.4431086 0
    7 657 .4891589 -1.0363818 4.579167 4.3469625 0
    7 658 .21748453 1.101524 4.451282 4.410873 0
    end
    [/CODE]

  • #2
    probit dv i.yearmo etc.
    replace yearmo = 0
    predict prob

    i would clone yearmo first so I didn’t wipe out the original variable.

    But i.yearmo makes no sense as yearmo is not a categorical variable, at least in your sample data.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Thank you very much!

      Comment


      • #4
        I should clarify my answer. If yearmo is a categorical variable, replace it with whatever the value of the reference category is.

        If it is actually a continuous variable, then replace it with zero.

        Also, I should have said

        predict prob if e(sample)

        to exclude cases with missing on dv.

        You can also do something like this:

        Code:
        webuse nhanes2f, clear
        probit diabetes weight height i.female
        margins, at(female = 0) gen(prob)
        sum prob
        That is actually probably the best way.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Thanks a lot. I thought margins command should work here, but wasn't sure how to use it. It's super helpful. I really appreciate your help.

          Comment

          Working...
          X