PMR_summary: PPMR Summary-level Analysis

View source: R/RcppExports.R

PMR_summaryR Documentation

PPMR Summary-level Analysis

Description

PPMR Summary-level Analysis

Usage

PMR_summary(
  betaxin,
  betayin,
  Sigma1sin,
  Sigma2sin,
  samplen1,
  samplen2,
  gammain,
  alphain,
  max_iterin,
  epsin
)

Arguments

betaxin

Numeric vector of estimated SNP–exposure effects (length 'p').

betayin

Numeric vector of estimated SNP–outcome effects (length 'p').

Sigma1sin

Numeric 'p x p' covariance matrix for the exposure SNP associations (typically an LD matrix).

Sigma2sin

Numeric 'p x p' covariance matrix for the outcome SNP associations.

samplen1

Integer. Sample size used to estimate betaxin.

samplen2

Integer. Sample size used to estimate betayin.

gammain

Integer flag (0/1). If 1, constrains the gamma parameter to 0.

alphain

Integer flag (0/1). If 1, constrains the alpha parameter to 0.

max_iterin

Integer. Maximum number of EM iterations (default: 50 or more).

epsin

Numeric. Convergence tolerance for the log-likelihood.

Value

A named list with elements:

alpha

Estimated causal effect of the mediator on the outcome.

gamma

Estimated direct effect of the SNPs on the outcome.

sigmaX

Residual variance for the exposure model.

sigmaY

Residual variance for the outcome model.

sigmabeta

Variance of the genetic effects.

loglik_seq

Vector of log-likelihood values across iterations.

loglik

Final log-likelihood value.

iteration

Number of iterations used before convergence.

Examples

# ---- Simulate simple example data ----
set.seed(123)
p  <- 3
n1 <- 10
n2 <- 12
betax <- c(0.2, -0.1, 0.3)
betay <- c(0.1,  0.0, 0.2)
Sigma1 <- matrix(c(0.6, 0.2, 0.1,
                   0.2, 0.5, 0.1,
                   0.1, 0.1, 0.4), 3, 3)
Sigma2 <- matrix(c(0.5, 0.1, 0.0,
                   0.1, 0.6, 0.1,
                   0.0, 0.1, 0.5), 3, 3)

PMR_summary(
  betaxin   = betax,
  betayin   = betay,
  Sigma1sin = Sigma1,
  Sigma2sin = Sigma2,
  samplen1  = n1,
  samplen2  = n2,
  gammain   = 0,
  alphain   = 0,
  max_iterin = 50,
  epsin      = 1e-6
)

PPMR documentation built on Nov. 5, 2025, 5:07 p.m.