# Function to output printed text
output_print_ME <- function(focus, ind, est_eff, beta_threshhold, nu, obs_r, critical_r, r_con, itcv, alpha, index) {
cat("These calculations assume measurement error as specified by the user. Different calculations would apply to an inference assuming no measurement error. If you prefer those calculations, rerun the command specifying no measurement error as in conmed_ind().")
if (focus == "inval_a") {
cat("The original estimated mediation effect is", round(ind, 3), ". After correcting for measurement error, the mediation effect is statistically significant.")
cat("To invalidate an inference of a significant mediation effect, we consider an omitted confounder CV to change the inference regarding the a pathway (from the treatment to the mediator).")
cat("The minimum impact as defined by Frank 2000 (the product of rX,CV and rM,CV) would be ")
cat(round(r_con^2, 3), "to invalidate an inference for a null hypothesis of 0 pathway.")
cat("This is generated by a scenario that generates the smallest impact necessary to invalidate the inference where |rX,CV| = |rM,CV| = ", round(r_con, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
if (est_eff > 0) {
cat("NOTE: the two correlations would have to have same signs (rX,CV * rM,CV > 0) because the initial estimate of the pathway is positive.")
}
if (est_eff < 0) {
cat("NOTE: the two correlations would have to have different signs (rX,CV * rM,CV < 0) because the initial estimate of the pathway is negative.")
}
cat(" Accordingly, the mediation effect via M is not significant anymore, based on a joint significance test.")
cat("Other combinations of rX,CV and rM,CV with impacts greater than", round(r_con^2, 3), "can change the inference. These are shown on the impact curve below for which combinations of correlations on or above the curved line would invalidate the inference regarding the a pathway (from the treatment to the mediator).")
}
if (focus == "inval_b") {
cat("The original estimated mediation effect is", round(ind, 3), ". After correcting for measurement error, the mediation effect is statistically significant.")
cat("To invalidate an inference of a significant mediation effect, we consider an omitted confounder CV to change the inference regarding the b pathway (from the mediator to the outcome).")
cat("The minimum impact as defined by Frank 2000 (the product of rM,CV and rY,CV) would be ")
cat(round(r_con^2, 3), "to invalidate an inference for a null hypothesis of 0 pathway.")
cat("This is generated by a scenario that generates the smallest impact necessary to invalidate the inference where |rM,CV| = |rY,CV| = ", round(r_con, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
if (est_eff > 0) {
cat("NOTE: the two correlations would have to have same signs (rM,CV * rY,CV > 0) because the initial estimate of the pathway is positive.")
}
if (est_eff < 0) {
cat("NOTE: the two correlations would have to have different signs (rM,CV * rY,CV < 0) because the initial estimate of the pathway is negative.")
}
cat(" Accordingly, the mediation effect via M is not significant anymore, based on a joint significance test.")
cat("Other combinations of rX,CV and rM,CV with impacts greater than", round(r_con^2, 3), "can change the inference. These are shown on the impact curve below for which combinations of correlations on or above the curved line would invalidate the inference regarding the b pathway (from the mediator to the outcome).")
}
if (focus == "sustain_a") {
cat("The original estimated mediation effect is", round(ind, 3), ". After correcting for measurement error, the mediation effect is not statistically significant.")
cat("To sustain an inference of a significant mediation effect, we consider an omitted confounder to change the inference regarding the a pathway (from the treatment to the mediator).")
cat("The maximum impact defined by Frank 2000 (the product of rX,CV and rM,CV) would be ")
cat(round(r_con^2, 3), "to sustain an inference that the a pathway is statistically significant from 0.")
cat("This is generated by a scenario that generates the largest impact necessary to sustain the inference where |rX,CV| = |rM,CV| = ", round(r_con, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
cat(" Accordingly, the mediation effect via M is statistically significant, based on a joint significance test.")
}
if (focus == "sustain_b") {
cat("The original estimated mediation effect is", round(ind, 3), ". After correcting for measurement error, the mediation effect is not statistically significant.")
cat("To sustain an inference of a significant mediation effect, we consider an omitted confounder to change the inference regarding the b pathway (from the mediator to the outcome).")
cat("The maximum impact defined by Frank 2000 (the product of rM,CV and rY,CV) would be ")
cat(round(r_con^2, 3), "to sustain an inference that the b pathway is statistically significant from 0.")
cat("This is generated by a scenario that generates the largest impact necessary to sustain the inference where |rM,CV| = |rY,CV| = ", round(r_con, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
cat(" Accordingly, the mediation effect via M is statistically significant, based on a joint significance test.")
}
}
output_print_both_ME <- function(ind, est_eff_a, est_eff_b, beta_threshold_a, beta_threshold_b, nu,
obs_r_a, obs_r_b, critical_r_a, critical_r_b,
r_con_a, r_con_b, itcv_a, itcv_b, alpha){
cat("These calculations assume measurement error as specified by the user. Different calculations would apply to an inference assuming no measurement error. If you prefer those calculations, rerun the command specifying no measurement error as in conmed_ind().")
cat("The original estimated mediation effect is", round(ind, 3), ". After correcting for measurement error, the mediation effect is not statistically significant.")
cat("To sustain an inference of a significant mediation effect, we consider an omitted confounder to change the inference regarding both a and b pathways.")
cat("For the a pathway (from the treatment to the mediator), the maximum impact defined by Frank 2000 (the product of rX,CV and rM,CV) would be ")
cat(round(r_con_a^2, 3), "to sustain an inference that the b pathway is statistically significant from 0.")
cat("This is generated by a scenario that generates the largest impact necessary to sustain the inference where |rX,CV| = |rM,CV| = ", round(r_con_a, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r_a, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
cat("For the b pathway (from the mediator to the outcome), the maximum impact defined by Frank 2000 (the product of rM,CV and rY,CV) would be ")
cat(round(r_con_b^2, 3), "to sustain an inference that the b pathway is statistically significant from 0.")
cat("This is generated by a scenario that generates the largest impact necessary to sustain the inference where |rM,CV| = |rY,CV| = ", round(r_con_b, 3))
cat(" (conditioning on observed covariates). The correlation is also based on a threshold of ")
cat(round(critical_r_b, 3), " for statistical significance (alpha = ", alpha, ").\n", sep = "")
cat(" Accordingly, the mediation effect via M is statistically significant, based on a joint significance test.")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.