mr_median | R Documentation |
The mr_median
function implements the weighted median (default) or simple median method introduced by Bowden et al (2016) to calculate
the median of the ratio instrumental variable estimates evaluated using each genetic variant individually.
mr_median(
object,
weighting = "weighted",
distribution = "normal",
alpha = 0.05,
iterations = 10000,
seed = 314159265
)
## S4 method for signature 'MRInput'
mr_median(
object,
weighting = "weighted",
distribution = "normal",
alpha = 0.05,
iterations = 10000,
seed = 314159265
)
object |
An |
weighting |
The type of weighting applied. The default option is to calculate the weighted median ( |
distribution |
The type of distribution to use to calculate the 95% confidence intervals, can be |
alpha |
The significance level used to calculate the confidence intervals. The default value is 0.05. |
iterations |
The number of bootstrap samples to generate when calculating the estimated standard error. The default value is 10000. |
seed |
The random seed to use when generating the bootstrap samples (for reproducibility). The default value is 314159265. If set to |
The median-based methods have greater robustness to individual genetic variants with strongly outlying causal estimates compared with the inverse-variance weighted and MR-Egger methods. Formally, the simple median method gives a consistent estimate of the causal effect when at least 50% of the genetic variants are valid instrumental variables (for the weighted median method, when 50% of the weight comes from valid instrumental variables).
When the weighting is "simple"
, the estimate is obtained by calculating the ratio causal estimates
from each genetic variants theta = betaY/betaX, and finding the median estimate.
When the weighting is "weighted"
, the estimate is obtained by:
Calculating the ratio causal estimates and ordering the genetic variants according to the magnitude of their estimates, i.e.
\theta_1 < \theta_2 < ... < \theta_J
Calculate normalized inverse-variance weights for each genetic variant w_1, w_2, ..., w_J
, as:
w_j = \frac{\beta_{Xj}^2}{se(\beta_{Yj})^2} / \sum_{i=1}^{J} \frac{\beta_{Xi}^2}{se(\beta_{Yi})^2}
Find k such that
s_k = \sum_{i = 1}^k w_i < 0.5
and
s_{k+1} = \sum_{i = 1}^{k+1} w_i > 0.5
Calculate the weighted median estimate by extrapolation as:
\theta_{WM} = \theta_k + (\theta_{k+1} - \theta_k) \times \frac{0.5 - s_k}{s_{k+1} - s_k}
The simple median estimate is the same as the weighted median estimate when all the weights are equal. Standard errors for both the simple and weighted median methods are calculated through bootstrapping.
When the weighting is "penalized"
, the weighted method is used, but the contribution of genetic variants with outlying (heterogeneous) ratio estimates to the analysis is downweighted.
The output from the function is a WeightedMedian
object containing:
Type |
The type of weights used: |
Exposure |
A character string giving the name given to the exposure. |
Outcome |
A character string giving the name given to the outcome. |
Estimate |
The value of the causal estimate. |
StdError |
Standard error of the causal estimate calculated using bootstrapping. |
CILower |
The lower bound for the causal estimate based on the estimated bootstrapped standard error and the significance level provided. |
CIUpper |
The upper bound for the causal estimate based on the estimated bootstrapped standard error and the significance level provided. |
Alpha |
The significance level used when calculating the confidence intervals. |
Pvalue |
The p-value associated with the estimate (calculated using |
SNPs |
The number of genetic variants (SNPs) included in the analysis. |
Jack Bowden, George Davey Smith, Philip C Haycock, Stephen Burgess. Consistent estimation in Mendelian randomization with some invalid instruments using a weighted median estimator. Genetic Epidemiology 2016; 40(4):304-314. doi: 10.1002/gepi.21965.
mr_median(mr_input(bx = ldlc, bxse = ldlcse, by = chdlodds, byse = chdloddsse),
weighting = "weighted", iterations = 100)
# iterations is set to 100 to reduce runtime for the mr_median method,
# 10000 iterations are recommended in practice
mr_median(mr_input(bx = ldlc, bxse = ldlcse, by = chdlodds, byse = chdloddsse),
weighting = "simple", iterations = 100)
mr_median(mr_input(bx = ldlc, bxse = ldlcse, by = chdlodds, byse = chdloddsse),
weighting = "penalized", iterations = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.