From 1bd3312e2f3cb8928e9098b3db35eb760cc87a05 Mon Sep 17 00:00:00 2001 From: Qinyun Lin <qinyun.lin@gu.se> Date: Mon, 7 Oct 2024 09:51:59 +0200 Subject: [PATCH 1/2] update the documentation for needtworows as a raw output --- R/pkonfound.R | 1 + man/pkonfound.Rd | 1 + 2 files changed, 2 insertions(+) diff --git a/R/pkonfound.R b/R/pkonfound.R index a5b8450..87cd288 100644 --- a/R/pkonfound.R +++ b/R/pkonfound.R @@ -59,6 +59,7 @@ #' \item{starting_table}{Observed 2 by 2 table before replacement and switching. Implied table for logistic regression.} #' \item{final_table}{The 2 by 2 table after replacement and switching.} #' \item{user_SE}{user entered standard error. Only applicable for logistic regression.} +#' \item{needtworows}{whether double row switches are needed.} #' \item{analysis_SE}{the standard error used to generate a plausible 2 by 2 table. Only applicable for logistic regression.} #' \item{Fig_ITCV}{figure for ITCV.} #' \item{Fig_RIR}{figure for RIR.} diff --git a/man/pkonfound.Rd b/man/pkonfound.Rd index 331d0c5..e239177 100644 --- a/man/pkonfound.Rd +++ b/man/pkonfound.Rd @@ -118,6 +118,7 @@ pkonfound prints the bias and the number of cases that would have to be replaced \item{starting_table}{Observed 2 by 2 table before replacement and switching. Implied table for logistic regression.} \item{final_table}{The 2 by 2 table after replacement and switching.} \item{user_SE}{user entered standard error. Only applicable for logistic regression.} + \item{needtworows}{whether double row switches are needed.} \item{analysis_SE}{the standard error used to generate a plausible 2 by 2 table. Only applicable for logistic regression.} \item{Fig_ITCV}{figure for ITCV.} \item{Fig_RIR}{figure for RIR.} From cd47e2eaf7f2eae7327d7340b5f7523983c19be8 Mon Sep 17 00:00:00 2001 From: Qinyun Lin <qinyun.lin@gu.se> Date: Tue, 15 Oct 2024 11:23:05 +0200 Subject: [PATCH 2/2] udpate readme to include ITCV --- README.Rmd | 12 ++++++++- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/README.Rmd b/README.Rmd index ef4baac..599f48a 100644 --- a/README.Rmd +++ b/README.Rmd @@ -42,7 +42,7 @@ devtools::install_github("konfound-project/konfound") ## pkonfound() for published studies -`pkonfound()`, for published studies, calculates (1) how much bias there must be in an estimate to invalidate/sustain an inference, and interprets in terms of how much data would need to be replaced to nullify an inference; (2) the impact of an omitted variable necessary to invalidate/sustain an inference for a regression coefficient: +`pkonfound()`, for published studies, calculates (1) how much bias there must be in an estimate to invalidate/sustain an inference, and interprets in terms of how much data would need to be replaced to nullify an inference (Robustness of an Inference to Replacement, RIR); (2) the impact of an omitted variable necessary to invalidate/sustain an inference for a regression coefficient (Impact Threshold of a Confounding Variable, ITCV). RIR is reported by default. ITCV can be generated by specifying `index = "IT"`. ```{r, eval = T} library(konfound) @@ -53,6 +53,11 @@ pkonfound(est_eff = 2, std_err = .4, n_obs = 100, n_covariates = 3) +pkonfound(est_eff = 2, + std_err = .4, + n_obs = 100, + n_covariates = 3, + index = "IT") ``` ## konfound() for models fit in R @@ -71,6 +76,11 @@ Sensitivity analysis for the effect for `wt` on `mpg` can be carried out as foll konfound(m1, wt) ``` +Similar to `pkonfound`, ITCV can be generated by specifying `index = "IT"`. +```{r} +konfound(m1, wt, index = "IT") +``` + ## mkonfound for meta-analyses including sensitivity analysis `mkonfound()` supports sensitivity that can be compared or synthesized across multiple analyses. We can use an existing (and built-in) dataset, such as `mkonfound_ex`. diff --git a/README.md b/README.md index a1e533b..53047d2 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,11 @@ devtools::install_github("konfound-project/konfound") `pkonfound()`, for published studies, calculates (1) how much bias there must be in an estimate to invalidate/sustain an inference, and interprets in terms of how much data would need to be replaced to -nullify an inference; (2) the impact of an omitted variable necessary to -invalidate/sustain an inference for a regression coefficient: +nullify an inference (Robustness of an Inference to Replacement, RIR); +(2) the impact of an omitted variable necessary to invalidate/sustain an +inference for a regression coefficient (Impact Threshold of a +Confounding Variable, ITCV). RIR is reported by default. ITCV can be +generated by specifying `index = "IT"`. ``` r library(konfound) @@ -76,6 +79,39 @@ pkonfound(est_eff = 2, #> For other forms of output, run #> ?pkonfound and inspect the to_return argument #> For models fit in R, consider use of konfound(). +pkonfound(est_eff = 2, + std_err = .4, + n_obs = 100, + n_covariates = 3, + index = "IT") +#> Impact Threshold for a Confounding Variable (ITCV): +#> +#> The minimum impact of an omitted variable to invalidate an inference for +#> a null hypothesis of an effect of nu (0) is based on a correlation of 0.566 +#> with the outcome and 0.566 with the predictor of interest (conditioning +#> on all observed covariates in the model; signs are interchangeable). This is +#> based on a threshold effect of 0.2 for statistical significance (alpha = 0.05). +#> +#> Correspondingly the impact of an omitted variable (as defined in Frank 2000) must be +#> 0.566 X 0.566 = 0.321 to invalidate an inference for a null hypothesis of an effect of nu (0). +#> +#> For calculation of unconditional ITCV using pkonfound(), additionally include +#> the R2, sdx, and sdy as input, and request raw output. +#> +#> See Frank (2000) for a description of the method. +#> +#> Citation: +#> Frank, K. (2000). Impact of a confounding variable on the inference of a +#> regression coefficient. Sociological Methods and Research, 29 (2), 147-194 +#> +#> Accuracy of results increases with the number of decimals reported. +#> +#> The ITCV analysis was originally derived for OLS standard errors. If the +#> standard errors reported in the table were not based on OLS, some caution +#> should be used to interpret the ITCV. +#> For other forms of output, run +#> ?pkonfound and inspect the to_return argument +#> For models fit in R, consider use of konfound(). ``` ## konfound() for models fit in R @@ -141,6 +177,37 @@ konfound(m1, wt) #> NULL ``` +Similar to `pkonfound`, ITCV can be generated by specifying +`index = "IT"`. + +``` r +konfound(m1, wt, index = "IT") +#> Impact Threshold for a Confounding Variable (ITCV): +#> +#> The minimum (in absolute value) impact of an omitted variable to invalidate +#> an inference for a null hypothesis of an effect of nu (0) is based on +#> a correlation of -0.425 with the outcome and 0.425 with the predictor of +#> interest (conditioning on all observed covariates in the model; signs are +#> interchangeable). This is based on a threshold effect of -0.355 for statistical +#> significance (alpha = 0.05). +#> +#> Correspondingly the impact of an omitted variable (as defined in Frank 2000) must be +#> -0.425 X 0.425 = -0.18 to invalidate an inference for a null hypothesis of an effect of nu (0). +#> +#> See Frank (2000) for a description of the method. +#> +#> Citation: +#> Frank, K. (2000). Impact of a confounding variable on the inference of a +#> regression coefficient. Sociological Methods and Research, 29 (2), 147-194 +#> +#> Accuracy of results increases with the number of decimals reported. +#> +#> The ITCV analysis was originally derived for OLS standard errors. If the +#> standard errors reported in the table were not based on OLS, some caution +#> should be used to interpret the ITCV. +#> NULL +``` + ## mkonfound for meta-analyses including sensitivity analysis `mkonfound()` supports sensitivity that can be compared or synthesized