| PMR_individual | R Documentation |
PPMR Individual-level Analysis
PMR_individual(yin, zin, x1in, x2in, gammain, alphain, max_iterin, epsin)
yin |
Numeric vector of the outcome variable (length |
zin |
Numeric vector of the mediator variable (length |
x1in |
Numeric |
x2in |
Numeric |
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. |
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 of the outcome model. |
sigmaY |
Residual variance of the mediator 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 before convergence. |
# ---- Simulate simple example data ----
set.seed(456)
n1 <- 8
n2 <- 10
p <- 3
# Outcome and mediator vectors
y <- c(0.5, -0.3, 0.1, 0.4, -0.2, 0.0, 0.6, -0.1)
z <- c(0.2, -0.4, 0.3, 0.1, -0.1, 0.5, 0.0, 0.4, -0.3, 0.2)
# Fixed genotype design matrices (n × p) with mild correlations
x1 <- matrix(c(
1.0, 0.2, 0.1,
0.2, 1.0, 0.3,
0.1, 0.3, 1.0,
0.4, 0.1, 0.2,
0.2, 0.4, 0.3,
0.3, 0.2, 0.4,
0.5, 0.1, 0.3,
0.1, 0.5, 0.2
), nrow = n1, byrow = TRUE)
x2 <- matrix(c(
1.0, 0.3, 0.2,
0.3, 1.0, 0.4,
0.2, 0.4, 1.0,
0.5, 0.1, 0.3,
0.2, 0.5, 0.1,
0.3, 0.2, 0.4,
0.4, 0.3, 0.2,
0.1, 0.4, 0.3,
0.2, 0.1, 0.5,
0.3, 0.2, 0.4
), nrow = n2, byrow = TRUE)
# Run PPMR individual-level analysis
PMR_individual(
yin = y,
zin = z,
x1in = x1,
x2in = x2,
gammain = 0,
alphain = 0,
max_iterin = 50,
epsin = 1e-6
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.