Download presentation

Presentation is loading. Please wait.

Published byHamza Stickler Modified about 1 year ago

1
1 Problems with infinite solutions in logistic regression Ian White MRC Biostatistics Unit, Cambridge UK Stata Users’ Group London, 12th September 2006

2
2 Introduction I teach logistic regression for the analysis of case-control studies to Epidemiology Master’s students, using Stata I stress how to work out degrees of freedom –e.g. if E has 2 levels and M has 4 levels then you get 3 d.f. for testing the E*M interaction Our practical uses data on 244 cases of leprosy and 1027 controls –previous BCG vaccination is the exposure of interest –level of schooling is a possible effect modifier –in what follows I’m ignoring other confounders

3
3 Leprosy data -> tabulation of d outcome 0=control, | 1=case | Freq. Percent Cum | 1, | Total | 1, > tabulation of bcg exposure BCG scar | Freq. Percent Cum Absent | Present | Total | 1, > tabulation of school possible effect modifier Schooling | Freq. Percent Cum | | | | Total | 1,

4
4 Main effects model. xi: logistic d i.bcg i.school i.bcg _Ibcg_0-1 (naturally coded; _Ibcg_0 omitted) i.school _Ischool_0-3 (naturally coded; _Ischool_0 omitted) Logistic regression Number of obs = 1271 LR chi2(4) = Prob > chi2 = Log likelihood = Pseudo R2 = d | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] _Ibcg_1 | _Ischool_1 | _Ischool_2 | _Ischool_3 | estimates store main

5
5 Interaction model. xi: logistic d i.bcg*i.school i.bcg _Ibcg_0-1 (naturally coded; _Ibcg_0 omitted) i.school _Ischool_0-3 (naturally coded; _Ischool_0 omitted) i.bcg*i.school _IbcgXsch_#_# (coded as above) Logistic regression Number of obs = 1271 LR chi2(7) = Prob > chi2 = Log likelihood = Pseudo R2 = d | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] _Ibcg_1 | _Ischool_1 | _Ischool_2 | _Ischool_3 | 1.28e e e e-07 _IbcgXsch_~1 | _IbcgXsch_~2 | _IbcgXsch_~3 | 4.25e Note: 17 failures and 0 successes completely determined.. estimates store inter

6
6 The problem. table bcg school, by(d) =control |, 1=case | and BCG | Schooling scar | | Absent | Present | | Absent | Present |

7
7 LR test. xi: logistic d i.bcg i.school LR chi2(4) = Log likelihood = estimates store main. xi: logistic d i.bcg*i.school LR chi2(7) = Log likelihood = estimates store inter. lrtest main inter Likelihood-ratio test LR chi2(2) = 3.92 (Assumption: main nested in inter) Prob > chi2 =

8
8 What is Stata doing? (guess) Recognises the information matrix is singular Hence reduces model df by 1 In other situations Stata drops observations –if a single variable perfectly predicts success/failure –this happens if the problematic cell doesn’t occur in a reference category –then Stata refuses to perform lrtest, but we can force it to do so –Stata still gets df=2; can use df(3) option

9
9. gen bcgrev=1-bcg. xi: logistic d i.bcgrev*i.school i.bcgrev _Ibcgrev_0-1 (naturally coded; _Ibcgrev_0 omitted) i.school _Ischool_0-3 (naturally coded; _Ischool_0 omitted) i.bcg~v*i.sch~l _IbcgXsch_#_# (coded as above) note: _IbcgXsch_1_3 != 0 predicts failure perfectly _IbcgXsch_1_3 dropped and 17 obs not used Logistic regression Number of obs = 1254 LR chi2(6) = Prob > chi2 = Log likelihood = Pseudo R2 = d | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] _Ibcgrev_1 | _Ischool_1 | _Ischool_2 | _Ischool_3 | _IbcgXsch_~1 | _IbcgXsch_~2 | est store interrev. lrtest interrev main observations differ: 1254 vs r(498);. lrtest interrev main, force Likelihood-ratio test LR chi2(2) = 3.92 (Assumption: main nested in interrev) Prob > chi2 =

