[R] How to find the accuracy of the predicted glm model with family = binomial (link = logit)

Frank Harrell f.harrell at vanderbilt.edu
Fri Aug 26 16:00:15 CEST 2011


That's not the way to use logistic regression.

See
http://stats.stackexchange.com/questions/14803/graphically-presenting-model-fits-of-logistic-regression
for some other ideas.
Frank

Weidong Gu-2 wrote:
> 
> Andra,
> 
> You can transfer the probabilities into class membership by setting up
> a cut-off value, usually 0.5.
> 
> set.seed(3)
> x<-rnorm(100)
> y<-rbinom(100,prob=1/(1+exp(x)),size=1)
> model<-glm(y~x,family=binomial(link=logit))
> pred<-ifelse(predict(model,type='response')>0.5,1,0)
> table(pred,y)
> 
> 
> Weidong Gu
> 
> On Fri, Aug 26, 2011 at 12:58 AM, Andra Isan <andra_isan at yahoo.com>
> wrote:
>> Hi All,
>>
>> When modeling with glm and family = binomial (link = logit) and response
>> values of 0 and 1, I get the predicted probabilities of assigning to my
>> class one, then I would like to compare it with my vector y which does
>> have the original labels. How should I change the  probabilities into
>> values of zero and 1 and then compare it with my vector y to find out
>> about the accuracy of my prediction?
>>
>> Thanks,
>> Andra
>>
>> ______________________________________________
>> R-help at 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-help at 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.
> 


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/How-to-find-the-accuracy-of-the-predicted-glm-model-with-family-binomial-link-logit-tp3770027p3770932.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list