Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculation of Accuracy ratio for Logistic regression

Tags:

r

glm

I have fitted a Logistic Regression using a dummy data as below,

set.seed(1)
binary <- sample(c(1,0), 9, replace = T)
outcome <- rnorm(9)
treatment <- rnorm(9)
glm_fit <- glm(binary ~ outcome + treatment, family=binomial())

I wonder if there is any direct function to calculate the Accuracy ratio for above fit.

Many thanks for your insight.

like image 918
Daniel Lobo Avatar asked Sep 15 '25 12:09

Daniel Lobo


1 Answers

The accuracy ratio is just a transformation of the area under the ROC curve (page 39 of the document; page 47 of the PDF file). That means that any function that produces such AUC can help you here, for example:

auc <- pROC::roc(response=binary, predictor=predict(glm_fit))$auc
2*auc-1
#> 0.3333333
like image 52
PBulls Avatar answered Sep 17 '25 03:09

PBulls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!