Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: error in logistic regression when fitting models


From   [email protected]
To   [email protected]
Subject   st: error in logistic regression when fitting models
Date   Sun, 06 Feb 2005 19:47:22 -0500

I am using logistic regression with Stata 8.1 to build models for prediction of infection risk.   Stata runs the full model. Then, by removing variables (using p<0.2), I create new models, step by step.   However, at some moment, after to run the "lrtest" command (in order to fitting both unconstrained and constrained models), Stata accuses an error (number 498) informing that the two last models have different observation numbers. What I have to do? In order to outline this trouble, can you propose me some procedure? It follows a sequence of commands that I am executing and the problem that occurs.    

Thank you for your attention. 


. xi: logistic SSI i.asa i.contamin i.tipoproc  i.hospital
i.asa             _Iasa_1-5           (naturally coded; _Iasa_1 omitted)
i.contamin        _Icontamin_0-3      (naturally coded; _Icontamin_0 omitted)
i.tipoproc        _Itipoproc_1-6      (naturally coded; _Itipoproc_1 omitted)
i.hospital        _Ihospital_0-3      (naturally coded; _Ihospital_0 omitted)

note: _Iasa_5 != 0 predicts failure perfectly
      _Iasa_5 dropped and 6 obs not used


Logistic regression                Number of obs   =      15598
                                   LR chi2(14)     =     123.64
                                   Prob > chi2     =     0.0000
Log likelihood = -1321.2285        Pseudo R2       =     0.0447

------------------------------------------------------------------------------
         SSI | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     _Iasa_2 |   1.839743   .2726782     4.11   0.000     1.375929    2.459904
     _Iasa_3 |   2.641727   .5935354     4.32   0.000     1.700758    4.103301
     _Iasa_4 |   5.018927   2.237225     3.62   0.000     2.094987    12.02376
_Icontamin_1 |   2.754058   .6174202     4.52   0.000     1.774785    4.273662
_Icontamin_2 |    2.45464   .7546035     2.92   0.003     1.343731    4.483979
_Icontamin_3 |   2.388642   .4140681     5.02   0.000     1.700577    3.355102
_Itipoproc_2 |    .816091   .1483117    -1.12   0.263     .5715393    1.165282
_Itipoproc_3 |   .6787481   .1156558    -2.27   0.023      .486035    .9478721
_Itipoproc_4 |   1.691569   .9121878     0.97   0.330     .5878608    4.867487
_Itipoproc_5 |   1.028615   .7799252     0.04   0.970     .2327272    4.546301
_Itipoproc_6 |   1.405621   .4098281     1.17   0.243     .7937589    2.489131
_Ihospital_1 |   3.219921   .5403076     6.97   0.000     2.317461    4.473816
_Ihospital_2 |   1.494106   .4641423     1.29   0.196     .8127495    2.746668
_Ihospital_3 |   1.400152   .3519224     1.34   0.181     .8555183    2.291507
------------------------------------------------------------------------------

. 
. est store  A

. xi: logistic SSI i.asa i.contamin  i.hospital
i.asa             _Iasa_1-5           (naturally coded; _Iasa_1 omitted)
i.contamin        _Icontamin_0-3      (naturally coded; _Icontamin_0 omitted)
i.hospital        _Ihospital_0-3      (naturally coded; _Ihospital_0 omitted)

note: _Iasa_5 != 0 predicts failure perfectly
      _Iasa_5 dropped and 6 obs not used


Logistic regression                Number of obs   =      15598
                                   LR chi2(9)      =     112.56
                                   Prob > chi2     =     0.0000
Log likelihood = -1326.7664         Pseudo R2       =     0.0407

------------------------------------------------------------------------------
         SSI | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     _Iasa_2 |   1.950508   .2825339     4.61   0.000     1.468419    2.590869
     _Iasa_3 |   2.848565   .6285031     4.74   0.000     1.848495    4.389691
     _Iasa_4 |   5.253982   2.336339     3.73   0.000     2.197742    12.56032
_Icontamin_1 |   2.368768   .5142391     3.97   0.000     1.547869    3.625026
_Icontamin_2 |   2.056736   .6144001     2.41   0.016     1.145256    3.693639
_Icontamin_3 |   2.253248   .3874762     4.72   0.000     1.608546    3.156345
_Ihospital_1 |    3.07799     .49221     7.03   0.000     2.249827       4.211
_Ihospital_2 |   1.507275   .4500532     1.37   0.169     .8395266    2.706142
_Ihospital_3 |    1.42888   .3572277     1.43   0.153     .8753683    2.332388
------------------------------------------------------------------------------

. est store B

. lrtest A

likelihood-ratio test                   LR chi2(5)  =     11.08
(Assumption: B nested in A)             Prob > chi2 =    0.0499

. xi: logistic SSI i.contamin i.tipoproc  i.hospital
i.contamin        _Icontamin_0-3      (naturally coded; _Icontamin_0 omitted)
i.tipoproc        _Itipoproc_1-6      (naturally coded; _Itipoproc_1 omitted)
i.hospital        _Ihospital_0-3      (naturally coded; _Ihospital_0 omitted)

Logistic regression                Number of obs   =      16691
                                   LR chi2(11)     =     101.28
                                   Prob > chi2     =     0.0000
Log likelihood = -1412.1228        Pseudo R2       =     0.0346

------------------------------------------------------------------------------
         SSI | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Icontamin_1 |   3.122458   .6640611     5.35   0.000     2.058114    4.737223
_Icontamin_2 |    3.30561   .9319622     4.24   0.000     1.902258    5.744256
_Icontamin_3 |   2.351759   .4032836     4.99   0.000     1.680457     3.29123
_Itipoproc_2 |    .825048   .1466932    -1.08   0.279     .5822855    1.169021
_Itipoproc_3 |   .7140786   .1181442    -2.04   0.042     .5163152    .9875911
_Itipoproc_4 |   2.022546   1.079306     1.32   0.187     .7106657    5.756141
_Itipoproc_5 |   1.626439   1.024312     0.77   0.440      .473327    5.588748
_Itipoproc_6 |   1.948691   .5424795     2.40   0.017     1.129235    3.362805
_Ihospital_1 |   2.447753   .3706389     5.91   0.000     1.819192    3.293491
_Ihospital_2 |   1.494092   .4273867     1.40   0.160     .8528848    2.617366
_Ihospital_3 |   1.070275   .2613432     0.28   0.781     .6632027    1.727208
------------------------------------------------------------------------------

. est store C

. lrtest A
observations differ: 15598 vs. 16691
r(498);


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index