Announcement

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

  • marginal effects in biprobit: default prediction is a function of possibly stochastic quantities other than e(b)

    Dear Statlist' users:

    I get the message of the topic after try to obtained marginal effects in a biprobit regression. I try the fixedonly option that I saw in one related about probabilities with random effects (http://stats.idre.ucla.edu/stata/faq...-in-xtmelogit/), but the new message says: "option fixedonly not allowed".

    Any suggestion??

    Thanks a lot for your time

  • #2
    From section 12 in the FAQ:

    Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!

    Comment


    • #3
      Thanks @Friedrich Huebler. Here is my command line and the response of Stata 14

      . margins, dydx(*) atmeans predict (equation(name_equation1))
      default prediction is a function of possibly stochastic quantities other than e(b)

      . margins, dydx(*) atmeans predict (equation(name_equation1) fixedonly)
      option fixedonly not allowed
      Last edited by castro rene; 25 Apr 2017, 12:30.

      Comment


      • #4
        The documentation on the UCLA page may not be current. According to that page, the commands below lead to the first error message in your last post.
        Code:
        use http://www.ats.ucla.edu/stat/data/hsbdemo, clear
        xtmelogit honors i.female read || cid:
        margins female, at(read=(30(10)70)) vsquish
        However, if you run these commands in Stata 14.2, there is no error message. The output of the second command with fixedonly is different from the output on the UCLA page (the formatting, not the results).

        Comment


        • #5
          Originally posted by castro rene View Post
          Here is my command line and the response of Stata 14

          . margins, dydx(*) atmeans predict (equation(name_equation1))
          default prediction is a function of possibly stochastic quantities other than e(b)
          I don't replicate your problem. I don't get any error after biprobit and the margins syntax that you show.

          .ÿversionÿ14.2

          .ÿ
          .ÿclearÿ*

          .ÿsetÿmoreÿoff

          .ÿ
          .ÿwebuseÿschool

          .ÿbiprobitÿprivateÿvoteÿlogptaxÿlogincÿyears,ÿnolog

          BivariateÿprobitÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ95
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(6)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ9.59
          Logÿlikelihoodÿ=ÿ-89.254028ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.1431

          ------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
          -------------+----------------------------------------------------------------
          privateÿÿÿÿÿÿ|
          ÿÿÿÿÿlogptaxÿ|ÿÿ-.1066962ÿÿÿ.6669782ÿÿÿÿ-0.16ÿÿÿ0.873ÿÿÿÿ-1.413949ÿÿÿÿ1.200557
          ÿÿÿÿÿÿlogincÿ|ÿÿÿ.3762037ÿÿÿ.5306484ÿÿÿÿÿ0.71ÿÿÿ0.478ÿÿÿÿÿ-.663848ÿÿÿÿ1.416255
          ÿÿÿÿÿÿÿyearsÿ|ÿÿ-.0118884ÿÿÿ.0256778ÿÿÿÿ-0.46ÿÿÿ0.643ÿÿÿÿ-.0622159ÿÿÿÿ.0384391
          ÿÿÿÿÿÿÿ_consÿ|ÿÿ-4.184694ÿÿÿ4.837817ÿÿÿÿ-0.86ÿÿÿ0.387ÿÿÿÿ-13.66664ÿÿÿÿ5.297253
          -------------+----------------------------------------------------------------
          voteÿÿÿÿÿÿÿÿÿ|
          ÿÿÿÿÿlogptaxÿ|ÿÿ-1.288707ÿÿÿ.5752266ÿÿÿÿ-2.24ÿÿÿ0.025ÿÿÿÿ-2.416131ÿÿÿ-.1612839
          ÿÿÿÿÿÿlogincÿ|ÿÿÿÿ.998286ÿÿÿ.4403565ÿÿÿÿÿ2.27ÿÿÿ0.023ÿÿÿÿÿ.1352031ÿÿÿÿ1.861369
          ÿÿÿÿÿÿÿyearsÿ|ÿÿ-.0168561ÿÿÿ.0147834ÿÿÿÿ-1.14ÿÿÿ0.254ÿÿÿÿ-.0458309ÿÿÿÿ.0121188
          ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.5360573ÿÿÿ4.068509ÿÿÿÿ-0.13ÿÿÿ0.895ÿÿÿÿ-8.510188ÿÿÿÿ7.438073
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿ/athrhoÿ|ÿÿ-.2764525ÿÿÿ.2412099ÿÿÿÿ-1.15ÿÿÿ0.252ÿÿÿÿ-.7492153ÿÿÿÿ.1963102
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿrhoÿ|ÿÿ-.2696186ÿÿÿ.2236753ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-.6346806ÿÿÿÿ.1938267
          ------------------------------------------------------------------------------
          LRÿtestÿofÿrho=0:ÿchi2(1)ÿ=ÿ1.38444ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿ0.2393

          .ÿ
          .ÿmargins,ÿdydx(*)ÿatmeansÿpredictÿ(equation(private))

          ConditionalÿmarginalÿeffectsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ95
          ModelÿVCEÿÿÿÿ:ÿOIM

          Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict(equation(private))
          dy/dxÿw.r.t.ÿ:ÿlogptaxÿlogincÿyears
          atÿÿÿÿÿÿÿÿÿÿÿ:ÿlogptaxÿÿÿÿÿÿÿÿÿ=ÿÿÿÿ6.939496ÿ(mean)
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿlogincÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿ9.971017ÿ(mean)
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿyearsÿÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿ8.515789ÿ(mean)

          ------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
          ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿdy/dxÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿlogptaxÿ|ÿÿ-.1066962ÿÿÿ.6669782ÿÿÿÿ-0.16ÿÿÿ0.873ÿÿÿÿ-1.413949ÿÿÿÿ1.200557
          ÿÿÿÿÿÿlogincÿ|ÿÿÿ.3762037ÿÿÿ.5306484ÿÿÿÿÿ0.71ÿÿÿ0.478ÿÿÿÿÿ-.663848ÿÿÿÿ1.416255
          ÿÿÿÿÿÿÿyearsÿ|ÿÿ-.0118884ÿÿÿ.0256778ÿÿÿÿ-0.46ÿÿÿ0.643ÿÿÿÿ-.0622159ÿÿÿÿ.0384391
          ------------------------------------------------------------------------------

          .ÿ
          .ÿexit

          endÿofÿdo-file


          .


          As to fixedonly, I don't see it as an available option for margins when I go to
          Code:
          help biprobit_postestimation
          and click the options hyperlink on the command's syntax line.

          Comment


          • #6
            According to #4 and #5 ... I had to conclude that the problem is my data set???

            The lines of interest in the the UCLA post are:


            . margins female, at(read=(30(10)70)) vsquish
            default prediction is a function of possibly stochastic quantities other than e(b) r(498);
            That didn’t work because margins can’t compute predicted values for models that have both fixed and random components.

            We can, however, get the predicted probabilities from just the fixed part of the model, like this.

            margins female, at(read=(30(10)70)) predict(mu fixedonly) vsquish
            That example is for predict probabilities, but in my case I want to estimate marginal effects. There is no form to calculate these last only for the fixed part of the model as the example shows??
            Last edited by castro rene; 26 Apr 2017, 08:58.

            Comment


            • #7
              Which version of Stata do you use? Joseph and I wrote that the margins command on the UCLA page causes no error message in Stata 14. The same command results in an error in Stata 13. Below is output from Stata versions 13.1 and 14.2 for the same commands.
              Code:
              . version
              version 13.1
              
              . use http://www.ats.ucla.edu/stat/data/hsbdemo, clear
              (highschool and beyond (200 cases))
              
              . xtmelogit honors i.female read || cid:
              [output omitted]
              
              . margins female, at(read=(30(10)70)) vsquish
              default prediction is a function of possibly stochastic quantities other than e(b)
              r(498);
              Code:
              . version
              version 14.2
              
              . use http://www.ats.ucla.edu/stat/data/hsbdemo, clear
              (highschool and beyond (200 cases))
              
              . xtmelogit honors i.female read || cid:
              [output omitted]
              
              . margins female, at(read=(30(10)70)) vsquish
              
              Adjusted predictions                            Number of obs     =        200
              
              Expression   : Linear prediction, fixed portion, predict(xb)
              1._at        : read            =          30
              2._at        : read            =          40
              3._at        : read            =          50
              4._at        : read            =          60
              5._at        : read            =          70
              
              ------------------------------------------------------------------------------
                           |            Delta-method
                           |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                _at#female |
                   1#male  |  -3.548549   1.301111    -2.73   0.006     -6.09868   -.9984181
                 1#female  |  -2.344865   1.260359    -1.86   0.063    -4.815122     .125393
                   2#male  |  -3.122162   .8710246    -3.58   0.000    -4.829339   -1.414985
                 2#female  |  -1.918477   .8065514    -2.38   0.017    -3.499289   -.3376656
                   3#male  |  -2.695775   .7039332    -3.83   0.000    -4.075458   -1.316091
                 3#female  |   -1.49209   .6193473    -2.41   0.016    -2.705989   -.2781917
                   4#male  |  -2.269388   .9504759    -2.39   0.017    -4.132286   -.4064889
                 4#female  |  -1.065703   .8875254    -1.20   0.230    -2.805221     .673815
                   5#male  |     -1.843   1.407953    -1.31   0.191    -4.602537    .9165367
                 5#female  |  -.6393157   1.364865    -0.47   0.639    -3.314402     2.03577
              ------------------------------------------------------------------------------

              Comment


              • #8
                The example of UCLA page is for predict probabilities, in my case I want to estimate marginal effects but I obtain the same error message of Stata (version 14).

                There is no form to calculate marginal effects only for the fixed part of the model as the example shows for the case of predict probabilities??

                Comment


                • #9
                  Originally posted by castro rene View Post
                  in my case I want to estimate marginal effects but I obtain the same error message of Stata (version 14).
                  Again, what you show above in #3 does not give any error after biprobit. I show reproducible results from code and data that prove this. Why don't you follow the FAQ and show a reproducible example of code and data that give the error message that you claim?

                  Comment


                  • #10
                    In #6 it is stated: "That example is for predict probabilities, but in my case I want to estimate marginal effects." I would push this further and ask: "Marginal effects of what quantity on what quantity?" Without specific statements about both of these quantities, it would seem to me the question is either ill-posed or not fully posed.

                    It's hard to imagine well-posed questions here where the latter quantity is not either a joint, a marginal, or a conditional probability (conditional on x's), but this is not my research project.

                    Comment


                    • #11
                      I would say in a large percentage of cases one should want the average treatment effect (or average causal effect). If y1 is the binary response of interest and y2 is the binary endogenous variable, and z1 the subset of exogenous variables in the model for y1, then the population effect is

                      E[PHI(z1*b1 + a1) - PHI(z1*b1)]

                      where a1 is the coefficient on y2 in the biprobit. Replace the coefficients with the MLEs and the E[.] with the sample average and you have it. I've never successfully gotten Stata to report this, so I do it "by hand" and bootstrap. Run time can be an issue, as can be convergence for certain bootstrap samples.

                      Below is a short program I used to generate Table 15.2 in the 2e of my MIT Press Book (2010).

                      Code:
                      use c:\mitbook1_2e\statafiles\labsup, clear
                      
                      capture program drop bivprobit_boot
                      
                      program bivprobit_boot, rclass
                      
                      biprobit (worked = morekids nonmomi educ age agesq black hispan) (morekids = samesex nonmomi educ age agesq black hispan)
                      
                      predict x1b1hat, xb1
                      gen x1b1hat0 = x1b1hat - _b[morekids]*morekids
                      gen x1b1hat1 = x1b1hat0 + _b[morekids]
                      gen pe1 = normal(x1b1hat1) - normal(x1b1hat0)
                      summarize pe1
                      return scalar ape1 = r(mean)
                      
                      drop x1b1hat x1b1hat0 x1b1hat1 pe1
                      end
                      
                      bootstrap r(ape1), reps(50) seed(123): bivprobit_boot
                      
                      program drop bivprobit_boot
                      
                      ivregress 2sls worked (morekids = samesex) nonmomi educ age agesq black hispan, robust

                      Comment


                      • #12
                        Dear Jeff!

                        A short follow-up question on your post: after having run your bootstrap code given above in several biprobit models for a problem similar to the hypothetical problem you formulated above, the average partial effects for y2 in my biprobit sometimes have a completely different i) direction and ii) stat. significance level than the "normal" coefficients on y2 in the biprobit regression.

                        I can imagine that ii) is also a matter of the # of reps(50) in the bootstrap. But I do not understand why the direction of the average partial effect for y2 and the "normal" coefficients on y2 differ so substantially. Do you have any intuition for that?

                        I would be very happy to know your answer!

                        Best,

                        Johanna
                        Last edited by jomike; 05 Jun 2019, 09:37.

                        Comment


                        • #13
                          Friedrich Huebler I get the same error with stata 12. Is there any fix to this?

                          Comment


                          • #14
                            If anyone is still looking for a solution, using the -force- option avoids the error, at least in Stata 12.

                            Comment


                            • #15
                              Quick note for those finding that Prof. Wooldridge's code above solves their problem to compute the ATE and its std. error: the solution does not require bootstrapping (anymore; perhaps it did at the time the original post was written). Using the post and at options to margins, one can estimate the ATE after biprobit simply as follows:
                              Code:
                              bcuse labsup
                              biprobit (worked = morekids nonmomi educ age agesq black hispan) (morekids = samesex nonmomi educ age agesq black hispan)
                              margins, at(morekids=(0,1)) predict(pmarg1) post
                              lincom _b[2._at] - _b[1._at]
                              A similar procedure can be used to compute ATET:
                              Code:
                              biprobit (worked = morekids nonmomi educ age agesq black hispan) (morekids = samesex nonmomi educ age agesq black hispan)
                              margins, at(morekids=(0 1)) predict(pcond1) subpop(morekids)  post
                              lincom _b[2._at] - _b[1._at]

                              Comment

                              Working...
                              X