Announcement

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

  • Margins (marginal effects) after -cmp- for simultaneous equations

    Hi all,

    I am running the following regression using -cmp-:
    Code:
    cmp setup
    set more off
    cmp (rwork =rshlt_# c.age##c.age  i.married##i.child18_  i.lesshighschool##i.ageover62 i.college##i.ageover62 i.collegemore##i.ageover62 i.whitecollar2_ i.bluecollar c.wealth i.hispanic i.black i.midwest i.northeast i.west i.rcovown i.yr1996 i.yr1998 i.yr2000 i.yr2002 i.yr2004 i.yr2006 i.yr2008|| hhidpn:) (rshlt_=rwork# c.pc c.rconde c.age##c.age i.married  i.lesshighschool i.college i.collegemore i.whitecollar2_ i.bluecollar c.wealth i.hispanic i.black i.rsmoke i.rdrink i.lagsmoke i.lagdrink i.lagprevent i.midwest i.northeast i.west i.rhibpe i.rdiabe i.rcancre i.rlunge i.rhearte i.rstroke i.rpsyche i.rarthre  i.rhlthins || hhidpn:) if (ragender==1 & age<65) ,ind($cmp_probit $cmp_oprobit) nolr
    cmp, resultsform(reduced)
    margins, dydx(*) predict(equation(rwork) pr) force noestimcheck
    My question is "why no results show up after margins command?" It takes hours and hours without any result Many thanks.

    Result:
    PHP Code:
    marginsdydx(*) predict(equation(rwork)) force noestimcheck
    (notecontinuous option implied because a    factor with only one level    was    specified    in    the    dydx()    option
    Last edited by Maryam Bidgoli; 30 Jun 2017, 20:49.

  • #2
    You have a very large number of variables. Perhaps if you specify just one or two variables in the dydx option you will get results, and the amount of time it takes will give you a better idea of how long it will take for all your variables. Or you can just run the margins command repeated with just a few variables as the argument to dydx().

    The warning message also suggests you may have a problem. It suggests that at least one factor variable (i.variable) has only a single level.

    I'm also concerned that you have different factor variables for year - i.1996 i.1998 etc - and I don't think the results of margins will be meaningful, because Stata will not understand that i.1996==1 means that all the other yearly factor variables will have to be zero, if you have constructed them in the way I assumed. Generally you'd use i.year where year is the year in question - 1996 or 1998 or ... .

    Comment


    • #3
      Thank you so much William for your help.
      As you suggested, I first specified just a few variables in dydx, and then ran margins for the full model. It took me couple of hours to get the results.

      I also removed two variables that have collinearity; That was why I get warning message.

      You made a good point in the last paragraph. Since I am working on a longitudinal dataset, I thought it is better to see the year effects. That is why I created dummy variables for the year variables. You think should I exclude year dummies since I am not interested in a specific year?

      Thanks for all your helpful suggestions.

      Comment


      • #4
        I do not have an opinion one way or the other about whether including a year effect is a good idea for your model. I often include year effects when analyzing longitudinal data.

        What I say, though, is that if you have a categorical variable, as the survey year is for your data, you should not use that categorical variable to generate a set of dummy variables.

        Instead, you need to understand the documentation for factor variables found in help factor variables and the use factor variable notation to include the categorical variable.

        When you create separate dummy variables from the categorical variable, the margins command does not necessarily calculate the correct margins. When you use factor variable notation with the categorical variable, the margins command understands the dependency - that you cannot have both 1996 and 1998 at the same time, for example.

        In writing that I am assuming that something like this happened in your data.
        Code:
        generate yr1996 = 0
        replace yr1996 = 1 if year==1996
        ...
        generate yr2008 = 0
        replace yr2008 = 1 if year==2008
        But perhaps instead you don't have the year variable, and the dummies were created some other way. Then I would do the following.
        Code:
        generate year = 1994 // or whatever the omitted year is
        replace year = 1996 if yr1996==1
        replace year = 1998 if yr1998==1
        ...
        replace year = 2008 if yr2008==1
        And then in your model I would replace
        Code:
        i.yr1996 i.yr1998 i.yr2000 i.yr2002 i.yr2004 i.yr2006 i.yr2008
        with
        Code:
        i.year

        Comment


        • #5
          Thank you so much William. It was such a great help. I modified the code as follows:

          Code:
          cmp (rwork =xb c.age c.age#c.age  married##child18_  i.ageover62 edu#ageover62 i.job wealth i.hispanic i.black i.state i.rcovown i.year || hhidpn:) if (ragender==1 &amp; age&lt;65) , ind($cmp_probit) nolr redraws(101, anti) tech(bhhh)
          The following is the coefficient estimates:


          Code:
           
          OPG
          rwork Coef. Std. Err. z P>z [95% Conf. Interval]
          rwork
          xb 0.8666717 0.028419 30.5 0 0.8109714 0.922372
          age 0.1224267 0.1146135 1.07 0.285 -0.1022116 0.347065
          c.age#c.age -0.0022078 0.0010345 -2.13 0.033 -0.0042354 -0.0001802
          1.married 0.2400654 0.0499136 4.81 0 0.1422365 0.3378944
          1.child18_ 0.1035119 0.1895888 0.55 0.585 -0.2680753 0.475099
          married#child18_
          1 1 -0.0272955 0.2021973 -0.13 0.893 -0.423595 0.3690039
          1.ageover62 -0.5268888 0.0905282 -5.82 0 -0.7043209 -0.3494568
          edu#ageover62
          2 0 0.3831474 0.0727954 5.26 0 0.2404711 0.5258237
          2 1 0.320963 0.0991693 3.24 0.001 0.1265948 0.5153312
          3 0 -0.086873 0.0573977 -1.51 0.13 -0.1993704 0.0256244
          3 1 0.0700883 0.0849252 0.83 0.409 -0.0963621 0.2365387
          4 0 -0.0680431 0.0679089 -1 0.316 -0.2011422 0.065056
          4 1 0.1406123 0.0900331 1.56 0.118 -0.0358494 0.317074
          job
          2 0.1108659 0.0560643 1.98 0.048 0.0009819 0.22075
          3 -0.1475237 0.0517383 -2.85 0.004 -0.2489289 -0.0461185
          wealth -0.0021123 0.0027748 -0.76 0.447 -0.0075509 0.0033263
          hispanic
          1. hispanic 0.4526698 0.0708643 6.39 0 0.3137783 0.5915613
          1.black -0.0134035 0.0534898 -0.25 0.802 -0.1182416 0.0914346
          state
          2 0.0657175 0.0454804 1.44 0.148 -0.0234225 0.1548575
          3 0.0419547 0.0575397 0.73 0.466 -0.070821 0.1547304
          4 0.0758118 0.0523298 1.45 0.147 -0.0267527 0.1783763
          1.rcovown 0.7360732 0.0401823 18.32 0 0.6573172 0.8148291
          year
          1998 0.2289138 0.0673886 3.4 0.001 0.0968346 0.360993
          2000 0.1129061 0.0696542 1.62 0.105 -0.0236136 0.2494259
          2002 -0.0645129 0.0698124 -0.92 0.355 -0.2013427 0.0723169
          2004 0.2297052 0.0702801 3.27 0.001 0.0919588 0.3674516
          2006 0.2845946 0.0779164 3.65 0 0.1318811 0.437308
          2008 0.3872203 0.0793742 4.88 0 0.2316497 0.542791
          2010 0.210257 0.0785313 2.68 0.007 0.0563385 0.3641756
          _cons 3.199468 3.178929 1.01 0.314 -3.031118 9.430054
          /lnsig_1_1 0.5328122 0.0289013 18.44 0 0.4761668 0.5894576
          And the ME results (at mean) as follows:

          Code:
           
          Delta-method
          dy/dx Std. Err. z P>z [95% Conf. Interval]
          xb 0.8666717 0.028419 30.5 0 0.8109714 0.922372
          age -0.1341832 0.0090275 -14.86 0 -0.1518768 -0.1164896
          1.married 0.2369986 0.0496824 4.77 0 0.139623 0.3343742
          1.child18_ 0.0811682 0.0688989 1.18 0.239 -0.0538711 0.2162075
          1.ageover62 -0.4412286 0.0736609 -5.99 0 -0.5856013 -0.2968558
          edu
          2 0.3671642 0.0616872 5.95 0 0.2462594 0.4880689
          3 -0.0465293 0.0484321 -0.96 0.337 -0.1414545 0.0483959
          4 -0.0144125 0.0591264 -0.24 0.807 -0.1302981 0.1014731
          job
          2 0.1108659 0.0560643 1.98 0.048 0.0009819 0.22075
          3 -0.1475237 0.0517383 -2.85 0.004 -0.2489289 -0.0461185
          wealth -0.0021123 0.0027748 -0.76 0.447 -0.0075509 0.0033263
          hispanic
          1. hispanic 0.4526698 0.0708643 6.39 0 0.3137783 0.5915613
          1.black -0.0134035 0.0534898 -0.25 0.802 -0.1182416 0.0914346
          state
          2 0.0657175 0.0454804 1.44 0.148 -0.0234225 0.1548575
          3 0.0419547 0.0575397 0.73 0.466 -0.070821 0.1547304
          4 0.0758118 0.0523298 1.45 0.147 -0.0267527 0.1783763
          1.rcovown 0.7360732 0.0401823 18.32 0 0.6573172 0.8148291
          year
          1998 0.2289138 0.0673886 3.4 0.001 0.0968346 0.360993
          2000 0.1129061 0.0696542 1.62 0.105 -0.0236136 0.2494259
          2002 -0.0645129 0.0698124 -0.92 0.355 -0.2013427 0.0723169
          2004 0.2297052 0.0702801 3.27 0.001 0.0919588 0.3674516
          2006 0.2845946 0.0779164 3.65 0 0.1318811 0.437308
          2008 0.3872203 0.0793742 4.88 0 0.2316497 0.542791
          2010 0.210257 0.0785313 2.68 0.007 0.0563385 0.3641756
          Now my questions are:
          1. why is the sign of age is negative in ME and positive in the original estimate?
          2. I know we do not have age squared in the marginal effect output because it is interaction term. But my problem is when I just include age in the regression, the sign of age is negative and when I include both age and age squared variables , the sign of age turns to be positive and sign of age square is negative. Now, when we include both variables and want to see the marginal effects, the sign of age is again negative. I don't know how to interpret this result. Should I look at the sign of age in the original coefficient or just interpret marginal effect sign?

          sorry for the vary long question.

          Many thanks.

          Comment


          • #6
            I know we do not have age squared in the marginal effect output because it is interaction term.
            Not so. What I think you misunderstand is that the marginal effect of age represents the contribution of both age and age squared.

            Think about taking the derivative with respect to age: it doesn't ignore the age squared term. This is really the continuous equivalent of the categorical comment I made earlier: you can't change age from 20 to 30 without simultaneously changing age squared from 400 to 900.

            This is the power of the margins command when combined with properly applied factor variable notation: the factor variable notation tells the margins command how the coefficients are related to each other, and margins then takes that relationship into account.

            What cmp is telling you is that the effect of age will be positive, but decreasingly so as age increases, up to age 28, when the effect becomes negative and increasingly so as age continues to increase. To see this, just evaluate 0.1224*age - 0.0022*age*age at various values, or take the derivative and solve for zero to find the point of inflection.

            What margins is telling you is that at the mean value of age, its marginal effect is negative.

            Comment


            • #7
              Dear all,

              I encounter a similar problem when I estimate a simultaneous equation with cmp as follows:

              Code:
              cmp(finance_ = i.sector i.szone log_age i.foreign_origin ib4.total_employed2_ tfp_cob1 i.loan_ever innovator_#) ///
                      (innovator_= i.sector i.szone finance_# log_age i.international_ ///
                      log_training_per_employee_ i.foreign_origin ib4.total_employed2_ ///
                      sources tfp_cob1 i.RnD_) if innovator_ally==1 & h22_G!=1, ///
                      indicators ($cmp_probit $cmp_probit)
              The variables of interest are Finance_ and innovator_ (both dummy variables)

              the margins command:

              Code:
              margins, dydx(*) predict(pr equation(innovator_)) force
              the codes run through, however, after running the margins command I receive an output table that is (almost) completetly empty:

              Code:
              Average marginal effects                        Number of obs     =        590
              Model VCE    : OIM
              
              Expression   : Pr(innovator_), predict(pr equation(innovator_))
              dy/dx w.r.t. : 2.sector 3.sector 4.sector 5.sector 6.sector 7.sector 8.sector 9.sector 10.sector 11.sector 12.sector 13.sector 14.sector
                             15.sector 16.sector 18.sector 19.sector 20.sector 21.sector 22.sector 23.sector 24.sector 25.sector 26.sector 28.sector
                             29.sector 30.sector 31.sector 33.sector 34.sector 2.szone 3.szone 4.szone 5.szone log_age 1.foreign_origin
                             1.total_employed2_ 2.total_employed2_ 3.total_employed2_ tfp_cob1_ 1.loan_ever 1.international_ log_training_per_employee_
                             sources 1.RnD_
              
              ---------------------------------------------------------------------------------------------------------------------------------
                                                                              |            Delta-method
                                                                              |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
              ----------------------------------------------------------------+----------------------------------------------------------------
                                                                       sector |
                                                                    Textiles  |          .  (not estimable)
                                                                    Garments  |          .  (not estimable)
                                                                     Leather  |          .  (not estimable)
                                                                        Wood  |          .  (not estimable)
                                                                       Paper  |          .  (not estimable)
                                    Publishing, priniting and Recorded Media  |          .  (not estimable)
                                                   Refined Petroleum Product  |          .  (not estimable)
                                                                   Chemicals  |          .  (not estimable)
                                                         Plastics and Rubber  |          .  (not estimable)
                                               Non-Metallic Mineral Products  |          .  (not estimable)
                                                                Basic Metals  |          .  (not estimable)
                                                   Fabricated Metal Products  |          .  (not estimable)
                                                     Machinery and Equipment  |          .  (not estimable)
                                            Office, Accounting and Computing  |          .  (not estimable)
                                          Electrical Machinery and Apparatus  |          .  (not estimable)
                                                   Other Transport Equipment  |          .  (not estimable)
                                                                   Furniture  |          .  (not estimable)
                                                                   Recycling  |          .  (not estimable)
                                                        Construction Section  |          .  (not estimable)
                                                  Services of Motor Vehicles  |          .  (not estimable)
                                                                   Wholesale  |          .  (not estimable)
                                                                      Retail  |          .  (not estimable)
                                                       Hotel and Restaurants  |          .  (not estimable)
                                                             Water Transport  |          .  (not estimable)
                               Supporting and Auxiliary Transport Activities  |          .  (not estimable)
                                                  Post and Telecommunication  |          .  (not estimable)
              Financial intermediation, except insurance and pension funding  |          .  (not estimable)
                            Activities auxiliary to financial intermediation  |          .  (not estimable)
                                             Computer and related activities  |          .  (not estimable)
                                                      Health and social work  |          .  (not estimable)
                                                                              |
                                                                        szone |
                                                              2. Ashanti /BA  |          .  (not estimable)
                                                          3. Central/Western  |          .  (not estimable)
                                                            4. Eastern/Volta  |          .  (not estimable)
                                                                     5. Tema  |          .  (not estimable)
                                                                              |
                                                                      log_age |          0  (omitted)
                                                             1.foreign_origin |          .  (not estimable)
                                                                              |
                                                             total_employed2_ |
                                                                 Micro (0-4)  |          .  (not estimable)
                                                                Small (5-19)  |          .  (not estimable)
                                                              Medium (20-49)  |          .  (not estimable)
                                                                              |
                                                                    tfp_cob1_ |          0  (omitted)
                                                                  1.loan_ever |  -.0387465          .        .       .            .           .
                                                             1.international_ |          .  (not estimable)
                                                   log_training_per_employee_ |          0  (omitted)
                                                                      sources |          0  (omitted)
                                                                       1.RnD_ |          .  (not estimable)
              ---------------------------------------------------------------------------------------------------------------------------------
              Note: dy/dx for factor levels is the discrete change from the base level.
              also my variable of interest finance is not displayed.

              Somebody who has an idea what is going on?

              Comment


              • #8
                Hello Anna,

                I am encountering a similar issue as you have described above - "marginal effects not estimable". Have you figured out a solution for this? If so, could you please let me know?
                Thanks!

                Comment

                Working...
                X