[R] Sensitivity and Specificity
greg holly
m@k@hho||y @end|ng |rom gm@||@com
Mon Oct 24 17:17:47 CEST 2022
Hi all R-Help ,
After partitioning my data to testing and training (please see below), I
need to estimate the Sensitivity and Specificity. I failed. It would be
appropriate to get your help.
Best regards,
Greg
inTrain <- createDataPartition(y=data$case,
p=0.7,
list=FALSE)
training <- data[ inTrain,]
testing <- data[-inTrain,]
attach(training)
#model training and prediction
data_training <- glm(case ~ age+BMI+Calcium+Albumin+meno_1, data =
training, family = binomial(link="logit"))
predict <- predict(data_training, data_predict = testing, type = "response")
predict_testing <- ifelse(predict > 0.5,1,0)
# Sensitivity and Specificity
sensitivity<-(predict_testing[2,2]/(predict_testing[2,2]+predict_testing[2,1]))*100
sensitivity
specificity<-(predict_testing[1,1]/(predict_testing[1,1]+predict_testing[1,2]))*100
specificity
[[alternative HTML version deleted]]
More information about the R-help
mailing list