0) install konfound from github repository
library(tidyverse)
library(htmltools)
library(evaluate)
library(githubinstall)
suppressMessages(gh_install_packages("konfound", ref = "newitcv_output", force = TRUE))
## Warning in fread(download_url, sep = "\t", header = FALSE, stringsAsFactors =
## FALSE, : Found and resolved improper quoting out-of-sample. First healed line
## 4848: <<Puriney honfleuR "Evening, honfleuR" by Seurat>>. If the fields are not
## quoted (e.g. field separator does not appear within any field), try quote="" to
## avoid this warning.
## Do you want to install the package (Y/n)?
##
## ── R CMD build ─────────────────────────────────────────────────────────────────
##
checking for file ‘/private/var/folders/52/my2sfsnn1qs78nfvl14zyynh0000gn/T/RtmppKwHlZ/remotesa2f67e80e9e0/konfound-project-konfound-cfa9742/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/52/my2sfsnn1qs78nfvl14zyynh0000gn/T/RtmppKwHlZ/remotesa2f67e80e9e0/konfound-project-konfound-cfa9742/DESCRIPTION’
##
─ preparing ‘konfound’:
##
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
##
─ checking for LF line-endings in source and make files and shell scripts
##
─ checking for empty or unneeded directories
##
─ building ‘konfound_0.4.0.tar.gz’
##
##
library(konfound)
1) Output Language Modification for RIR in Non-linear Model
1.1) Invalidate, changeSE = TRUE
- In this example, calculation of RIR (Note that RIR =
Fragility/[1-P(RIR_phrase))])has been modified following R code
below
# Case 2: Non-linear
## Case 2-1: changeSE = TRUE, Invalidate
pkonfound(-0.3, 0.01, 5000, n_covariates = 0, alpha = .05, tails = 2, nu = 0, n_treat = 2500, switch_trm = TRUE, model_type = "logistic", to_return = "print")
## RIR = 220
##
## The table implied by the parameter estimates and sample sizes you entered:
##
## Fail Success
## Control 1157 1343
## Treatment 1344 1156
##
## The reported effect size = -0.300, SE = 0.010, p-value = 0.000.
## The SE has been adjusted to 0.057 to generate real numbers in the
## implied table. Numbers in the table cells have been rounded
## to integers, which may slightly alter the estimated effect from
## the value originally entered.
##
## To invalidate the inference that the effect is different from 0
## (alpha = 0.050) one would need to replace 220 (16.37%) treatment failure
## cases with cases for which the probability of failure in the control
## group (46.28%) applies (RIR = 220). This is equivalent to transferring
## 118 cases from treatment failure to treatment success (Fragility = 118).
##
## Note that RIR = Fragility/[1-P(failure in the control group)]
##
## The transfer of 118 cases yields the following table:
##
## Fail Success
## Control 1157 1343
## Treatment 1226 1274
## Effect size = -0.111, SE = 0.057, p-value = 0.051.
## This is based on t = estimated effect/standard error
## For other forms of output, run ?pkonfound and inspect the to_return argument
## For models fit in R, consider use of konfound().
1.2) Invalidate, changeSE = FALSE
## Case 2-2: changeSE = FALSE, Invalidate
pkonfound(-0.3, 0.1, 5000, n_covariates = 10, alpha = .05, tails = 2, n_treat = 2500, switch_trm = TRUE, model_type = "logistic", to_return = "print")
## RIR = 207
##
## The table implied by the parameter estimates and sample sizes you entered:
##
## Fail Success
## Control 2246 254
## Treatment 2307 193
##
## The reported effect size = -0.300, and SE = 0.100, p-value = 0.003.
## Values have been rounded to the nearest integer. This may cause
## a little change to the estimated effect for the table.
##
## To invalidate the inference that the effect is different from 0
## (alpha = 0.050) one would need to replace 207 (8.97%) treatment failure
## cases with cases for which the probability of failure in the control
## group (89.84%) applies (RIR = 207). This is equivalent to transferring
## 21 cases from treatment failure to treatment success (Fragility = 21).
##
## Note that RIR = Fragility/[1-P(failure in the control group)]
##
## The transfer of 21 cases yields the following table:
##
## Fail Success
## Control 2246 254
## Treatment 2286 214
## Effect size = -0.189, SE = 0.097, p-value = 0.052.
## This is based on t = estimated effect/standard error
## For other forms of output, run ?pkonfound and inspect the to_return argument
## For models fit in R, consider use of konfound().
1.3) Part of RIR calculation code
- Following
RIR <- part, RIRway_phrase has been
changed(RIRway_phrase <-).
if (switch_trm && dcroddsratio_ob) {
transferway <- "treatment success to treatment failure"
RIR <- ceiling(final/((a+c)/n_obs))*(replace=="entire") + ceiling(final/(a/(a+b)))*(1-(replace=="entire"))
RIRway <- "treatment success"
RIR_pi <- RIR / d * 100
if (replace == "entire"){
RIRway_phrase <- "success in the entire sample"
} else if (replace == "control"){
RIRway_phrase <- "success in the control group"
}
}
if (switch_trm && !dcroddsratio_ob) {
transferway <- "treatment failure to treatment success"
RIR <- ceiling(final/((b+d)/n_obs))*(replace=="entire") + ceiling(final/(b/(a+b)))*(1-(replace=="entire"))
RIRway <- "treatment failure"
RIR_pi <- RIR / c * 100
### added to show RIR calculation
if (replace == "entire"){
RIRway_phrase <- "failure in the entire sample"
} else if (replace == "control"){
RIRway_phrase <- "failure in the control group"
}
}