Announcement

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

  • Output table for marginal and impact effects

    Hello,

    I have run a probit model followed by the
    Code:
    mfx
    command to get the marginal and impact effects.

    I then used this commands
    Code:
    eststo
    Code:
    esttab C:\Users\Wanyonyi\Desktop\DHS\output.csv
    However, the output table has estimates from the main probit model and not the the marginal and impact effect estimates.

    Kindly, what can I do to get the output table that has the marginal and impact effect estimates?

  • #2
    -mfx- has been superseded by the -margins- command. Use -margins- with the -saving()- option to save that output. Then -use- that saved file, clean it up to your taste, and then you can make a .csv file out of it with -export delimited-.

    Alternatively, you can use -margins- with the -post- option, and then I think -esttab- will handle it after that. I'm not sure of this as I don't use -esttab- myself.

    Comment


    • #3
      Hi Clyde,

      What's the command I can use for the -margins -with the -post -option?

      What do you normally use instead of esttab?

      Comment


      • #4
        The command itself is called -margins-. There are extensive examples of how to use it in the [R] manual. In addition, there is a really clearly written handout by Richard Williams at https://www3.nd.edu/~rwilliam/stats/Margins01.pdf.

        To give you more specific advice about applying it to your situation, you would have to show us your regression command and results.

        As for what I use instead of -esttab-, the answer is: nothing in particular. When I am in the midst of a project and want to share regression outputs with colleagues on the project I just send them my log files (as .smcl if they run Stata, as .pdf if they don't.) When it comes time to make a publication-ready table, I usually have narrowed down the results that will be presented to a small number of manageable tables. Often the regression results just as Stata shows them, or with light editing, do the trick (especially now that we have -set cformat- and lots of options that control the display of the regression table in the regression commands themselves. If something more complicated is needed, I tend to just write some custom-code for the circumstances.

        I have nothing particularly against -esttab-. It's just that it has a zillion options, and my need for it is sufficiently infrequent that I can never remember what they are and how they work anyway. For me, it's less work to do light hand-edits to the Stata output directly or write a little custom code than it is to figure out how to configure an -esttab- command.

        Comment


        • #5
          My command is:
          Code:
          probit hv121 hv206 hv105 agesq hv104 hv220 headagesq hv219  hdensity mwall wood sourceofwater sourceofwatersq hv009  hv025, cluster(hhid)
          The output is:
          Code:
          Iteration 0:   log pseudolikelihood = -2568.8374  
          Iteration 1:   log pseudolikelihood = -2306.3589  
          Iteration 2:   log pseudolikelihood = -2285.9021  
          Iteration 3:   log pseudolikelihood = -2285.8463  
          Iteration 4:   log pseudolikelihood = -2285.8463  
          
          Probit regression                               Number of obs     =     10,573
                                                          Wald chi2(14)     =     316.31
                                                          Prob > chi2       =     0.0000
          Log pseudolikelihood = -2285.8463               Pseudo R2         =     0.1102
          
                                            (Std. Err. adjusted for 4,860 clusters in hhid)
          ---------------------------------------------------------------------------------
                          |               Robust
                    hv121 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
                    hv206 |  -.2737755   .0924836    -2.96   0.003    -.4550401   -.0925109
                    hv105 |   .4563149   .0601365     7.59   0.000     .3384496    .5741803
                    agesq |  -.0201105   .0030597    -6.57   0.000    -.0261074   -.0141136
                    hv104 |   .0128462   .0399903     0.32   0.748    -.0655333    .0912258
                    hv220 |   .0039563   .0127487     0.31   0.756    -.0210307    .0289434
                headagesq |  -.0000529   .0001216    -0.43   0.664    -.0002913    .0001855
                    hv219 |  -.2067014   .0654437    -3.16   0.002    -.3349686   -.0784341
                 hdensity |   2.231987   .2648749     8.43   0.000     1.712842    2.751132
                    mwall |   .1730469   .0608503     2.84   0.004     .0537825    .2923112
                     wood |  -.0565939   .0986922    -0.57   0.566     -.250027    .1368392
            sourceofwater |  -.3416941   .0540198    -6.33   0.000     -.447571   -.2358172
          sourceofwatersq |   .0289682   .0094729     3.06   0.002     .0104017    .0475346
                    hv009 |  -.0440757   .0135297    -3.26   0.001    -.0705935    -.017558
                    hv025 |  -.0377929   .0630255    -0.60   0.549    -.1613206    .0857348
                    _cons |  -.9383623   .3985501    -2.35   0.019    -1.719506   -.1572185
          ---------------------------------------------------------------------------------
          Then for marginal and impact effects:
          Code:
          mfx
          Code:
          Marginal effects after probit
                y  = Pr(hv121) (predict)
                   =  .95424258
          ------------------------------------------------------------------------------
          variable |      dy/dx    Std. Err.     z    P>|z|  [    95% C.I.   ]      X
          ---------+--------------------------------------------------------------------
             hv206*|  -.0307527      .01212   -2.54   0.011  -.054504 -.007001   .162679
             hv105 |   .0438372      .00594    7.38   0.000   .032193  .055481    9.7678
             agesq |   -.001932       .0003   -6.42   0.000  -.002522 -.001342   102.161
             hv104*|    .001234      .00384    0.32   0.748  -.006293  .008761   .494562
             hv220 |   .0003801      .00122    0.31   0.756  -.002019  .002779   43.1677
          headag~q |  -5.08e-06      .00001   -0.44   0.663  -.000028  .000018   1974.99
             hv219*|  -.0220596      .00773   -2.85   0.004  -.037205 -.006914   .201362
          hdensity |   .2144223       .0233    9.20   0.000   .168756  .260089   .317888
             mwall*|   .0155706      .00513    3.04   0.002    .00552  .025621   .270027
              wood*|  -.0052675       .0089   -0.59   0.554  -.022704  .012169    .83212
          source~r |  -.0328258      .00531   -6.19   0.000  -.043228 -.022424   .515182
          source~q |   .0027829      .00091    3.05   0.002   .000996   .00457   .932687
             hv009 |  -.0042343      .00132   -3.21   0.001  -.006816 -.001652   7.09827
             hv025*|  -.0036817      .00623   -0.59   0.555  -.015892  .008528   .282512
          ------------------------------------------------------------------------------
          (*) dy/dx is for discrete change of dummy variable from 0 to 1
          I want an output that has the estimates from the mfx command as it is easier and more relevant to interpret marginal and impact effects than standardized probit

          Comment


          • #6
            OK. There are two problems: you didn't use factor variable notation in your -probit-, so you can't use -margins-. And it looks to me like your model is mis-specified.

            The misspecifications arise in connection with the terms agesq and headagesq. If I'm understanding the variable names correctly, these appear to be quadratic terms, but they have no linear terms included along with them. That is almost always a model misspecification: there are rare circumstances where a quadratic term with no linear is appropriate--but I'd be very surprised if that's the case here. So you need to build in the linear terms. And then the quadratics also need to be constructed using factor variable notation, so that -margins- will know that those terms are in fact the squares of the linear terms and will handle them appropriately.

            So I would do this as follows:
            Code:
            probit hv121 i.hv206 hv105 c.age##c.age i.hv104 hv220 ///
                c.headage##c.headage i.hv219  hdensity i.mwall i.wood ///
                c.sourceofwater##c.sourceofwater hv009  i.hv025, cluster(hhid)
            Then I would get the marginal effects as follows:
            Code:
            margins, dydx(*) saving(marginal_effects, replace)
            The final step is to -use marginal_effects-, rename the variables to something nicer than what -margins- gave them, drop any that you don't need, and then -export delimited- to create a .csv.

            Or, as I said earlier, it may be that if you do
            Code:
            margins, dydx(*) post
            -esttab- will get you what you want. It's certainly worth a try.

            Comment


            • #7
              Thank you so much Clyde for the correction, I hadn't noticed my model was mis-specified.
              After introducing the factor variable notation, I noticed that it drops the first category when the variable is a categorical dummy. Is there a way I can alter it so as to have a different category as the base category.


              If you don't mind, why is factor variable notation important in probit when one wants to use margins?

              Comment


              • #8
                see "help fvvarlist##bases" for how to choose the base level using factor variable notation

                margins understands factor variable notation and therefor will correctly deal with all "pieces" of a variable (several indicator variables or polynomials are 2 examples); thus, if you use factor variable notation then margins will do what you expect - if you don't margins will be dealing with each piece as a separate variable with is (almost) never what you want

                Comment


                • #9
                  Anne,

                  Using factor variable notation, when you have a nonlinear model like probit, is important to get the marginal effects you want. Suppose the variable x1 is categorical with two values and when introducing it in your list of covariates instead of typing
                  Code:
                  i.x1
                  you type
                  Code:
                  x1
                  The average marginal effect ( dydx(x1)), in the first case, is the average over the values of the covariates for

                  \begin{equation}
                  \Phi\left(\beta_0 + 1 + \beta_2x_2 \ldots \right) - \Phi\left(\beta_0 + 0 + \beta_2x_2 \ldots \right)
                  \end{equation}

                  In the second case it is the average over the values of the covariates for:

                  \begin{equation}
                  \phi \left(\beta_0 + \beta_1x_1 + \beta_2x_2 + \ldots \right)\beta_1
                  \end{equation}

                  These two results are numerically and qualitatively different. You can find a little of extra information about this topic in
                  http://blog.stata.com/2016/07/12/eff...-interpreting/
                  Last edited by Enrique Pinzon (StataCorp); 21 Jul 2016, 07:19.

                  Comment


                  • #10
                    Thank you for all for the helpful comments.

                    I need to extend my model and include other variables.
                    Initially the probit model was focusing on impact of electrification on school attendance at the household level. But now I want to include variables which capture child labour. I am using occupation of the children's parents but collapsing them to the village level from the household level.

                    Occupation is a categorical variable. But after collapsing,I end up with the five different categories. I am wondering how I can use the factor variable notation in this case as the occupation variable from which the 5 different categories are generated 'disappears' after collapsing.

                    These are the categories after collapsing the household father's occupation to the village level.

                    Code:
                     des occfather1 occfather2 occfather3 occfather4 occfather5
                    
                                  storage   display    value
                    variable name   type    format     label      variable label
                    -----------------------------------------------------------------------------------------------------------------------------
                    occfather1      float   %8.0g                 (mean) occfather1
                    occfather2      float   %8.0g                 (mean) occfather2
                    occfather3      float   %8.0g                 (mean) occfather3
                    occfather4      float   %8.0g                 (mean) occfather4
                    occfather5      float   %8.0g                 (mean) occfather5

                    The variable which 'disappeared' after use of collapse that I could have used with the factor variable notation is:
                    Code:
                    tab mv717
                    
                                 occupation (grouped) |      Freq.     Percent        Cum.
                    ----------------------------------+-----------------------------------
                                          not working |      1,732       22.91       22.91
                    professional/technical/managerial |        528        6.99       29.90
                          agriculture - self employed |      2,545       33.67       63.57
                               household and domestic |      1,009       13.35       76.91
                                       skilled manual |        556        7.36       84.27
                                     unskilled manual |      1,189       15.73      100.00
                    ----------------------------------+-----------------------------------
                                                Total |      7,559      100.00

                    I don't know whether I can ignore factor variable notation for only this variable and whether it will impact my results

                    Comment


                    • #11
                      For exporting output from the margins command, you can also try asdoc (from SSC).
                      Code:
                      ssc install asdoc
                      webuse margex
                      regress y i.sex i.group
                      asdoc margins sex, replace
                      Regards
                      --------------------------------------------------
                      Attaullah Shah, PhD.
                      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                      FinTechProfessor.com
                      https://asdocx.com
                      Check out my asdoc program, which sends outputs to MS Word.
                      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                      Comment

                      Working...
                      X