fracpoly_mr | R Documentation |
fracpoly_mr
performs a Mendelian randomization (MR)
analysis by fitting fractional polynomial models to localised
average causal effects using meta-regression.
fracpoly_mr(
y,
x,
g,
covar = NULL,
family = "gaussian",
q = 10,
xpos = "mean",
method = "FE",
d = 1,
pd = 0.05,
ci = "model_se",
nboot = 100,
fig = FALSE,
ref = mean(x),
pref_x = "x",
pref_x_ref = "x",
pref_y = "y",
ci_type = "overall",
ci_quantiles = 10,
breaks = NULL
)
y |
vector of outcome values |
x |
vector of exposure values |
g |
the instrumental variable |
covar |
|
family |
a description of the error distribution and link function
to be used in the model and is a |
q |
the number of quantiles the exposure distribution is to be split
into within which a causal effect will be fitted, known as localised
average causal effects (LACE) (default: |
xpos |
the position used to relate |
method |
meta-regression method parsed to the |
d |
fractional polynomial degree, the options are: |
pd |
p-value cut-off for choosing the best-fitting fractional polynomial
of degree 2 over the best-fitting fractional polynomial degree 1, used only
if |
ci |
the type of 95% confidence interval, there are three options:
(i) using the model standard errors ( |
nboot |
the number of bootstrap replications (default: |
fig |
a |
ref |
the reference point for the figure, this is the value of the
function that represents the expected difference in the outcome compared
with this reference value when the exposure is set to different values
(default: |
pref_x |
the prefix/label for the x-axis (default: |
pref_x_ref |
the prefix for the reference value displayed on the y-axis
(default: |
pref_y |
the prefix/label for the y-axis (default: |
ci_type |
the type of confidence interval to be displayed on the
graph, where confidence intervals are either presented as bands across the
range of x (option: |
ci_quantiles |
the number of quantiles at which confidence intervals
are to be displayed (default: |
breaks |
breaks on the y-axis of the figure |
fracpoly_mr
returns a list
of non-linear MR results from the
fractional polynomial MR approach:
n |
number of individuals |
model |
the model specifications:
number of quantiles ( |
powers |
the powers of the chosen polynomial |
coefficients |
the regression estimates:
regression coefficients ( |
lace |
the localised average causal effect estimate in each quantile:
regression coefficients ( |
xcoef |
the association between the instrument and the exposure in each quantile:
regression coefficients ( |
p_tests |
the p-value of the non-linearity tests:
p-value of the test between the fractional polynomial degrees ( |
p_heterogeneity |
the p-value of heterogeneity:
p-value of the Cochran Q heterogeneity test ( |
James Staley jrstaley95@gmail.com
# IV (g), exposure (x) & outcome (y)
epsx <- rexp(10000)
u <- runif(10000, 0, 1)
g <- rbinom(10000, 2, 0.3)
epsy <- rnorm(10000)
ag <- 0.25
x <- 1 + ag * g + u + epsx
y <- 0.15 * x^2 + 0.8 * u + epsy
# Covariates (covar)
c1 <- rnorm(10000)
c2 <- rnorm(10000)
c3 <- rbinom(10000, 2, 0.33)
covar <- data.frame(c1 = c1, c2 = c2, c3 = as.factor(c3))
# Analyses
fp <- fracpoly_mr(
y = y, x = x, g = g, covar = covar,
family = "gaussian", q = 10, d = 1, ci = "model_se",
fig = TRUE
)
summary(fp)
plm <- piecewise_mr(
y = y, x = x, g = g, covar = covar,
family = "gaussian", q = 10, nboot = 100,
fig = TRUE
)
summary(plm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.