Type: | Package |
Title: | Probability in Biostatistics |
Version: | 1.0 |
Author: | Alejandro Saavedra-Nieves, Paula Saavedra-Nieves |
Maintainer: | Paula Saavedra-Nieves <paula.saavedra@usc.es> |
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. |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2020-01-16 08:26:39 UTC; alexs |
Repository: | CRAN |
Date/Publication: | 2020-01-24 18:10:07 UTC |
Auxiliary function
Description
Auxiliary function.
Auxiliary function
Description
Auxiliary function.
Odds of a success
Description
This function calculates the odds of a success from its probability. For more details, see Agresti (2018, ISBN: 978-1-119-40528-3).
Usage
odds(p,name="Prevalence")
Arguments
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 |
Value
A matrix of two columns. The first column contains the vector of probabilities p
. The second column contains the corresponding odds values.
References
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
Examples
odds(0.09, name="Prevalence")
Odds ratio calculation
Description
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).
Usage
odds.ratio(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)
Arguments
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. |
Value
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.
References
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
Examples
A<-matrix(c(744,231,421,659),nrow=2)
odds.ratio(A,show.matrix=TRUE,conf.int=TRUE)
Positive and negative predictive values for a diagnostic test.
Description
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).
Usage
predictive.value(p, Spe, Sen, plot.it = FALSE)
Arguments
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. |
Value
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.
References
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
Examples
p<-seq(0.001,0.1,length=10)
predictive.value(p,Spe=0.95,Sen=0.97,plot.it=TRUE)
Relative risk calculation
Description
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).
Usage
relative.risk(A, show.matrix = FALSE, conf.int = FALSE, level = 0.05)
Arguments
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. |
Value
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.
References
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
Examples
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)
Sensitivity and specificity for a diagnostic test.
Description
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).
Usage
sensitivity.specificity(A, show.matrix = FALSE)
Arguments
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. |
Value
A vector object of two components: The first one cointains the sensitivity and the second component, the specificity.
References
Agresti, A. (2018). An introduction to categorical data analysis. John Wiley & Sons. ISBN: 978-1-119-40528-3.
Examples
A<-matrix(c(744,231,421,659),nrow=2)
sensitivity.specificity(A,show.matrix=TRUE)