I've been using R to do logistic regresssion, and that's working well, but there are two things I haven't figured out how to do. (1) Is there some pre-existing function that will let you compute the odds ratios and confidence intervals for them for a specific fit. I know how to do this manually or even write a function that I can call with the coefficients and se, but extending the printing function was a little more work than I expected. I.e. I'm looking for something where you'd type odds.ratios(fit) and get: Coefficient Odds ratio 95% CI XXX 5.2 1.5 7.2 etc. (2) I'd like to compute goodness-of-fit statistics for my fit (Hosmer-Lemeshow, Pearson, etc.). I didn't see a package that did this. Have I missed one? Thanks, -Ekr -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Eric Rescorla <ekr at rtfm.com> writes:> I've been using R to do logistic regresssion, and that's working > well, but there are two things I haven't figured out how to do. > > (1) Is there some pre-existing function that will let you compute the > odds ratios and confidence intervals for them for a specific fit. I know > how to do this manually or even write a function that I can call with > the coefficients and se, but extending the printing function was a > little more work than I expected. > > I.e. I'm looking for something where you'd type > odds.ratios(fit) > > and get: > > Coefficient Odds ratio 95% CI > XXX 5.2 1.5 7.2My favourite version of this is library(MASS) example(glm) exp(cbind(coef(glm.D93),confint(glm.D93))) (OK, so that's a Poisson regression, not a logistic one, but you get the picture.) Notice that rather than est.+-2SE it gives you likelihood ratio profiling, which is hardly worth not doing these days.> etc. > > (2) I'd like to compute goodness-of-fit statistics for my fit > (Hosmer-Lemeshow, Pearson, etc.). I didn't see a package that > did this. Have I missed one?As I understand it, some of these methods are rather unreliable. It might be a good idea to hear if Frank Harrell has anything to say. Last time someone requested a g-o-f statistic, he said that he regretted ever implementing it in SAS.... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 21 Oct 2002 06:26:46 -0700 Eric Rescorla <ekr at rtfm.com> wrote:> I've been using R to do logistic regresssion, and that's working > well, but there are two things I haven't figured out how to do. > > (1) Is there some pre-existing function that will let you compute the > odds ratios and confidence intervals for them for a specific fit. I know > how to do this manually or even write a function that I can call with > the coefficients and se, but extending the printing function was a > little more work than I expected. > > I.e. I'm looking for something where you'd type > odds.ratios(fit) > > and get: > > Coefficient Odds ratio 95% CI > XXX 5.2 1.5 7.2 > > etc. >library(Design) # see hesweb1.med.virginia.edu/biostat/rms d <- datadist(mydataframe); options(datadist='d') # defines data ranges etc. f <- lrm(y ~ ....) summary(f, age=c(21,65)) # 65:21 year OR (even if age is nonlinear) # other continuous variables: use quartiles See all the contrast function in Design.> (2) I'd like to compute goodness-of-fit statistics for my fit > (Hosmer-Lemeshow, Pearson, etc.). I didn't see a package that > did this. Have I missed one?Hosmer-Lemeshow has low power and relies on arbitrary binning of predicted probabilities. The Hosmer-Le Cessie omnibus test is unique and has more power usually. To get it: f <- update(f, x=T, y=T) resid(f, 'gof') # uses residuals.lrm Frank Harrell> > Thanks, > -Ekr > > > > > > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._