[R] HOw compare 2 models in logistic regression
ONKELINX, Thierry
Thierry.ONKELINX at inbo.be
Mon Apr 30 16:03:13 CEST 2012
Dear Santos,
Since your models are nested you can apply a likelihood ratio test.
M0 <- glm(formula = Spend_bucket ~ Freq + Address_is_res + last_update_days_ago, data = qdataset, family = binomial)
M1 <- glm(formula = Spend_bucket ~ Freq + Address_is_res, data = qdataset, family = binomial)
anova(M0, M1, test = "Chisq")
Note that using the data argument makes you code much more readable.
Best regards,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx op inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens santoshdvn
Verzonden: maandag 30 april 2012 10:23
Aan: r-help op r-project.org
Onderwerp: [R] HOw compare 2 models in logistic regression
Hi,
I have created 2 models in logistic regression and got the predictor values are significance on output. Here are 2 summaries of 2 model. HOw can we compare 2 models by what factor or coefficient and say which model is best
Please help
---------------------------------------------------------------------------------------------------------------
*MODEL 1*
glm(formula = qdataset$Spend_bucket ~ qdataset$Freq + qdataset$Address_is_res +
qdataset$last_update_days_ago, family = binomial)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.572e+00 2.344e-01 -6.708 1.98e-11 ***
qdataset$Freq 8.763e-01 8.229e-02 10.649 < 2e-16 ***
qdataset$Address_is_res -8.743e-01 2.116e-01 -4.132 3.60e-05 ***
qdataset$last_update_days_ago -4.568e-04 7.625e-05 -5.991 2.09e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1228.41 on 988 degrees of freedom Residual deviance: 957.74 on 985 degrees of freedom
AIC: 965.74
Number of Fisher Scoring iterations: 5
-------------------------------------------------------------------------------------------------------------------------------
*MODEL 2*
glm(formula = qdataset$Spend_bucket ~ qdataset$Freq + qdataset$Address_is_res,
family = binomial)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.5798 -0.6428 -0.5894 0.7271 2.2402
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.6148 0.1732 -15.094 < 2e-16 ***
qdataset$Freq 0.9526 0.0794 11.997 < 2e-16 ***
qdataset$Address_is_res -0.7622 0.2044 -3.729 0.000192 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1228.41 on 988 degrees of freedom Residual deviance: 995.18 on 986 degrees of freedom
AIC: 1001.2
Number of Fisher Scoring iterations: 5
--------------------------------------------------------------------------------------
Thanks,
Santosh
--
View this message in context: http://r.789695.n4.nabble.com/HOw-compare-2-models-in-logistic-regression-tp4597659.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help op r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
More information about the R-help
mailing list