| run_mr_analysis | R Documentation |
Performs causal inference analysis using multiple Mendelian Randomization
(MR) methods across one or more outcomes and exposures. Returns a combined
results data frame. To save the output, use standard R functions such as
write.csv() or saveRDS() on the returned object.
run_mr_analysis(
MR_input_data,
outcome.form = NULL,
use_ivw = TRUE,
use_raps = TRUE,
use_median = TRUE,
use_egger = TRUE,
use_mr_presso = TRUE,
use_mr_horse = TRUE,
use_mr_grip = TRUE,
NbDistribution = 1000,
SignifThreshold = 0.05,
mr_horse_n_iter = 5000,
mr_horse_n_burnin = 1000,
mr_grip_parameters = NULL
)
MR_input_data |
Harmonised MR input data frame. Must contain Outcome and Exposure columns. |
outcome.form |
Character vector indicating the effect scale for each
outcome: |
use_ivw |
Logical; whether to run the Inverse Variance Weighted
(IVW) method. Default is |
use_raps |
Logical; whether to run the Robust Adjusted Profile Score
(MR-RAPS) method. Default is |
use_median |
Logical; whether to run the Weighted Median method.
Default is |
use_egger |
Logical; whether to run MR-Egger regression.
Default is |
use_mr_presso |
Logical; whether to run the Mendelian Randomization
Pleiotropy RESidual Sum and Outlier (MR-PRESSO) method.
Default is |
use_mr_horse |
Logical; whether to run the MR-Horse method.
Default is |
use_mr_grip |
Logical; whether to run the Generalized Regression with
Instrument Pairs (MR-GRIP) method. Default is |
NbDistribution |
Integer; number of simulated distributions for
MR-PRESSO. Default is |
SignifThreshold |
Numeric; significance threshold for the MR-PRESSO
outlier test. Default is |
mr_horse_n_iter |
Integer; number of Markov chain Monte Carlo (MCMC)
iterations for MR-Horse. Default is |
mr_horse_n_burnin |
Integer; number of MCMC burn-in samples for
MR-Horse. Default is |
mr_grip_parameters |
Accepted for API compatibility; not used by MR-GRIP. |
A data frame combining results across all outcomes and exposures.
Each row represents one outcome-exposure pair. Columns include estimates,
confidence intervals (CI), and p-values for each method, together with
diagnostic flags (e.g., F-statistic below 10, significant heterogeneity).
Use write.csv() or saveRDS() to save the returned object.
data("fi_49item")
input1 <- harmonize_mr_data(df = fi_49item)$input_df
outcome1 <- run_mr_analysis(
MR_input_data = input1,
outcome.form = "Beta",
use_ivw = TRUE,
use_raps = FALSE,
use_median = FALSE,
use_egger = FALSE,
use_mr_presso = FALSE,
use_mr_horse = FALSE,
use_mr_grip = FALSE,
NbDistribution = 1000,
SignifThreshold = 0.05,
mr_horse_n_iter = 5000,
mr_horse_n_burnin = 1000,
mr_grip_parameters = NULL
)
data("fried_frailty")
input2 <- harmonize_mr_data(df = fried_frailty)$input_df
outcome2 <- run_mr_analysis(
MR_input_data = input2,
outcome.form = "OR",
use_ivw = TRUE,
use_raps = TRUE,
use_median = TRUE,
use_egger = TRUE,
use_mr_presso = TRUE,
use_mr_horse = TRUE,
use_mr_grip = TRUE,
NbDistribution = 1000,
SignifThreshold = 0.05,
mr_horse_n_iter = 5000,
mr_horse_n_burnin = 1000,
mr_grip_parameters = NULL
)
data("merged_data")
input3 <- harmonize_mr_data(df = merged_data)$input_df
outcome3 <- run_mr_analysis(
MR_input_data = input3,
outcome.form = c("Beta","OR"), ## First outcome use Beta and second outcome use OR
use_ivw = TRUE,
use_raps = TRUE,
use_median = TRUE,
use_egger = TRUE,
use_mr_presso = TRUE,
use_mr_horse = TRUE,
use_mr_grip = TRUE,
NbDistribution = 1000,
SignifThreshold = 0.05,
mr_horse_n_iter = 5000,
mr_horse_n_burnin = 1000,
mr_grip_parameters = NULL
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.