rglm

Calculation of Accuracy ratio for Logistic regression


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.


Solution

  • 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