Re: [R] Nagelkerke R square for Prediction data
Hello I found some small postings dated to 22 Oct 2008 on the message subject. Recently, I have been working with binary logistic regressions. I didn't use the design package. Yet, I needed the fit indices. Therefore, I wrote a small function to output the Nagelkerke's R, and the Cox--Snell R from a fitted model. I am no professional programmer by far, yet, I hope, that the code is okay and that it may be of some use to others -- or subject to useful improvement. Please let me know, if you find errors. Regards, Sören Rcsnagel - function(mod) { llnull - mod$null.deviance llmod - mod$deviance n - length(mod$fitted.values) Rcs - 1 - exp( (mod$deviance - mod$null.deviance) / n ) Rnagel - Rcs / (1 - exp(-llnull/n)) out - list('Rcs'=Rcs, 'Rnagel'=Rnagel) class(out) - c(list, table) return(out) } y - sample(c(T, F), 50, repl=T) x - sample(1:7, 50, repl=T) mod - glm(y ~ x, family=binomial(logit)) Rcsnagel(mod) -- Sören Vogel, Dipl.-Psych. (Univ.), PhD-Student, Eawag, Dept. SIAM http://www.eawag.ch, http://sozmod.eawag.ch __ R-help@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.
[R] Nagelkerke R square for Prediction data
Dear Helpers, I tries to find an Package or script which deals with Nagelkerke R square. I got Prediction data from Habitatmodels for an animal. Some researchers use the the Nagelkerke R Square to confirm the Goodness of model. I would like to do this as well. Data: 1 0.9847 1 0,7653 ... 0 0,2456 0 0,0457 ... THanks a lot -- Tobias Erik Reiners Justus Liebig University IFZ - Department of Animal Ecology Heinrich-Buff-Ring 26-32 D-35392 Giessen Germany __ R-help@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.
Re: [R] Nagelkerke R square for Prediction data
On 10/22/2008 6:05 AM, Tobias Erik Reiners wrote: Dear Helpers, I tries to find an Package or script which deals with Nagelkerke R square. I got Prediction data from Habitatmodels for an animal. Some researchers use the the Nagelkerke R Square to confirm the Goodness of model. I would like to do this as well. Data: 1 0.9847 1 0,7653 ... 0 0,2456 0 0,0457 ... THanks a lot RSiteSearch(Nagelkerke, restrict=function) suggests lrm() in the Design package by Frank Harrell. -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@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.
Re: [R] Nagelkerke R square for Prediction data
Chuck Cleland wrote: On 10/22/2008 6:05 AM, Tobias Erik Reiners wrote: Dear Helpers, I tries to find an Package or script which deals with Nagelkerke R square. I got Prediction data from Habitatmodels for an animal. Some researchers use the the Nagelkerke R Square to confirm the Goodness of model. I would like to do this as well. Data: 1 0.9847 1 0,7653 ... 0 0,2456 0 0,0457 ... THanks a lot RSiteSearch(Nagelkerke, restrict=function) suggests lrm() in the Design package by Frank Harrell. Thanks Chuck, and note Tobias that no R^2 measures goodness of fit but rather explained variation or predictive discrimination. R^2 can be high and there be a major misspecification in the model (e.g., omitting an interaction or nonlinearity term or omitting an important variable). Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@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.