Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Error message with predictnl


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Error message with predictnl
Date   Wed, 8 Jun 2011 19:16:44 +0100

Please study the following example:

. sysuse auto 

. regress mpg i.foreign

      Source |       SS       df       MS              Number of obs =      74
-------------+------------------------------           F(  1,    72) =   13.18
       Model |  378.153515     1  378.153515           Prob > F      =  0.0005
    Residual |  2065.30594    72  28.6848048           R-squared     =  0.1548
-------------+------------------------------           Adj R-squared =  0.1430
       Total |  2443.45946    73  33.4720474           Root MSE      =  5.3558

------------------------------------------------------------------------------
         mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   1.foreign |   4.945804   1.362162     3.63   0.001     2.230384    7.661225
       _cons |   19.82692   .7427186    26.70   0.000     18.34634    21.30751
------------------------------------------------------------------------------

. di _b[foreign]
[foreign] not found
r(111);

. di _b[1.foreign]
4.9458042

Similarly, in your analysis, -childfemale- appears in the guise of -1.childfemale-. Thus after model fitting there is no _b[childfemale] to refer to, but rather _b[1.childfemale]-. 

Nick 
[email protected] 

Urmi Bhattacharya

I am running a logit model and I want to use the predictnl command to
get the predicted probabilities, the marginal effect of interaction of
two variables and so on along with the standard errors.

I do the following


logit school_left childage i.childfemale i.urban i.scstobc
i.casteother i.dadp i.dadm i.momp i.momm wagep wage5 wage8 wage9 distp
distm disth percapcons durat1 durat2 durat3 durat4 durat5 durat6
durat7 durat8 durat9 durat10 durat11, nocons nolog


Logistic regression                               Number of obs   =      47569
                                                                Wald
chi2(28)   =   14601.42
Log likelihood = -14502.393                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
 school_left |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    childage |  -.1413654    .006069   -23.29   0.000    -.1532605   -.1294703
1.childfem~e |   .0212387   .0306462     0.69   0.488    -.0388266    .0813041
     1.urban |   .0124911   .0368072     0.34   0.734    -.0596497    .0846319
   1.scstobc |   1.972676   .1234074    15.99   0.000     1.730802     2.21455
1.casteother |   1.883233    .125722    14.98   0.000     1.636822    2.129643
      1.dadp |    .680585    .044327    15.35   0.000     .5937057    .7674643
      1.dadm |   .3872552   .0506982     7.64   0.000     .2878886    .4866217
      1.momp |   1.351053   .0835161    16.18   0.000     1.187364    1.514741
      1.momm |   .9494066   .0918146    10.34   0.000     .7694532     1.12936
       wagep |  -.0281962   .0061845    -4.56   0.000    -.0403176   -.0160748
       wage5 |  -.0040992   .0045604    -0.90   0.369    -.0130373     .004839
       wage8 |    .021027   .0043869     4.79   0.000     .0124289    .0296251
       wage9 |   .0159427   .0022335     7.14   0.000     .0115652    .0203203
       distp |  -.0355589   .0162329    -2.19   0.028    -.0673748   -.0037431
       distm |  -.0024083   .0112658    -0.21   0.831    -.0244888    .0196722
       disth |   .0186932   .0039384     4.75   0.000      .010974    .0264124
  percapcons |  -.0001459   .0000278    -5.26   0.000    -.0002003   -.0000915
      durat1 |  -5.771466   .1406919   -41.02   0.000    -6.047217   -5.495715
      durat2 |  -4.947835   .1222363   -40.48   0.000    -5.187414   -4.708256
      durat3 |  -4.690019   .1193602   -39.29   0.000    -4.923961   -4.456078
      durat4 |  -4.054464   .1132586   -35.80   0.000    -4.276447   -3.832481
      durat5 |  -3.055883   .1082449   -28.23   0.000    -3.268039   -2.843727
      durat6 |  -3.560284   .1130896   -31.48   0.000    -3.781936   -3.338633
      durat7 |  -2.825943   .1099477   -25.70   0.000    -3.041436   -2.610449
      durat8 |  -2.238741   .1094063   -20.46   0.000    -2.453173   -2.024308
      durat9 |  -1.427979   .1099217   -12.99   0.000    -1.643421   -1.212536
     durat10 |  -.3967904   .1152271    -3.44   0.001    -.6226313   -.1709495
     durat11 |  -2.168164   .1486318   -14.59   0.000    -2.459477   -1.876851
------------------------------------------------------------------------------

Then I do

predictnl p_hat = (1+exp((-1)*(_b[childage]*childage
+_b[childfemale]*childfemale +_b[urban]*urban +_b[scstobc]*scstobc
+_b[casteother]*casteother +_b[dadp]*dadp +_b[dadm]*dadm
+_b[momp]*momp+ _b[momm]*momm+ _b[wagep]*wagep +_b[wage5]*wage5
+_b[wage8]*wage8 +_b[wage9]*wage9 +_b[distp]*distp +_b[distm]*distm
+_b[disth]*disth +_b[percapcons]*percapcons +_b[durat1]*durat1
+_b[durat2]*durat2
+_b[durat3]*durat3+_b[durat4]*durat4+_b[durat5]*durat5+_b[durat6]*durat6+_b[durat7]*durat7+_b[durat8]*durat8+_b[durat9]*durat9+_b[durat10]*durat10+_b[durat11]*durat11)))^-1,se(p_hat_se)

I get the error message saying
[childfemale] not found
r(111);

I am confused as to why I am getting this error message. 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index