This function creates a table showing the most common statistical validity metrics used for testing the validity of a screening test or a predictive model. The way that the output is formated is as follows:
################# Validity Test #######################
Observed | ||||
+ | - | |||
------------- | --------------- | ------------- | ||
Predicted | + TP | FP | PPV | |
a | b | e (e1-e2) | ||
------------- | --------------- | ------------- | ||
- FN | TN | NPV | ||
c | d | f (f1-f2) | ||
------------- | --------------- | ------------- | ||
Sensitivity | Specificity | |||
Prevalence | g (g1-g2) | h (h1-h2) | ||
i (i1-i2) | ------------- | --------------- | ||
------------- | Error: | (FP+FN) | ||
/(TP+FP+FN+TN) | Accuracy: | (TP+TN) | ||
/(TP+FP+FN+TN) | Precision: | TP | ||
/(TP+FP) | Recall: | TP | ||
/(TP+FN) | f1-Score*: | 2*(Precision*Recall) | ||
/(Precision+Recall) |
* F1-Score: Harmonic mean of precision and recall. ######################################################
ValidityTest(a,b,c,d,multi=100,caption = "Validity of the Model/Screening")
the true positive (TP) value
the false positive (FP) value
the false negative (FN) value
the true negative (TN) value
(Optional) The multiplier for the values. The default is 100 for calculating the percentage.
the text to be printed as the title.
A character matrix containing the following statistical metrics:
the true positive value
the false positive value
the positive predictive value
the false negative value
the true negative value
the negative predictive value
the false negative value
the true negative value
the negative predictive value
the sensitivity of the test
the true negative value
the prevalence of the positive cases in the group
the of incorrectly assigned cases
the true negative value
is the same as the PPV
Othe name for the sensitivity of the test
the armonic mean of the precision and the recall
The ValidityTest function returns a summary table with the validity metrics most commonly used in epidemiology and in statistical analysis.
# NOT RUN {
tab1 <- ValidityTest(110,20,80,324)
# }
Run the code above in your browser using DataLab