Announcement

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

  • Marginal effects after cmp command

    Dear all,
    I am estimating (using the cmp command) a system of 2 equations where the first dependent variable is "years of education" and the second dependent variable is "hours of work", as follow:

    cmp (years_of_education = `set_of_controls_equation1) (hours_of_work = `set_of_controls_equation2), ind($cmp_cont "cond(hours_of_work>0, $cmp_cont, $cmp_left)") qui svy

    I want to get and display the marginal effects of all covariates.. This is of particular interest for interpreting the results of the second equation, which is indeed estimated as a Tobit regression in the system.
    I have tried several attempts starting as "margins, dydx(*) ...." but in vain. Any help about this please? Thank you very much in advance.

  • #2
    Welcome to Statalist!

    To increase the likelihood that Statalist readers will be able to assist you, please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Section 12.1 is particularly pertinent

    12.1 What to say about your commands and your problem

    Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
    ...
    Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
    as is Section 12.3 on the use of code delimiters to present code and output from the results window.

    With that said, the output of help cmp (noting that cmp is a user-written command available from SSC) has a long discussion on the use of predict and margins after cmp. Perhaps you have overlooked that advice.

    Comment


    • #3
      Dear William Lisowski, thank you for your feedback and advice. To be more specific, below are the two command lines I am running and the error message I got:


      Code:
      cmp (years_of_education = `set_of_controls_equation1) (hours_of_work = `set_of_controls_equation2), ind($cmp_cont "cond(hours_of_work>0, $cmp_cont, $cmp_left)") qui svy
      
      margins, dydx(*) predict(ystar(0 .) eq(#2)) force
      
      =exp required
      r(100);


      As a reminder, I'd like to get the marginal effects of all covariates in equation #2 on hours of work (censored outcome)... My feeling is that the command I typed to get what I need misses something... I went through the output of "help cmp" and the long discussion of "predict" and "margins" after "cmp", but I could not figure it out.

      Comment


      • #4
        If indeed
        Code:
        cmp (years_of_education = `set_of_controls_equation1) (hours_of_work = `set_of_controls_equation2), ind($cmp_cont "cond(hours_of_work>0, $cmp_cont, $cmp_left)") qui svy
        is the command you issued, then it was presumably preceded by something like
        Code:
        local set_of_controls_equation1 var1 var2 var3
        local set_of_controls_equation2 var4 var5 var6
        and your command should have been
        Code:
        cmp (years_of_education = `set_of_controls_equation1') (hours_of_work = `set_of_controls_equation2'), ind($cmp_cont "cond(hours_of_work>0, $cmp_cont, $cmp_left)") qui svy

        Comment


        • #5
          Dear William, thanks again for your feedback... I am sorry because I mistakenly wrote my estimation command line in my previous post. The way you correct is the right one and indeed it is the one I run in my do-file. The cmp command runs without error. The problem arises when I type
          Code:
           
           margins, dydx(*) predict(ystar(0 .) eq(#2)) force
          after which I get the error message
          Code:
           
           =exp required r(100);

          Comment


          • #6
            At this point I have nothing more to add; it will take someone with experience and expertise in the use of the cmp command.

            That person must also be willing to accept your assertion that the cmp command was correctly specified and ran without error, because most of your arguments to the cmp command are hidden in macros and unknown to the reader, and because you did not show the output from cmp, which would have given the reader an indication of what the arguments were and might have revealed an error you overlooked.

            To
            say exactly what you typed and exactly what Stata typed (or did) in response
            you should rerun your cmp and margins commands, and from your Stata Results window, copy everything starting with the cmp command and ending with the error message from the margins command, and including everything between the two, and paste that information into a code block.

            With that information, there is then the possibility that the reader can determine where your margins command fails to correctly relate to the results of your cmp command.

            Comment


            • #7
              Dear Willian, thank you for your suggestion. Below is the commands and Stata's output/response (NB: I've shortened the number of controls for space reasons):

              Code:
              . cmp (kid_grade_for_age =  c.FSOMI_d_hat4 hh_male_got_cashpayment_d hh_female_got_cashpayment_d female_wage_share 
              > female_wage_share_sqrd      ) (kid_a5_labor_hours_bis =  c.FSOMI_d_hat4  hh_male_got_cashpayment_d hh_female_got_
              > cashpayment_d  female_wage_share  female_wage_share_sqrd     ) if (MEI_d==1), ind($cmp_cont "cond(kid_a5_labor_ho
              > urs_bis>0, $cmp_cont, $cmp_left)") qui svy
              
              Fitting individual models as starting point for full model fit.
              Note: For programming reasons, these initial estimates may deviate from your specification.
                    For exact fits of each equation alone, run cmp separately on each.
              
              Fitting full model.
              
              Mixed-process regression
              
              Number of strata   =        36                  Number of obs      =      4057
              Number of PSUs     =       370                  Population size    =  27058592
                                                              Design df          =       334
                                                              F(   4,    331)    =     11.13
                                                              Prob > F           =    0.0000
              
              ---------------------------------------------------------------------------------------------
                                          |             Linearized
                                          |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              ----------------------------+----------------------------------------------------------------
              kid_grade_for_age           |
                             FSOMI_d_hat4 |   18.17413   3.548068     5.12   0.000     11.19475     25.1535
              hh_female_got_cashpayment_d |   9.214944     3.6171     2.55   0.011     2.099776    16.33011
                        female_wage_share |  -3.876617   16.87893    -0.23   0.818    -37.07902    29.32579
                   female_wage_share_sqrd |  -.2042746    17.8501    -0.01   0.991    -35.31705    34.90851
                                    _cons |   63.00956   2.652465    23.76   0.000     57.79191     68.2272
              ----------------------------+----------------------------------------------------------------
              kid_a5_labor_hours_bis      |
                             FSOMI_d_hat4 |   -39.9985   10.47351    -3.82   0.000    -60.60086   -19.39614
              hh_female_got_cashpayment_d |  -19.07112   15.16756    -1.26   0.210    -48.90711    10.76488
                        female_wage_share |   66.57664     64.454     1.03   0.302     -60.2103    193.3636
                   female_wage_share_sqrd |  -66.86831   66.97759    -1.00   0.319    -198.6194    64.88277
                                    _cons |  -69.56904   9.045313    -7.69   0.000    -87.36201   -51.77608
              ----------------------------+----------------------------------------------------------------
                                 /lnsig_1 |   3.416094   .0289591   117.96   0.000     3.359128    3.473059
                                 /lnsig_2 |   4.228853   .0553694    76.38   0.000     4.119937     4.33777
                             /atanhrho_12 |  -.1230916   .0334878    -3.68   0.000    -.1889652    -.057218
              ----------------------------+----------------------------------------------------------------
                                    sig_1 |   30.45023   .8818114                      28.76411    32.23519
                                    sig_2 |   68.63849   3.800475                      61.55534    76.53669
                                   rho_12 |  -.1224737   .0329855                     -.1867477   -.0571557
              ---------------------------------------------------------------------------------------------
              
              . margins, dydx(*) predict(ystar(0 .) eq(#2)) force
              =exp required
              r(100);
              Could anybody else help fixing this issue? Thanks!

              Comment


              • #8
                I believe that the problem may be that you're not specifying the vce(unconditional) option in your margins command. I believe you need to do so when using svy estimations. See "Obtaining margins with survey data and representative samples" in the manual section for margins.
                Alfonso Sanchez-Penalver

                Comment


                • #9
                  Dear Alfonso, thanks to your suggestion, it works now. Be blessed!

                  Comment

                  Working...
                  X