-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModule-6-Example-8.R
More file actions
27 lines (19 loc) · 710 Bytes
/
Module-6-Example-8.R
File metadata and controls
27 lines (19 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# setwd("SET THE Working Director to THE PATH TO THIS DIRECTORY")
rm(list = ls())
library(aod)
library(stats)
library(pROC)
data<-read.csv("Datasets/cevent.csv")
data$male <- ifelse(data$sex =="M", 1, 0)
m <- glm(event ~ chol + age , data=data, family = "binomial")
summary(m)
# http://r-statistics.co/Logistic-Regression-With-R.html
# Find the optimal cutOff
# Default cutoff is 0.5
# Chaning the cutoff can improve the accuracy
data$prob <-predict(m, type=c("response"))
# The InformationValue::optimalCutoff function provides ways to find
# the optimal cutoff
# install.packages("InformationValue")
library(InformationValue)
optCutOff <- optimalCutoff(data$prob, m)[1]