% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mr_workflows.R
\name{run_mr_analysis}
\alias{run_mr_analysis}
\title{Run MR Analysis for Multiple Outcomes}
\usage{
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
)
}
\arguments{
\item{MR_input_data}{Harmonised MR input data frame. Must contain Outcome
and Exposure columns.}

\item{outcome.form}{Character vector indicating the effect scale for each
outcome: \code{"Beta"}, \code{"OR"} (odds ratio), or \code{"HR"}
(hazard ratio). A single value is recycled across all outcomes.
Defaults to \code{"Beta"}.}

\item{use_ivw}{Logical; whether to run the Inverse Variance Weighted
(IVW) method. Default is \code{TRUE}.}

\item{use_raps}{Logical; whether to run the Robust Adjusted Profile Score
(MR-RAPS) method. Default is \code{TRUE}.}

\item{use_median}{Logical; whether to run the Weighted Median method.
Default is \code{TRUE}.}

\item{use_egger}{Logical; whether to run MR-Egger regression.
Default is \code{TRUE}.}

\item{use_mr_presso}{Logical; whether to run the Mendelian Randomization
Pleiotropy RESidual Sum and Outlier (MR-PRESSO) method.
Default is \code{TRUE}.}

\item{use_mr_horse}{Logical; whether to run the MR-Horse method.
Default is \code{TRUE}.}

\item{use_mr_grip}{Logical; whether to run the Generalized Regression with
Instrument Pairs (MR-GRIP) method. Default is \code{TRUE}.}

\item{NbDistribution}{Integer; number of simulated distributions for
MR-PRESSO. Default is \code{1000}.}

\item{SignifThreshold}{Numeric; significance threshold for the MR-PRESSO
outlier test. Default is \code{0.05}.}

\item{mr_horse_n_iter}{Integer; number of Markov chain Monte Carlo (MCMC)
iterations for MR-Horse. Default is \code{5000}.}

\item{mr_horse_n_burnin}{Integer; number of MCMC burn-in samples for
MR-Horse. Default is \code{1000}.}

\item{mr_grip_parameters}{Accepted for API compatibility; not used by MR-GRIP.}
}
\value{
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 \code{write.csv()} or \code{saveRDS()} to save the returned object.
}
\description{
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
\code{write.csv()} or \code{saveRDS()} on the returned object.
}
\examples{
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
)

\donttest{
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
)
}

\donttest{
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
)
}
}