10
10 What’s right? Zero cell suggests small sample so asymptotic 2 distribution may be inappropriate for LRT –true in this case: have a bcg*school category with only 1 observation –but I’m going to demonstrate the same problem in hypothetical example with expected cell counts > 3 but a zero observed cell count Could combine or drop cells to get rid of zeroes –but the cell with zeroes may carry information Problems with testing boundary values are well known –e.g. LRT for testing zero variance component isn’t 2 1 –but here the point estimate, not the null value, is on the boundary

11
11 Example to explain why LRT makes some sense. tab x y, chi2 exact | y x | 0 1 | Total | | 30 1 | 0 10 | Total | | 40 Pearson chi2(1) = Pr = Fisher's exact = sided Fisher's exact = 0.035

12
12 Model: logit P(y=1|x) = + x Difference in log lik = 3.4 LRT = 6.8 on 0 df?

13
13 Example to explore correct df using Pearson / Fisher as gold standard. tab x y, chi2 exact | y x | 0 1 | Total | 6 0 | 6 2 | 3 6 | 9 3 | 3 6 | Total | | 24 Pearson chi2(2) = Pr = Fisher's exact = All expected counts ≥3 Don’t want to drop or merge category 1 - contains the evidence for association!

14
14. xi: logistic y i.x i.x _Ix_1-3 (naturally coded; _Ix_1 omitted) Logistic regression Number of obs = 24 LR chi2(2) = Prob > chi2 = Log likelihood = Pseudo R2 = y | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] _Ix_2 | 1.61e e e e+09 _Ix_3 | 1.61e Note: 6 failures and 0 successes completely determined.. est store x. xi: logistic y Logistic regression Number of obs = 24 LR chi2(0) = 0.00 Prob > chi2 =. Log likelihood = Pseudo R2 = y | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] est store null

15
15 LRT. xi: logistic y i.x Log likelihood = est store x. xi: logistic y Log likelihood = est store null. lrtest x null Likelihood-ratio test LR chi2(1) = (Assumption: null nested in x) Prob > chi2 =

16
16 Comparison of tests | y x | 0 1 | Total | 6 0 | 6 2 | 3 6 | 9 3 | 3 6 | Total | | 24 Pearson chi2(2) = P = Fisher's exact = P = LR chi2(1) = P = (using 2df: P = ) Clearly LRT isn’t great. But 1df is even worse than 2df

17
17 Note In this example, we could use Pearson / Fisher as gold standard. Can’t do this in more complex examples (e.g. adjust for several covariates).

18
18 My proposal for Stata lrtest appears to adjust df for infinite parameter estimates: it should not Model df should be incremented to allow for any variables dropped because they perfectly predict success/failure –Don’t need to increment log lik as it is 0 for the cases dropped Can the ad hoc handling of zeroes by xi:logistic be improved?

19
19 Conclusions for statisticians Must remember the 2 approximation is still poor for these LRTs –typically anti-conservative? (Kuss, 2002) Performance of LRT can be improved by using penalised likelihood (Firth, 1993; Bull, 2006) - like a mildly informative prior –worth using routinely? Gold standard: Bayes or exact logistic regression (logXact)?

20
20 The end

21
21 Output for example with 2-level x. logit y x Log likelihood = y | Coef. Std. Err. z P>|z| [95% Conf. Interval] _cons | estimates store x. logit y Log likelihood = y | Coef. Std. Err. z P>|z| [95% Conf. Interval] _cons | estimates store null. lrtest x null df(unrestricted) = df(restricted) = 1 r(498);. lrtest x null, force df(1) Likelihood-ratio test LR chi2(1) = 6.80 (Assumption: null nested in x) Prob > chi2 =

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google