Skip to content

Commit

Permalink
Version 1.0.7 for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard Grebe committed Sep 13, 2016
1 parent 0b0104f commit 101a211
Show file tree
Hide file tree
Showing 10 changed files with 467 additions and 109 deletions.
7 changes: 6 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# 2016-09-01 - v1.0.0.6
# 2016-09-13 - v1.0.0.7

## Build environment
* OS X 10.11.6, R 3.3.1

## Test environments
* OS X 10.11.6, R 3.3.1
* http://win-builder.r-project.org/ R-release
* http://win-builder.r-project.org/ R-devel

## R CMD check results
0 errors | 0 warnings | 0 notes
Warning message:
Expand Down
7 changes: 4 additions & 3 deletions inctools/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Encoding: UTF-8
Package: inctools
Type: Package
Title: Incidence Estimation Tools
Version: 1.0.6.9002
Date: 2016-09-02
Version: 1.0.7
Date: 2016-09-13
Authors@R: c(
person("Alex","Welte", email="alexwelte@sun.ac.za", role="aut"),
person("Eduard","Grebe",email="eduardgrebe@sun.ac.za",role=c("cre","aut")),
Expand Down Expand Up @@ -39,6 +39,7 @@ Imports:
utils
Suggests:
survey,
knitr,
rmarkdown
VignetteBuilder: rmarkdown
VignetteBuilder: knitr
RoxygenNote: 5.0.1
6 changes: 3 additions & 3 deletions inctools/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import(foreach)
export(frrcal)
export(inccounts)
export(incpower)
export(incprecision)
export(incprops)
export(mdrical)
export(fit_binomial_model)
export(integrate_for_mdri)
export(frrcal)
#export(fit_binomial_model)
#export(integrate_for_mdri)
export(prevcounts)
11 changes: 6 additions & 5 deletions inctools/R/calibration_mdri.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mdrical <- function(data = NULL, subid_var = NULL, time_var = NULL, functional_f
if (plot == TRUE) {
plot_parameters <- parameters
}
cluster <- parallel::makeCluster(cores)
cluster <- parallel::makeCluster(cores, outfile="")
doParallel::registerDoParallel(cluster)
if (foreach::getDoParWorkers() != cores) {
stop("Failed to initialise parallel worker threads.")
Expand All @@ -207,12 +207,13 @@ mdrical <- function(data = NULL, subid_var = NULL, time_var = NULL, functional_f
chosen_subjects[[j]] <- sample(1:n_subjects, n_subjects, replace = T)
}
pb <- utils::txtProgressBar(min = 1, max = n_bootstraps, style = 3)
progress <- function(n) utils::setTxtProgressBar(pb, n)
opts <- list(progress = progress)
#progress <- function(n) utils::setTxtProgressBar(pb, n)
#opts <- list(progress = progress)
mdris <- foreach::foreach(j = 1:n_bootstraps, .combine = rbind,
#.options.snow = opts,
.inorder = FALSE,
.packages = "inctools") %dopar%
.inorder = FALSE #,
#.packages = "inctools"
) %dopar%
{
boot_data <- data[FALSE, ]
for (k in 1:n_subjects) {
Expand Down
10 changes: 5 additions & 5 deletions inctools/vignettes/EstimatingIncidence.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ <h3>Examples</h3>
<span class="dt">BS_Count =</span> <span class="dv">10000</span>, <span class="dt">Boot =</span> <span class="ot">TRUE</span>, <span class="dt">MDRI =</span> <span class="dv">200</span>, <span class="dt">RSE_MDRI =</span> <span class="fl">0.05</span>,
<span class="dt">FRR =</span> <span class="fl">0.01</span>, <span class="dt">RSE_FRR =</span> <span class="fl">0.2</span>, <span class="dt">BigT =</span> <span class="dv">730</span>)</code></pre></div>
<pre><code>## $Incidence.Statistics
## Incidence CI.low CI.up RSE
## 1 0.04265 0.03324 0.05322 0.1196
## Incidence CI.low CI.up RSE
## 1 0.04265 0.03315 0.05307 0.11953
##
## $Annual.Risk.of.Infection
## ARI ARI.CI.low ARI.CI.up
## 1 0.0418 0.0327 0.0518
## 1 0.0418 0.0326 0.0517
##
## $MDRI.CI
## CI.low CI.up
Expand Down Expand Up @@ -198,8 +198,8 @@ <h2>Function <code>prevcounts</code></h2>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>Kassanjee, R., McWalter, T.A., Baernighausen, T. and Welte, A. “A new general biomarker-based incidence estimator.” Epidemiology; 2012, 23(5): 721-728; <a href="#fnref1"></a></p></li>
<li id="fn2"><p>Kassanjee, R., McWalter, T.A. and Welte, A. “Short Communication: Defining Optimality of a Test for Recent Infection for HIV Incidence Surveillance.” AIDS Research and Human Retroviruses; 2014, 30(1): 45-49; <a href="#fnref2"></a></p></li>
<li id="fn1"><p>Kassanjee, R., McWalter, T.A., Baernighausen, T. and Welte, A. “A new general biomarker-based incidence estimator.” Epidemiology; 2012, 23(5): 721-728.<a href="#fnref1"></a></p></li>
<li id="fn2"><p>Kassanjee, R., McWalter, T.A. and Welte, A. “Short Communication: Defining Optimality of a Test for Recent Infection for HIV Incidence Surveillance.” AIDS Research and Human Retroviruses; 2014, 30(1): 45-49.<a href="#fnref2"></a></p></li>
</ol>
</div>

Expand Down
14 changes: 7 additions & 7 deletions inctools/vignettes/Introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,26 @@ <h2>Appendix: Technical details</h2>
</ol>
<p>Below are the variances of the incidence difference estimator for the three cases</p>
Case 1: Surveys share a single estimate for MDRI and a single estimate for FRR
\begin{align}
<span class="math display">\[\begin{align}
V[\Delta \mathbb{I}]_1 \approx &amp;
\Big(\frac{(PrevR_1 - \beta)}{(1 - PrevH_1)^2} (\Omega - \beta T)\Big)^2\ (RSE_{PrevH_1}PrevH_1)^2 + \\
&amp;\Big(\frac{(PrevR_2 - \beta)}{(1 - PrevH_2)^2} (\Omega - \beta T)\Big)^2\ (RSE_{PrevH_2}PrevH_2)^2 +\\
&amp; \frac{PrevH_1}{1 - PrevH_1}(\Omega - \beta T))\ (RSE_{PrevR_1}\ PrevR_1)^2) + \\ &amp; \frac{PrevH_2}{1 - PrevH_2}(\Omega - \beta T))\ (RSE_{PrevR_2}PrevR_2)^2) +\\
&amp;\Big(\big(\frac{\beta\ PrevH_1 - PrevR_1 \ PrevH_1}{1 - PrevH_1} - \frac{\beta\ PrevH_2 - PrevR_2 \ PrevH_2}{1 - PrevH_2}\big) (\Omega - \beta \ T)^2 \Big)^2 RSE_{MDRI}\ MDRI +\\
&amp;\Big(\big(\frac{PrevH_1(T\ PrevR_1 - \Omega)}{(1 - PrevH_1)} -\frac{PrevH_2(T\ PrevR_2 -\Omega)}{(1 - PrevH_2)}\big)(\Omega - \beta T)^2 \Big)^2 RSE_{\beta}\ \beta\\
\end{align}
\end{align}\]</span>
Case 2: Surveys share a single estimate for MDRI, but have independent FRR estimates
\begin{align}
<span class="math display">\[\begin{align}
V[\Delta \mathbb{I}]_2 \approx &amp;
\Big(\frac{(PrevR_1 - \beta)}{(1 - PrevH_1)^2} (\Omega - \beta T)\Big)^2\ (RSE_{PrevH_1}PrevH_1)^2 + \\
&amp;\Big(\frac{(PrevR_2 - \beta)}{(1 - PrevH_2)^2} (\Omega - \beta T)\Big)^2\ (RSE_{PrevH_2}PrevH_2)^2 +\\
&amp; \frac{PrevH_1}{1 - PrevH_1}(\Omega - \beta T))\ (RSE_{PrevR_1}\ PrevR_1)^2) +\\ &amp;\frac{PrevH_2}{1 - PrevH_2}(\Omega - \beta T))(RSE_{PrevR_2}PrevR_2)^2) +\\
&amp;\Big(\big(\frac{\beta\ PrevH_1 - PrevR_1 \ PrevH_1}{1 - PrevH_1} - \frac{\beta\ PrevH_2 - PrevR_2 \ PrevH_2}{1 - PrevH_2}\big) (\Omega - \beta \ T)^2 \Big)^2 RSE_{MDRI}\ MDRI +\\
&amp;\Big(\frac{PrevH_1(T\ PrevR_1 - \Omega)}{1 - PrevH_1}(\Omega - \beta_1 \ T)^2\Big)^2 RSE_{\beta_1}\ \beta_1 + \\
&amp;\Big(\frac{PrevH_2(T\ PrevR_2 - \Omega)}{1 - PrevH_2}(\Omega - \beta_2 \ T)^2)\Big)^2 RSE_{\beta_2}\ \beta_2
\end{align}
\end{align}\]</span>
Case 3: Both MDRI and FRR are independently estimated in each survey
\begin{align}
<span class="math display">\[\begin{align}
V[\Delta \mathbb{I}]_3 \approx &amp;
\Big(\frac{(PrevR_1 - \beta_1)}{(1 - PrevH_1)^2} (\Omega_1 - \beta_1 T_1)\Big)^2\ (RSE_{PrevH_1}PrevH_1)^2 + \\
&amp;\Big(\frac{(PrevR_2 - \beta_2)}{(1 - PrevH_2)^2} (\Omega_2 - \beta_2 T_2)\Big)^2\ (RSE_{PrevH_2}PrevH_2)^2 +\\
Expand All @@ -207,7 +207,7 @@ <h2>Appendix: Technical details</h2>
&amp;\Big(\frac{\beta_2\ PrevH_2 - PrevR_2\ PrevH_2}{1 - PrevH_2}\ (\Omega_2 - \beta_2\ T_2)^2\Big)^2 RSE_{MDRI_2}\ MDRI_2 +\\
&amp;\Big(\frac{PrevH_1(T_1\ PrevR_1 - \Omega_1}{1 - PrevH_1}(\Omega_1 -\beta_1\ T_1)^2\Big)^2 RSE_{\beta_1}\ \beta_1 + \\
&amp;\Big(\frac{PrevH_2(T_2\ PrevR_2 - \Omega_2}{1 - PrevH_2}(\Omega_2 -\beta_2\ T_2)^2\Big)^2 RSE_{\beta_2}\ \beta_2
\end{align}
\end{align}\]</span>
<p>Note:</p>
<ul>
<li>The option for the assay characteristic scheme is specified by function parameter <code>BMest</code>. Subscripts 1 and 2 in the parameter notation denote associated survey or test parameters. The variances of the three cases follow.</li>
Expand All @@ -223,7 +223,7 @@ <h3>Crucial note on choice of null hypothesis, calculation of p-values and meani
<li>hypothesize that the estimated value of the variance of the incidence difference estimate (calculated carefully in accordance with the choice of how test properties are shared between the surveys) is a good estimate of the actual variance of the incidence difference. (This is equivalent to a routinely made assumption in less complex situations)</li>
<li>allow the prevalence for each context to be independently estimated from the data from that context. (Note that even if the data does not support the rejection of the hypothesis that the prevalences are identical, benchmarking indicates that there is little or no advantage in constructing the null hypothesis to include equal prevalence.)</li>
</ul>
<p>The preceding assumptions allow the calculation of a p-value, which is done according to a two-tailed test, capturing the point that the experimenter has no basis to pre-determine the acceptable direction of any incidence difference.   Note that while it is common to report “power” as simply the probability of correctly rejecting a null hypothesis, without regard to whether the inferred direction of difference is in correspondence with the underlying reality, the present construction specifically presumes a two-tailed test, where the direction of any particular inferred difference will be either correct or incorrect. Hence, <em>inctools</em> calculates the probability of <em>correctly</em> detecting the sign of the incidence difference through the rejection of the null hypothesis throug the attainment of a below-threshold <em>p value</em>. Numerically, the probability of rejecting the null hypothesis, but with the incorrect direction for the inferred effect, will usually be <em>very</em> small, unless the study design has no useful statistical power in any case. The primary difference between this implementation and an alternative likely to be proposed, is in the insistence on a two tailed test, which should not be controversial in this situation as it would be difficult to defend the claim that survey implementers can claim to know the change in</p>
<p>The preceding assumptions allow the calculation of a p-value, which is done according to a two-tailed test, capturing the point that the experimenter has no basis to pre-determine the acceptable direction of any incidence difference.   Note that while it is common to report “power” as simply the probability of correctly rejecting a null hypothesis, without regard to whether the inferred direction of difference is in correspondence with the underlying reality, the present construction specifically presumes a two-tailed test, where the direction of any particular inferred difference will be either correct or incorrect. Hence, <em>inctools</em> calculates the probability of <em>correctly</em> detecting the sign of the incidence difference through the rejection of the null hypothesis throug the attainment of a below-threshold <em>p value</em>. Numerically, the probability of rejecting the null hypothesis, but with the incorrect direction for the inferred effect, will usually be <em>very</em> small, unless the study design has no useful statistical power in any case. The primary difference between this implementation and an alternative likely to be proposed, is in the insistence on a two tailed test, which should not be controversial in this situation as it would be difficult to defend the claim that survey implementers can claim to know, in advance, the direction of a change in incidence.</p>
<!-- #not-for-release -->
<!--
## The Empirical Bootstrapping Option
Expand Down
8 changes: 1 addition & 7 deletions inctools/vignettes/SurveyDesign.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.15, alpha = 0.05,
## ---- echo=TRUE----------------------------------------------------------
incprecision(I = 0.015, RSE_I = 0.25, PrevH = 0.2, CR = 1, MDRI = 200,
RSE_MDRI = 0.05, FRR = 0.01, RSE_FRR = 0.2, BigT = 730,
DE_H = 1.1, DE_R = 1, n = 'out')
DE_H = 1.1, DE_R = 1.1, n = 'out')

## ---- echo=TRUE----------------------------------------------------------
incprecision(I = c(0.015,0.02), RSE_I = 0.25, PrevH = c(0.10,0.20), CR = 1,
Expand All @@ -28,9 +28,3 @@ incprecision(I = 0.017, RSE_I = 'out', PrevH = c(0.10,0.20), CR = 1, MDRI = 211,
RSE_MDRI = 0.05, FRR = 0.009, RSE_FRR = 0.2, BigT = 720, n = 5000,
step = 5)

## ---- echo=TRUE----------------------------------------------------------
incpower(I1 = 0.05, I2 = 0.03, PrevH1 = 0.20, PrevH2 = 0.15, n1 = 5000,
n2 = "out", alpha = 0.05, Power = 0.8, SS = "out", CR = 1, DE_H = 1,
DE_R = 1, BMest = "same.test", MDRI = 200, RSE_MDRI = 0.05, FRR = 0.01,
RSE_FRR = 0.21, BigT = 730)

Loading

0 comments on commit 101a211

Please sign in to comment.