Title: | Non-linear Mendelian randomisation |
---|---|
Description: | Non-linear Mendelian randomization analysis to investigate the shape of exposure-outcome relationships. |
Authors: | James Staley [aut, cre] |
Maintainer: | James Staley <[email protected]> |
License: | GPL-3 |
Version: | 1.0.3 |
Built: | 2025-01-10 05:48:09 UTC |
Source: | https://github.com/jrs95/nlmr |
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 )
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 [email protected]
# 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)
# 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)
lace
computes the localised average causal effect
for each quantile.
lace( y, x, g, covar = NULL, q, x0q, xc_sub = TRUE, family = "gaussian", xpos = "mean" )
lace( y, x, g, covar = NULL, q, x0q, xc_sub = TRUE, family = "gaussian", xpos = "mean" )
y |
vector of outcome values |
x |
vector of exposure values |
g |
the instrumental variable |
covar |
|
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: |
x0q |
quantiles of x0 (the IV-free exposure) |
xc_sub |
compute the association between the exposure and the insturment in each quantile of x0 |
family |
a description of the error distribution and link function
to be used in the model and is a |
xpos |
the position used to relate |
lace
returns a data.frame
of the LACE for quantile:
coef |
the LACE in each quantile |
coef_se |
the standard error of the LACE in each quantile |
xmean |
the mean of the exposure in each quantile |
xcoef_sub |
the association between the exposure and the instrument in each quantile |
xcoef_sub_se |
the standard error of the association between the exposure and the instrument in each quantile |
James Staley [email protected]
piecewise_mr
performs a Mendelian randomization (MR) analysis
by fitting a piecewise linear function to localised average causal effects.
piecewise_mr( y, x, g, covar = NULL, family = "gaussian", q = 10, xpos = "mean", nboot = 100, fig = TRUE, ref = mean(x), pref_x = "x", pref_x_ref = "x", pref_y = "y", ci_quantiles = 10, breaks = NULL )
piecewise_mr( y, x, g, covar = NULL, family = "gaussian", q = 10, xpos = "mean", nboot = 100, fig = TRUE, ref = mean(x), pref_x = "x", pref_x_ref = "x", pref_y = "y", 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: |
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_quantiles |
the number of quantiles at which confidence intervals
are to be displayed (default: |
breaks |
breaks on the y-axis of the figure |
piecewise_mr
returns a list
of non-linear MR results from the
piecewise linear function MR approach:
n |
number of individuals |
model |
the model specifications:
number of quantiles ( |
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 from the quadratic test ( |
p_heterogeneity |
the p-value of heterogeneity:
p-value of the Cochran Q heterogeneity test ( |
James Staley [email protected]
# 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)
# 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)
print method for class "fracpoly_mr"
.
## S3 method for class 'fracpoly_mr' print(x, ...)
## S3 method for class 'fracpoly_mr' print(x, ...)
x |
an object of class |
James Staley [email protected]
print method for class "piecewise_mr"
.
## S3 method for class 'piecewise_mr' print(x, ...)
## S3 method for class 'piecewise_mr' print(x, ...)
x |
an object of class |
James Staley [email protected]
print.summary method for class "fracpoly_mr"
.
## S3 method for class 'summary.fracpoly_mr' print(x, ...)
## S3 method for class 'summary.fracpoly_mr' print(x, ...)
x |
an object of class |
James Staley [email protected]
print.summary method for class "piecewise_mr"
.
## S3 method for class 'summary.piecewise_mr' print(x, ...)
## S3 method for class 'summary.piecewise_mr' print(x, ...)
x |
an object of class |
James Staley [email protected]
summary method for class "fracpoly_mr"
.
## S3 method for class 'fracpoly_mr' summary(x, ...)
## S3 method for class 'fracpoly_mr' summary(x, ...)
x |
an object of class |
James Staley [email protected]
summary method for class "piecewise_mr"
.
## S3 method for class 'piecewise_mr' summary(x, ...)
## S3 method for class 'piecewise_mr' summary(x, ...)
x |
an object of class |
James Staley [email protected]