| Title: | Probability in Biostatistics |
|---|---|
| Description: | Several tools for analyzing diagnostic tests and 2x2 contingency tables are provided. In particular, positive and negative predictive values for a diagnostic tests can be calculated from prevalence, sensitivity and specificity values. For contingency tables, relative risk and odds ratio measures are estimated. Furthermore, confidence intervals are provided. |
| Authors: | Alejandro Saavedra-Nieves, Paula Saavedra-Nieves |
| Maintainer: | Paula Saavedra-Nieves <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0 |
| Built: | 2026-05-07 05:25:10 UTC |
| Source: | https://github.com/cran/BioProbability |
This function calculates the odds of a success from its probability. For more details, see Agresti (2018, ISBN: 978-1-119-40528-3).
odds(p,name="Prevalence")odds(p,name="Prevalence")
p |
a numeric value indicating the probability of the success. It is possible to consider a numeric vector of different probabilities values. |
name |
a character value indicating the name of the success. Possible values for this argument are |
A matrix of two columns. The first column contains the vector of probabilities p. The second column contains the corresponding odds values.
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
odds(0.09, name="Prevalence")odds(0.09, name="Prevalence")
This function calculates the odds ratio from a contingency table. Furthermore, a confidence interval for the odds ratio is provided. Details on the confidence interval can be found in Agresti (2018, ISBN: 978-1-119-40528-3).
odds.ratio(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)odds.ratio(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)
A |
a 2x2 matrix object where A[1,1] contains the number of people with the disease who have been exposed to some condition; A[1,2], the number of people without the disease who have not been exposed this condition; A[2,1], the number of people with the disease who have been exposed to the condition; A[2,2], the number of people without the disease who have not been exposed to some condition. |
show.matrix |
a logical value indicating whether the matrix A must be shown. |
conf.int |
a logical value indicating whether a confidence interval for the relative risk must be calculated. |
level |
level of significance for the confidence interval. |
If conf.int=TRUE, a list of length equal to two. The first element of the list Odds Ratio corresponds to the estimation of the odds ratio; the second one Confidence Interval of level contains the corresponding confidence interval.
If conf.int=FALSE, a numeric value corresponding to the estimation of the odds ratio.
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
A<-matrix(c(744,231,421,659),nrow=2) odds.ratio(A,show.matrix=TRUE,conf.int=TRUE)A<-matrix(c(744,231,421,659),nrow=2) odds.ratio(A,show.matrix=TRUE,conf.int=TRUE)
This function calculates the positive and negative predictive values for a diagnostic test from the prevalence, the sensitivity and the specificity values using the Bayes' theorem. For more details, see Agresti (2018, ISBN: 978-1-119-40528-3).
predictive.value(p, Spe, Sen, plot.it = FALSE)predictive.value(p, Spe, Sen, plot.it = FALSE)
p |
a numeric value indicating the prevalence of the disease. It is possible to consider a numeric vector of different values for the prevalence. |
Spe |
a numeric value corresponding to the specificity of the diagnostic test. |
Sen |
a numeric value corresponding to the sensitivity of the diagnostic test. |
plot.it |
a logical value indicating whether the scatterplots for the prevalence values and the corresponding predictive values for the diagnostic test must be plotted. |
A matrix of three columns. The first column contains the vector of prevalences p. The second and third columns contain the corresponding positive and negative predictive values, respectively.
If plot.it=TRUE, the scatterplots for the prevalence values and the predictive values is are plotted.
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
p<-seq(0.001,0.1,length=10) predictive.value(p,Spe=0.95,Sen=0.97,plot.it=TRUE)p<-seq(0.001,0.1,length=10) predictive.value(p,Spe=0.95,Sen=0.97,plot.it=TRUE)
This function calculates the relative risk from a contingency table. Furthermore, a confidence interval for the relative risk is provided. Details on the confidence interval can be found in Agresti (2018, ISBN: 978-1-119-40528-3).
relative.risk(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)relative.risk(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)
A |
a 2x2 matrix object where A[1,1] contains the number of people with the disease who have been exposed to some condition; A[1,2], the number of people without the disease who have not been exposed this condition; A[2,1], the number of people with the disease who have been exposed to the condition; A[2,2], the number of people without the disease who have not been exposed to some condition. |
show.matrix |
a logical value indicating whether the matrix A must be shown. |
conf.int |
a logical value indicating whether a confidence interval for the relative risk must be calculated. |
level |
level of significance for the confidence interval. |
If conf.int=TRUE, a list of length equal to two. The first element of the list Relative Risk corresponds to the estimation of the relative risk; the second one Confidence Interval of level contains the corresponding confidence interval.
If conf.int=FALSE, a numeric value corresponding to the estimation of the relative risk.
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
A<-matrix(c(744,231,421,659),nrow=2) relative.risk(A,show.matrix=TRUE,conf.int=TRUE) relative.risk(A,show.matrix=TRUE,conf.int=TRUE,level=0.1)A<-matrix(c(744,231,421,659),nrow=2) relative.risk(A,show.matrix=TRUE,conf.int=TRUE) relative.risk(A,show.matrix=TRUE,conf.int=TRUE,level=0.1)
This function calculates the sensitivity and specificity for a diagnostic test. Definition of these two concepts can be found in Agresti (2018, ISBN: 978-1-119-40528-3).
sensitivity.specificity(A, show.matrix = FALSE)sensitivity.specificity(A, show.matrix = FALSE)
A |
a 2x2 matrix object where A[1,1] contains the number of people with the disease and with a positive test result; A[1,2], the number of people without the disease with a positive test result; A[2,1], the number of people with the disease with a negative test result; A[2,2], the number of people without the disease and with a negative test result. |
show.matrix |
a logical value indicating whether the matrix A must be shown. |
A vector object of two components: The first one cointains the sensitivity and the second component, the specificity.
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
A<-matrix(c(744,231,421,659),nrow=2) sensitivity.specificity(A,show.matrix=TRUE)A<-matrix(c(744,231,421,659),nrow=2) sensitivity.specificity(A,show.matrix=TRUE)