Title: | Diagnosis Performance Using Attributable Fraction |
Version: | 1.1.1 |
Date: | 2021-05-24 |
URL: | https://github.com/johnaponte/afdx |
Description: | Estimate diagnosis performance (Sensitivity, Specificity, Positive predictive value, Negative predicted value) of a diagnostic test where can not measure the golden standard but can estimate it using the attributable fraction. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.1 |
Depends: | R (≥ 3.5.0) |
Imports: | maxLik, dplyr, magrittr, tidyr |
Suggests: | knitr, rmarkdown, ggplot2, DescTools, kableExtra, coda, rjags, ggmcmc, spelling, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Language: | en-US |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2021-05-24 09:38:44 UTC; apontej |
Author: | John J. Aponte |
Maintainer: | John J. Aponte <john.j.aponte@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2021-05-25 11:50:12 UTC |
afdx: Diagnosis performance indicators from attributable fraction estimates.
Description
The afdx package provides functions to estimate the attributable fraction using logit exponential model or bayesian latent class model.
The logit exponential model
The logitexp function estimated the logit exponential function fitting a maximum likelihood model. The senspec() function estimate the sensitivity, specificity, positive predicted value and negative predicted values for the specified cut-off points.
The bayesian latent class model
The get_latent_model() provides an rjags model template to estimate the attributable fraction and the sensitivity, specificity, positive predicted value and negative predicted value of the latent class model.
@docType package @name afdx
Author(s)
Maintainer: John J. Aponte john.j.aponte@gmail.com (ORCID)
Authors:
Orvalho Augusto caveman@gmail.com (ORCID)
See Also
Useful links:
Template for the bayesian latent class model
Description
This function returns a template that can be use as model in an rjags
model
it requires two vectors with the number of subjects in the symptoms,
like fever in the case of malaria (n) and the number of non-symptomatic (m)
in each of the categories of results of the diagnostic test. The first
category is reserved for the negatives by the diagnostic test (in the malaria
case those with asexual density 0) and the rest categories each one with
higher values than the previous category.
Usage
get_latent_model()
Details
See: Smith T, Vounatsou P. Logistic regression and latent class models for estimating positivities in diagnostic assays with poor resolution. Communications in Statistics - Theory and Methods. 1997 Jan;26(7):1677–700.
Vounatsou P, Smith T, Smith AFM. Bayesian analysis of two-component mixture distributions applied to estimating malaria attributable fractions. Journal of the Royal Statistical Society: Series C (Applied Statistics). 1998;47(4):575–87.
Müller I, Genton B, Rare L, Kiniboro B, Kastens W, Zimmerman P, et al. Three different Plasmodium species show similar patterns of clinical tolerance of malaria infection. Malar J. 2009;8(1):158.
Plucinski MM, Rogier E, Dimbu PR, Fortes F, Halsey ES, Aidoo M, et al. Performance of Antigen Concentration Thresholds for Attributing Fever to Malaria among Outpatients in Angola. J Clin Microbiol. 2019;57(3).
Value
a string value
Examples
{
get_latent_model()
}
Exponential logit model for two variables
Description
Fit a logit model of v.density on v.fever v.density with a exponential coefficient for the v.density
Usage
logitexp(v.fever, v.density)
Arguments
v.fever |
numeric vector of 0/1 indicating fever or equivalent |
v.density |
numeric vector of values >= 0 indicating the density |
Details
logit(v.fever) ~ beta * (v. density ^ tau)
This corresponds to the model 3 describe by Smith, T., Schellenberg, J.A., Hayes, R., 1994. Attributable fraction estimates and case definitions for malaria in endemic areas. Stat Med 13, 2345–2358.
Value
S3 object of class afmodel with 4 components: data, model, coefficients and the estimated attributable fraction.
See Also
Examples
{
# Get the sample data
head(malaria_df1)
fit <- logitexp(malaria_df1$fever, malaria_df1$density)
fit
senspec(fit, c(1,100,500,1000,2000,4000,8000,16000, 32000,54000,100000))
}
Cut-off points for densities and fever
Description
Generate the cutoffs at every change of density in the fever, but first category is for density 0, and last category if possible have no subjects with no fever.
Usage
make_cutoffs(v.fever, v.density, add1 = TRUE)
Arguments
v.fever |
numeric vector of 0/1 indicating fever or equivalent |
v.density |
numeric vector of values >= 0 indicating the density |
add1 |
a logical value to indicate the category started with 1 is included |
Value
a vector with the cutoff points
Examples
{
make_cutoffs(malaria_df1$fever, malaria_df1$density, add1 = TRUE)
}
Make a defined number of categories having similar number of positives in each category
Description
Generate the categories in a way that each category have at least the
mintot
number of observation. It generate all possible categories
were there is change and then collapse to have minimum number of observations
in each category
Usage
make_n_cutoffs(v.fever, v.density, mintot, add1 = TRUE)
Arguments
v.fever |
numeric vector of 0/1 indicating fever or equivalent |
v.density |
numeric vector of values >= 0 indicating the density |
mintot |
minimum number of observations per category |
add1 |
a logical value to indicate the category started with 1 is included |
Value
a vector with the cutoff points
Examples
{
make_n_cutoffs(malaria_df1$fever, malaria_df1$density, mintot=50)
}
Synthetic data simulating a malaria crossectional
Description
Simulated data with the main outcomes of a malaria crossectional, fever and parasite density
Usage
malaria_df1
Format
a dataset with two variables
- fever
1 if fever or history of fever, 0 otherwise
- density
asexual Plasmodium parasite density, in parasites per ul
Synthetic data simulating a malaria crossectional
Description
Simulated data with the main outcomes of a malaria crossectional, fever and parasite density
Usage
malaria_df2
Format
a dataset with two variables
- fever
1 if fever or history of fever, 0 otherwise
- density
asexual Plasmodium parasite density, in parasites per ul
S3 methods to estimate diagnosis performance of an afmodel
Description
Estimate sensitivity, specificity, positive predicted value and negative predicted value negative predictive value from an afmodel. The estimated "true" negative and "true" positive are estimated using the estimated overall attributable fraction and the predictive positive value associated with each cut-off point as described by Smith, T., Schellenberg, J.A., Hayes, R., 1994. Attributable fraction estimates and case definitions for malaria in endemic areas. Stat Med 13, 2345–2358.
Usage
senspec(object, ...)
## Default S3 method:
senspec(object, ...)
## S3 method for class 'afmodel'
senspec(object, cutoff, ...)
Arguments
object |
with the data to calculate the sensitivity and specificity |
... |
other parameters for the implementing functions |
cutoff |
vector of cut-off points to make the estimations |
Value
a matrix with the columns sensitivity and specificity, ppv (positive predicted value) and npv (negative predicted value)
No return value. Raise an error.
a matrix with the columns sensitivity and specificity, ppv (positive predicted value) and npv (negative predicted value)
See Also
Examples
{
# Get the sample data
head(malaria_df1)
fit <- logitexp(malaria_df1$fever, malaria_df1$density)
fit
senspec(fit, c(1,100,500,1000,2000,4000,8000,16000, 32000,54000,100000))
}