Jan Verbesselt
2005-Feb-22 14:19 UTC
[R] ERROR NaNs produced; when comparing two logistic regression models with the ANOVA CHI test
Dear R-list,
*When comparing two logistic regression models with the anova CHi test, I
obtain the following error: (there are no NA's in the time series). How can
this be solved such that I can compare two models on the same dataset were
different explanatory variables are used?
l.KBDI <- glm(zna.arson2 ~ zna.KBDI,family = binomial)
l.NDWI <- glm(zna.arson2 ~ zna.NDWI,family = binomial)
anova(l.KBDI,l.NDWI, test = "Chi")
Analysis of Deviance Table
Model 1: zna.arson2 ~ zna.KBDI
Model 2: zna.arson2 ~ zna.NDWI
Resid. Df Resid. Dev Df Deviance P(>|Chi|)
1 110 123.227
2 110 113.593 0 9.635
Warning message:
NaNs produced in: pchisq(q, df, lower.tail, log.p)
*Is this caused by the non-linearity of the data?
*How can I obtain a p-value?
Thanks,
Jan
_______________________________________________________________________
ir. Jan Verbesselt
Research Associate
Lab of Geomatics and Forest Engineering K.U. Leuven
Vital Decosterstraat 102. B-3000 Leuven Belgium
Tel:+32-16-329750 Fax: +32-16-329760
http://gloveg.kuleuven.ac.be/
Prof Brian Ripley
2005-Feb-22 14:58 UTC
[R] ERROR NaNs produced; when comparing two logistic regression models with the ANOVA CHI test
You need the models to be NESTED for this test to be valid. Look up `analysis of deviance' in your textbooks. You get the error because you have two unnested models with the same number of parameters, so the F numerator is divided by 0. (But this is merely a symptom of incorrect usage.) On Tue, 22 Feb 2005, Jan Verbesselt wrote:> Dear R-list, > > *When comparing two logistic regression models with the anova CHi test, I > obtain the following error: (there are no NA's in the time series). How can > this be solved such that I can compare two models on the same dataset were > different explanatory variables are used? > > > l.KBDI <- glm(zna.arson2 ~ zna.KBDI,family = binomial) > l.NDWI <- glm(zna.arson2 ~ zna.NDWI,family = binomial) > > anova(l.KBDI,l.NDWI, test = "Chi") > > > Analysis of Deviance Table > > Model 1: zna.arson2 ~ zna.KBDI > Model 2: zna.arson2 ~ zna.NDWI > Resid. Df Resid. Dev Df Deviance P(>|Chi|) > 1 110 123.227 > 2 110 113.593 0 9.635 > Warning message: > NaNs produced in: pchisq(q, df, lower.tail, log.p) > > > *Is this caused by the non-linearity of the data? > *How can I obtain a p-value?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dimitris Rizopoulos
2005-Feb-22 15:02 UTC
[R] ERROR NaNs produced; when comparing two logistic regression models with the ANOVACHI test
these models are not nested and thus LRT should not be used. You get
no p-value because Df=0 in your case. As an alternative you could look
at the deviances.
I hope it helps.
Best,
Dimitris
p.s., you referred to `non-linearity of the data' if you mean that the
probability of positive responses is a nonlinear function of your
explanatory variables then you could use splines to model it (see
e.g., at function `lrm()' from the Design package).
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Jan Verbesselt" <Jan.Verbesselt at agr.kuleuven.ac.be>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, February 22, 2005 3:19 PM
Subject: [R] ERROR NaNs produced;when comparing two logistic
regression models with the ANOVACHI test
> Dear R-list,
>
> *When comparing two logistic regression models with the anova CHi
> test, I
> obtain the following error: (there are no NA's in the time series).
> How can
> this be solved such that I can compare two models on the same
> dataset were
> different explanatory variables are used?
>
>
> l.KBDI <- glm(zna.arson2 ~ zna.KBDI,family = binomial)
> l.NDWI <- glm(zna.arson2 ~ zna.NDWI,family = binomial)
>
> anova(l.KBDI,l.NDWI, test = "Chi")
>
>
> Analysis of Deviance Table
>
> Model 1: zna.arson2 ~ zna.KBDI
> Model 2: zna.arson2 ~ zna.NDWI
> Resid. Df Resid. Dev Df Deviance P(>|Chi|)
> 1 110 123.227
> 2 110 113.593 0 9.635
> Warning message:
> NaNs produced in: pchisq(q, df, lower.tail, log.p)
>
>
> *Is this caused by the non-linearity of the data?
> *How can I obtain a p-value?
>
>
> Thanks,
> Jan
>
> _______________________________________________________________________
> ir. Jan Verbesselt
> Research Associate
> Lab of Geomatics and Forest Engineering K.U. Leuven
> Vital Decosterstraat 102. B-3000 Leuven Belgium
> Tel:+32-16-329750 Fax: +32-16-329760
> http://gloveg.kuleuven.ac.be/
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
Maybe Matching Threads
- negetative AIC values: How to compare models with negative AIC's
- labels on axis(4) and adaptation of legend to size of the plot
- Penalized likelihood-ratio chi-squared statistic: L.R. model for Goodness of fit?
- Change labels of x-axes in Plot of stl() function?
- Spatial Autocorrelation for point data