Title: | Quantify the Robustness of Causal Inferences |
---|---|
Description: | Statistical methods that quantify the conditions necessary to alter inferences, also known as sensitivity analysis, are becoming increasingly important to a variety of quantitative sciences. A series of recent works, including Frank (2000) <doi:10.1177/0049124100029002001> and Frank et al. (2013) <doi:10.3102/0162373713493129> extend previous sensitivity analyses by considering the characteristics of omitted variables or unobserved cases that would change an inference if such variables or cases were observed. These analyses generate statements such as "an omitted variable would have to be correlated at xx with the predictor of interest (e.g., the treatment) and outcome to invalidate an inference of a treatment effect". Or "one would have to replace pp percent of the observed data with nor which the treatment had no effect to invalidate the inference". We implement these recent developments of sensitivity analysis and provide modules to calculate these two robustness indices and generate such statements in R. In particular, the functions konfound(), pkonfound() and mkonfound() allow users to calculate the robustness of inferences for a user's own model, a single published study and multiple studies respectively. |
Authors: | Joshua M Rosenberg [aut, cre], Ran Xu [ctb], Qinyun Lin [ctb], Spiro Maroulis [ctb], Sarah Narvaiz [ctb], Kenneth A Frank [ctb], Wei Wang [ctb], Yunhe Cui [ctb], Gaofei Zhang [ctb], Xuesen Cheng [ctb], JiHoon Choi [ctb], Guan Saw [ctb] |
Maintainer: | Joshua M Rosenberg <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.3 |
Built: | 2024-11-18 18:41:25 UTC |
Source: | https://github.com/konfound-project/konfound |
This data is made-up data for use in examples.
A data.frame with 107 rows and 3 variables.
Calculate delta star for sensitivity analysis
cal_delta_star( FR2max, R2, R2_uncond, est_eff, eff_thr, var_x, var_y, est_uncond, rxz, n_obs )
cal_delta_star( FR2max, R2, R2_uncond, est_eff, eff_thr, var_x, var_y, est_uncond, rxz, n_obs )
FR2max |
maximum R2 |
R2 |
current R2 |
R2_uncond |
unconditional R2 |
est_eff |
estimated effect |
eff_thr |
effect threshold |
var_x |
variance of X |
var_y |
variance of Y |
est_uncond |
unconditional estimate |
rxz |
correlation coefficient between X and Z |
n_obs |
number of observations |
delta star value
Calculate rxy based on ryxGz, rxz, and ryz
cal_rxy(ryxGz, rxz, ryz)
cal_rxy(ryxGz, rxz, ryz)
ryxGz |
correlation coefficient between Y and X given Z |
rxz |
correlation coefficient between X and Z |
ryz |
correlation coefficient between Y and Z |
rxy value
Calculate R2xz based on variances and standard error
cal_rxz(var_x, var_y, R2, df, std_err)
cal_rxz(var_x, var_y, R2, df, std_err)
var_x |
variance of X |
var_y |
variance of Y |
R2 |
coefficient of determination |
df |
degrees of freedom |
std_err |
standard error |
R2xz value
Calculate R2yz based on ryxGz and R2
cal_ryz(ryxGz, R2)
cal_ryz(ryxGz, R2)
ryxGz |
correlation coefficient between Y and X given Z |
R2 |
coefficient of determination |
R2yz value
'chisq_p' calculates the p-value for a chi-square test given a contingency table.
chisq_p(a, b, c, d)
chisq_p(a, b, c, d)
a |
Frequency count for row 1, column 1. |
b |
Frequency count for row 1, column 2. |
c |
Frequency count for row 2, column 1. |
d |
Frequency count for row 2, column 2. |
P-value from the chi-square test.
This data is from Hamilton (1983)
A data.frame with 496 rows and 10 variables.
Hamilton, Lawrence C. 1983. Saving water: A causal model of household conservation. Sociological Perspectives 26(4):355-374.
Extract Degrees of Freedom for Fixed Effects in a Linear Mixed-Effects Model
get_kr_df(model_object)
get_kr_df(model_object)
model_object |
The mixed-effects model object produced by lme4::lmer. |
A vector containing degrees of freedom for the fixed effects in the model.
Performs sensitivity analysis on fitted models including linear models ('lm'), generalized linear models ('glm'), and linear mixed-effects models ('lmerMod'). It calculates the amount of bias required to invalidate or sustain an inference,and the impact of an omitted variable necessary to affect the inference.
konfound( model_object, tested_variable, alpha = 0.05, tails = 2, index = "RIR", to_return = "print", two_by_two = FALSE, n_treat = NULL, switch_trm = TRUE, replace = "control" )
konfound( model_object, tested_variable, alpha = 0.05, tails = 2, index = "RIR", to_return = "print", two_by_two = FALSE, n_treat = NULL, switch_trm = TRUE, replace = "control" )
model_object |
A model object produced by 'lm', 'glm', or 'lme4::lmer'. |
tested_variable |
Variable associated with the coefficient to be tested. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
index |
Type of sensitivity analysis ('RIR' by default). |
to_return |
Type of output to return ('print', 'raw_output', 'table'). |
two_by_two |
Boolean; if 'TRUE', uses a 2x2 table approach for 'glm' dichotomous variables. |
n_treat |
Number of treatment cases (used only if 'two_by_two' is 'TRUE'). |
switch_trm |
Boolean; switch treatment and control in the analysis. |
replace |
Replacement method for treatment cases ('control' by default). |
Depending on 'to_return', prints the result, returns a raw output, or a summary table.
# using lm() for linear models m1 <- lm(mpg ~ wt + hp, data = mtcars) konfound(m1, wt) konfound(m1, wt, to_return = "table") # using glm() for non-linear models if (requireNamespace("forcats")) { d <- forcats::gss_cat d$married <- ifelse(d$marital == "Married", 1, 0) m2 <- glm(married ~ age, data = d, family = binomial(link = "logit")) konfound(m2, age) } # using lme4 for mixed effects (or multi-level) models if (requireNamespace("lme4")) { library(lme4) m3 <- fm1 <- lme4::lmer(Reaction ~ Days + (1 | Subject), sleepstudy) konfound(m3, Days) } m4 <- glm(outcome ~ condition, data = binary_dummy_data, family = binomial(link = "logit")) konfound(m4, condition, two_by_two = TRUE, n_treat = 55)
# using lm() for linear models m1 <- lm(mpg ~ wt + hp, data = mtcars) konfound(m1, wt) konfound(m1, wt, to_return = "table") # using glm() for non-linear models if (requireNamespace("forcats")) { d <- forcats::gss_cat d$married <- ifelse(d$marital == "Married", 1, 0) m2 <- glm(married ~ age, data = d, family = binomial(link = "logit")) konfound(m2, age) } # using lme4 for mixed effects (or multi-level) models if (requireNamespace("lme4")) { library(lme4) m3 <- fm1 <- lme4::lmer(Reaction ~ Days + (1 | Subject), sleepstudy) konfound(m3, Days) } m4 <- glm(outcome ~ condition, data = binary_dummy_data, family = binomial(link = "logit")) konfound(m4, condition, two_by_two = TRUE, n_treat = 55)
This function performs konfound analysis on a generalized linear model object. It uses 'broom' to tidy model outputs and calculates the sensitivity of inferences. It supports analysis for a single variable or multiple variables.
konfound_glm( model_object, tested_variable_string, alpha, tails, index = "RIR", to_return )
konfound_glm( model_object, tested_variable_string, alpha, tails, index = "RIR", to_return )
model_object |
The model object produced by glm. |
tested_variable_string |
The name of the variable being tested. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
index |
Type of sensitivity analysis ('RIR' by default). |
to_return |
The type of output to return. |
The results of the konfound analysis for the specified variable(s).
This function performs konfound analysis on a generalized linear model object with a dichotomous outcome. It uses 'broom' to tidy model outputs and calculates the sensitivity of inferences.
konfound_glm_dichotomous( model_object, tested_variable_string, alpha, tails, to_return, n_treat, switch_trm, replace )
konfound_glm_dichotomous( model_object, tested_variable_string, alpha, tails, to_return, n_treat, switch_trm, replace )
model_object |
The model object produced by glm. |
tested_variable_string |
The name of the variable being tested. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
to_return |
The type of output to return. |
n_treat |
Number of treatment cases. |
switch_trm |
Term to switch for sensitivity analysis. |
replace |
Boolean indicating whether to replace cases or not. |
The results of the konfound analysis.
This function performs konfound analysis on a linear model object produced by lm. It calculates the sensitivity of inferences for coefficients in the model. It supports analysis for a single variable or multiple variables.
konfound_lm( model_object, tested_variable_string, alpha, tails, index, to_return )
konfound_lm( model_object, tested_variable_string, alpha, tails, index, to_return )
model_object |
The linear model object produced by lm. |
tested_variable_string |
The name of the variable being tested. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
index |
Type of sensitivity analysis ('RIR' by default). |
to_return |
The type of output to return. |
The results of the konfound analysis for the specified variable(s).
This function performs konfound analysis on a linear mixed-effects model object produced by lme4::lmer. It calculates the sensitivity of inferences for fixed effects in the model. It supports analysis for a single variable or multiple variables.
konfound_lmer( model_object, tested_variable_string, test_all, alpha, tails, index, to_return )
konfound_lmer( model_object, tested_variable_string, test_all, alpha, tails, index, to_return )
model_object |
The mixed-effects model object produced by lme4::lmer. |
tested_variable_string |
The name of the fixed effect being tested. |
test_all |
Boolean indicating whether to test all fixed effects or not. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
index |
Type of sensitivity analysis ('RIR' by default). |
to_return |
The type of output to return. |
The results of the konfound analysis for the specified fixed effect(s).
Performs sensitivity analysis for multiple models, where parameters are stored in a data frame. It calculates the amount of bias required to invalidate or sustain an inference for each case in the data frame.
mkonfound(d, t, df, alpha = 0.05, tails = 2, return_plot = FALSE)
mkonfound(d, t, df, alpha = 0.05, tails = 2, return_plot = FALSE)
d |
A data frame or tibble containing t-statistics and associated degrees of freedom. |
t |
Column name or vector of t-statistics. |
df |
Column name or vector of degrees of freedom associated with t-statistics. |
alpha |
Significance level for hypothesis testing. |
tails |
Number of tails for the test (1 or 2). |
return_plot |
Whether to return a plot of the percent bias (default is 'FALSE'). |
Depending on 'return_plot', either returns a data frame with analysis results or a plot.
## Not run: mkonfound_ex str(d) mkonfound(mkonfound_ex, t, df) ## End(Not run)
## Not run: mkonfound_ex str(d) mkonfound(mkonfound_ex, t, df) ## End(Not run)
A dataset containing t and df values from example studies from Educational Evaluation and Policy Analysis (as detailed in Frank et al., 2013): https://drive.google.com/file/d/1aGhxGjvMvEPVAgOA8rrxvA97uUO5TTMe/view
mkonfound_ex
mkonfound_ex
A data frame with 30 rows and 2 variables:
t value
degrees of freedom associated with the t value
...
https://drive.google.com/file/d/1aGhxGjvMvEPVAgOA8rrxvA97uUO5TTMe/view
Output data frame based on model estimates and thresholds
output_df( est_eff, beta_threshhold, unstd_beta, bias = NULL, sustain = NULL, recase, obs_r, critical_r, r_con, itcv, non_linear )
output_df( est_eff, beta_threshhold, unstd_beta, bias = NULL, sustain = NULL, recase, obs_r, critical_r, r_con, itcv, non_linear )
est_eff |
estimated effect |
beta_threshhold |
threshold for beta |
unstd_beta |
unstandardized beta value |
bias |
bias to change inference |
sustain |
sustain to change inference |
recase |
number of cases to replace null |
obs_r |
observed correlation |
critical_r |
critical correlation |
r_con |
correlation for omitted variable |
itcv |
inferential threshold for confounding variable |
non_linear |
flag for non-linear models |
data frame with model information
This function outputs printed text for various indices such as RIR (Robustness of Inference to Replacement) and IT (Impact Threshold for a Confounding Variable) with specific formatting like bold, underline, and italic using functions from the crayon package. It handles different scenarios based on the effect difference, beta threshold, and other parameters, providing formatted output for each case.
output_print( n_covariates, est_eff, beta_threshhold, bias = NULL, sustain = NULL, nu, eff_thr, recase, obs_r, critical_r, r_con, itcv, alpha, index, far_bound, sdx = NA, sdy = NA, R2 = NA, rxcv = NA, rycv = NA, rxcvGz, rycvGz )
output_print( n_covariates, est_eff, beta_threshhold, bias = NULL, sustain = NULL, nu, eff_thr, recase, obs_r, critical_r, r_con, itcv, alpha, index, far_bound, sdx = NA, sdy = NA, R2 = NA, rxcv = NA, rycv = NA, rxcvGz, rycvGz )
n_covariates |
number of covariates. |
est_eff |
The estimated effect. |
beta_threshhold |
The threshold value of beta, used for statistical significance determination. |
bias |
The percentage of the estimate that could be due to bias (optional). |
sustain |
The percentage of the estimate necessary to sustain an inference (optional). |
nu |
The hypothesized effect size used in replacement analysis. |
eff_thr |
Threshold for estimated effect. |
recase |
The number of cases that need to be replaced to change the inference. |
obs_r |
The observed correlation coefficient in the data. |
critical_r |
The critical correlation coefficient for statistical significance. |
r_con |
The correlation coefficient of an omitted variable with both the outcome and the predictor. |
itcv |
The impact threshold for a confounding variable. |
alpha |
The level of statistical significance. |
index |
A character string indicating the index for which the output is generated ('RIR' or 'IT'). |
far_bound |
Indicator whether the threshold is towards the other side of nu or 0, by default is zero (same side), alternative is one (the other side). |
sdx |
Standard deviation of x. |
sdy |
Standard deviation of y. |
R2 |
the unadjusted, original R2 in the observed function. |
rxcv |
the correlation between x and CV. |
rycv |
the correlation between y and CV. |
rxcvGz |
the correlation between predictor of interest and CV necessary to nullify the inference for smallest impact, conditioning on all observed covariates. |
rycvGz |
the correlation between outcome and CV necessary to nullify the inference for smallest impact, conditioning on all observed covariates. |
This function takes a model object and the tested variable, tidies the model output using 'broom::tidy', calculates the impact threshold for confounding variables (ITCV) and impact for each covariate,and returns a rounded, tidy table of model outputs.
output_table(model_object, tested_variable)
output_table(model_object, tested_variable)
model_object |
A model object from which to generate the output. |
tested_variable |
The variable being tested in the model. |
A tidy data frame containing model outputs, ITCV, and impacts for covariates.
For published studies, this command calculates (1) how much bias there must be in an estimate to invalidate/sustain an inference; (2) the impact of an omitted variable necessary to invalidate/sustain an inference for a regression coefficient.
pkonfound( est_eff, std_err, n_obs, n_covariates = 1, alpha = 0.05, tails = 2, index = "RIR", nu = 0, n_treat = NULL, switch_trm = TRUE, model_type = "ols", a = NULL, b = NULL, c = NULL, d = NULL, two_by_two_table = NULL, test = "fisher", replace = "control", sdx = NA, sdy = NA, R2 = NA, far_bound = 0, eff_thr = NA, FR2max = 0, FR2max_multiplier = 1.3, to_return = "print" )
pkonfound( est_eff, std_err, n_obs, n_covariates = 1, alpha = 0.05, tails = 2, index = "RIR", nu = 0, n_treat = NULL, switch_trm = TRUE, model_type = "ols", a = NULL, b = NULL, c = NULL, d = NULL, two_by_two_table = NULL, test = "fisher", replace = "control", sdx = NA, sdy = NA, R2 = NA, far_bound = 0, eff_thr = NA, FR2max = 0, FR2max_multiplier = 1.3, to_return = "print" )
est_eff |
the estimated effect (such as an unstandardized beta coefficient or a group mean difference) |
std_err |
the standard error of the estimate of the unstandardized regression coefficient |
n_obs |
the number of observations in the sample |
n_covariates |
the number of covariates in the regression model |
alpha |
probability of rejecting the null hypothesis (defaults to 0.05) |
tails |
integer whether hypothesis testing is one-tailed (1) or two-tailed (2; defaults to 2) |
index |
whether output is RIR or IT (impact threshold); defaults to "RIR" |
nu |
what hypothesis to be tested; defaults to testing whether est_eff is significantly different from 0 |
n_treat |
the number of cases associated with the treatment condition; applicable only when model_type = "logistic" |
switch_trm |
whether to switch the treatment and control cases; defaults to FALSE; applicable only when model_type = "logistic" |
model_type |
the type of model being estimated; defaults to "ols" for a linear regression model; the other option is "logistic" |
a |
cell is the number of cases in the control group showing unsuccessful results |
b |
cell is the number of cases in the control group showing successful results |
c |
cell is the number of cases in the treatment group showing unsuccessful results |
d |
cell is the number of cases in the treatment group showing successful results |
two_by_two_table |
table that is a matrix or can be coerced to one (data.frame, tibble, tribble) from which the a, b, c, and d arguments can be extracted |
test |
whether using Fisher's Exact Test or A chi-square test; defaults to Fisher's Exact Test |
replace |
whether using entire sample or the control group to calculate the base rate; default is control |
sdx |
the standard deviation of X |
sdy |
the standard deviation of Y |
R2 |
the unadjusted, original R2 in the observed function |
far_bound |
whether the estimated effect is moved to the boundary closer (default 0) or further away (1); |
eff_thr |
for RIR: unstandardized coefficient threshold to change an inference; for IT: correlation defining the threshold for inference |
FR2max |
the largest R2, or R2max, in the final model with unobserved confounder |
FR2max_multiplier |
the multiplier of R2 to get R2max, default is set to 1.3 |
to_return |
whether to return a data.frame (by specifying this argument to equal "raw_output" for use in other analyses) or a plot ("plot"); default is to print ("print") the output to the console; can specify a vector of output to return |
pkonfound prints the bias and the number of cases that would have to be replaced with cases for which there is no effect to nullify the inference. If to_return = "raw_output," a list will be given with the following components:
correlation between predictor of interest (X) and outcome (Y) in the sample data.
correlation between predictor of interest (X) and outcome (Y) from the sample regression based on the t-ratio accounting for non-zero null hypothesis.
critical correlation value at which the inference would be nullified (e.g., associated with p=.05).
final correlation value given CV. Should be equal to critical_r.
correlation between predictor of interest (X) and CV necessary to nullify the inference for smallest impact.
correlation between outcome (Y) and CV necessary to nullify the inference for smallest impact.
correlation between predictor of interest and CV necessary to nullify the inference for smallest impact conditioning on all observed covariates (given z).
correlation between outcome and CV necessary to nullify the inference for smallest impact conditioning on all observed covariates (given z).
ITCV conditioning on the observed covariates.
Unconditional ITCV.
R2 using all observed covariates to explain the predictor of interest (X).
R2 using all observed covariates to explain the outcome (Y).
delta calculated using Oster's unrestricted estimator.
delta calculated using Oster's restricted estimator.
correlation-based delta.
percent of bias when comparing delta_star with delta_exact.
correlation matrix implied by delta_star.
correlation matrix implied by delta_exact.
threshold value for estimated effect.
estimated effect given RIR. Should be equal to beta_threshold.
percent bias to change the inference.
Robustness of Inference to Replacement (RIR).
RIR for an extra row or column that is needed to nullify the inference.
RIR as % of total sample (for linear regression) or as % of data points in the cell where replacement takes place (for logistic and 2 by 2 table).
Fragility. the number of switches (e.g., treatment success to treatment failure) to nullify the inference.
Fragility for an extra row or column that is needed to nullify the inference.
Observed 2 by 2 table before replacement and switching. Implied table for logistic regression.
The 2 by 2 table after replacement and switching.
user entered standard error. Only applicable for logistic regression.
whether double row switches are needed.
the standard error used to generate a plausible 2 by 2 table. Only applicable for logistic regression.
figure for ITCV.
figure for RIR.
# using pkonfound for linear models pkonfound(2, .4, 100, 3) pkonfound(-2.2, .65, 200, 3) pkonfound(.5, 3, 200, 3) pkonfound(-0.2, 0.103, 20888, 3, n_treat = 17888, model_type = "logistic") pkonfound(2, .4, 100, 3, to_return = "thresh_plot") pkonfound(2, .4, 100, 3, to_return = "corr_plot") # using pkonfound for a 2x2 table pkonfound(a = 35, b = 17, c = 17, d = 38) pkonfound(a = 35, b = 17, c = 17, d = 38, alpha = 0.01) pkonfound(a = 35, b = 17, c = 17, d = 38, alpha = 0.01, switch_trm = FALSE) pkonfound(a = 35, b = 17, c = 17, d = 38, test = "chisq") # use pkonfound to calculate delta* and delta_exact pkonfound(est_eff = .4, std_err = .1, n_obs = 290, sdx = 2, sdy = 6, R2 = .7, eff_thr = 0, FR2max = .8, index = "COP", to_return = "raw_output") # use pkonfound to calculate rxcv and rycv when preserving standard error pkonfound(est_eff = .5, std_err = .056, n_obs = 6174, eff_thr = .1, sdx = 0.22, sdy = 1, R2 = .3, index = "PSE", to_return = "raw_output")
# using pkonfound for linear models pkonfound(2, .4, 100, 3) pkonfound(-2.2, .65, 200, 3) pkonfound(.5, 3, 200, 3) pkonfound(-0.2, 0.103, 20888, 3, n_treat = 17888, model_type = "logistic") pkonfound(2, .4, 100, 3, to_return = "thresh_plot") pkonfound(2, .4, 100, 3, to_return = "corr_plot") # using pkonfound for a 2x2 table pkonfound(a = 35, b = 17, c = 17, d = 38) pkonfound(a = 35, b = 17, c = 17, d = 38, alpha = 0.01) pkonfound(a = 35, b = 17, c = 17, d = 38, alpha = 0.01, switch_trm = FALSE) pkonfound(a = 35, b = 17, c = 17, d = 38, test = "chisq") # use pkonfound to calculate delta* and delta_exact pkonfound(est_eff = .4, std_err = .1, n_obs = 290, sdx = 2, sdy = 6, R2 = .7, eff_thr = 0, FR2max = .8, index = "COP", to_return = "raw_output") # use pkonfound to calculate rxcv and rycv when preserving standard error pkonfound(est_eff = .5, std_err = .056, n_obs = 6174, eff_thr = .1, sdx = 0.22, sdy = 1, R2 = .3, index = "PSE", to_return = "raw_output")
This function creates a plot to illustrate the correlation between different variables,specifically focusing on the confounding variable, predictor of interest, and outcome.It uses ggplot2 for graphical representation.
plot_correlation(r_con, obs_r, critical_r)
plot_correlation(r_con, obs_r, critical_r)
r_con |
Correlation coefficient related to the confounding variable. |
obs_r |
Observed correlation coefficient. |
critical_r |
Critical correlation coefficient for decision-making. |
A ggplot object representing the correlation diagram.
This function creates a plot to illustrate the threshold of an effect estimate in relation to a specified beta threshold. It uses ggplot2 for graphical representation.
plot_threshold(beta_threshold, est_eff)
plot_threshold(beta_threshold, est_eff)
beta_threshold |
The threshold value for the effect. |
est_eff |
The estimated effect size. |
A ggplot object representing the effect threshold diagram.
This function performs a sensitivity analysis on a 2x2 contingency table. It calculates the number of cases that need to be replaced to invalidate or sustain the statistical inference. The function also allows switching between treatment success and failure or control success and failure based on the provided parameters.
tkonfound( a, b, c, d, alpha = 0.05, switch_trm = TRUE, test = "fisher", replace = "control", to_return = to_return )
tkonfound( a, b, c, d, alpha = 0.05, switch_trm = TRUE, test = "fisher", replace = "control", to_return = to_return )
a |
Number of unsuccessful cases in the control group. |
b |
Number of successful cases in the control group. |
c |
Number of unsuccessful cases in the treatment group. |
d |
Number of successful cases in the treatment group. |
alpha |
Significance level for the statistical test, default is 0.05. |
switch_trm |
Boolean indicating whether to switch treatment row cells, default is TRUE. |
test |
Type of statistical test to use, either "fisher" (default) or "chisq". |
replace |
Indicates whether to use the entire sample or the control group for base rate calculation, default is "control". |
to_return |
Type of output to return, either "raw_output" or "print". |
Returns detailed information about the sensitivity analysis, including the number of cases to be replaced (RIR), user-entered table, transfer table, and conclusions.
This function generates plots illustrating how the change in effect size is influenced by switching or replacing outcomes in a 2x2 table. It produces two plots: one showing all possibilities (switching) and another zoomed in the area for positive RIR (Relative Impact Ratio).
tkonfound_fig( a, b, c, d, thr_p = 0.05, switch_trm = TRUE, test = "fisher", replace = "control" )
tkonfound_fig( a, b, c, d, thr_p = 0.05, switch_trm = TRUE, test = "fisher", replace = "control" )
a |
Number of cases in the control group with unsuccessful outcomes. |
b |
Number of cases in the control group with successful outcomes. |
c |
Number of cases in the treatment group with unsuccessful outcomes. |
d |
Number of cases in the treatment group with successful outcomes. |
thr_p |
P-value threshold for statistical significance, default is 0.05. |
switch_trm |
Whether to switch the two cells in the treatment or control row, default is TRUE (treatment row). |
test |
Type of statistical test used, either "Fisher's Exact Test" (default) or "Chi-square test". |
replace |
Indicates whether to use the entire sample or just the control group for calculating the base rate, default is "control". |
Returns two plots showing the effect of hypothetical case switches on the effect size in a 2x2 table.
tkonfound_fig(14, 17, 6, 25, test = "chisq")
tkonfound_fig(14, 17, 6, 25, test = "chisq")
Verify regression model with control variable Z
verify_reg_Gzcv(n_obs, sdx, sdy, sdz, sdcv, rxy, rxz, rzy, rcvy, rcvx, rcvz)
verify_reg_Gzcv(n_obs, sdx, sdy, sdz, sdcv, rxy, rxz, rzy, rcvy, rcvx, rcvz)
n_obs |
number of observations |
sdx |
standard deviation of X |
sdy |
standard deviation of Y |
sdz |
standard deviation of Z |
sdcv |
sd between C and V |
rxy |
correlation coefficient between X and Y |
rxz |
correlation coefficient between X and Z |
rzy |
correlation coefficient between Z and Y |
rcvy |
correlation coefficient between V and Y |
rcvx |
correlation coefficient between V and X |
rcvz |
correlation coefficient between V and Z |
list of model parameters
Verify unconditional regression model
verify_reg_uncond(n_obs, sdx, sdy, rxy)
verify_reg_uncond(n_obs, sdx, sdy, rxy)
n_obs |
number of observations |
sdx |
standard deviation of X |
sdy |
standard deviation of Y |
rxy |
correlation coefficient between X and Y |
list of model parameters
These functions are used for initializing the package environment and providing utility functions for the package.