| Title: | Non-Linear Mendelian Randomization On Partially Summarized Data |
|---|---|
| Description: | Runs non-linear MR calculations on partly-summarized data. |
| Authors: | Amy Mason [aut, cre] (ORCID: <https://orcid.org/0000-0002-8019-0777>), Stephen Burgess [aut], James Staley [aut], Matt Arnold [aut] |
| Maintainer: | Amy Mason <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-26 14:59:56 UTC |
| Source: | https://github.com/amymariemason/SUMnlmr |
Hunt dataset containing the allele score-associations with bmi and all cause mortality, by 100 quantiles of residual BMI. As used in the paper "Body mass index and all cause mortality in HUNT and UK Biobank studies: linear and non-linear mendelian randomisation analyses" https://doi.org/10.1136/bmj.l1042
bmi_acmbmi_acm
A data frame with 100 rows and 5 variables:
linear association between BMI and allele score, adjusted for age, sex and age-squared
standard error for the beta_bmi term from the linear regression
Cox proportional hazards regression association between all cause mortality and allele score, adjusted for age and sex
standard error for the beta_acm term from the Cox regression
Average BMI in stratum
...
generates individual level data with a single genetic variant
create_ind_data( N, gpar = 0.3, par1 = 1, par2 = 0, beta0 = 0, beta1 = 3, beta2 = 7, confound = 0.8 )create_ind_data( N, gpar = 0.3, par1 = 1, par2 = 0, beta0 = 0, beta1 = 3, beta2 = 7, confound = 0.8 )
N |
number of individuals to create |
gpar |
genetic parameter; used to create g: single genetic snp, from a binomial distribution with n=2 and p = gpar. |
par1 |
power parameter for fractional poly generation. See details |
par2 |
power parameter for fractional poly generation. . See details. |
beta0 |
covariate parameter. See details |
beta1 |
covariate parameter. See details |
beta2 |
covariate parameter. See details |
confound |
confounding parameter,c. See details. |
data A data-frame containing the values of g, the genetic variate;
X, the exposure; and a variety of Y, the outcome values, including
y.bin, a binary outcome generated from a logistic model of X.
This function generates a database with genetic relationships suitable
for evaluating non-linear MR relationships.
A unknown covariate,u, is generated as a N(0,1) variable.
Error terms are generated: Ex ~exp(1) and for Ey ~ N(0,1)
Outcomes are as follows
Linear:
Quadratic
Squareroot
Log
Threshold if and
otherwise
fracpoly
with the usual adaptions for p=0 or p_1=p_2
Amy Mason
create_nlmr_summary Takes individual level data and creates summarized dataset, ready to save and share for summarized non-linear analysis
create_nlmr_summary( y, x, g, covar = NULL, gxe_covar = NULL, gxe_interaction = NULL, strata_method = "ranked", x_corrected = NULL, x_strata = NULL, family = "gaussian", controlsonly = FALSE, q = 10, prestrat = 1, strata_bound = c(0.2, 0.1, 0.8, 0.9), extra_statistics = FALSE, report_GR = FALSE, report_het = FALSE, return_assignment = FALSE, seed = 1234 )create_nlmr_summary( y, x, g, covar = NULL, gxe_covar = NULL, gxe_interaction = NULL, strata_method = "ranked", x_corrected = NULL, x_strata = NULL, family = "gaussian", controlsonly = FALSE, q = 10, prestrat = 1, strata_bound = c(0.2, 0.1, 0.8, 0.9), extra_statistics = FALSE, report_GR = FALSE, report_het = FALSE, return_assignment = FALSE, seed = 1234 )
y |
vector of outcome values. |
x |
vector of exposure values. |
g |
the instrumental variable. |
covar |
An optional matrix of covariates used in deriving the stratification
and the genetic associations with the exposure and the outcome within the strata.
When using |
gxe_covar |
An optional matrix of covariates used in deriving the
stratification when using the |
gxe_interaction |
An optional matrix of covariates used as effect
modifiers in deriving the stratification when using the |
strata_method |
What method to use for determining strata. There are
three options |
x_corrected |
An optional numeric vector used if method is |
x_strata |
An optional numeric vector used to replace the stratification calculation with the supplied strata assignment. Only use this if you have precalculated the strata and just want the genetic associations within those strata. |
family |
A description of the error distribution and link function to be
used in the model. It must be one of |
controlsonly |
Only applied if family is |
q |
The number of quantiles the exposure distribution is to be split into. Within each quantile a causal effect will be estimated, known as a localised average causal effect (LACE). The default is deciles (i.e. 10 quantiles). |
prestrat |
Only applied if method is |
strata_bound |
This controls what range to use for the LACE estimates in
the graphical display. By default, this is taken conservatively as the 10th and
90th percentile of internal strata and the 20th and 80th for the bottom of the
lowest stratum and top of the highest stratum. It is supplied as a vector of percentiles
(lower bottom stratum, lower other, higher top stratum, higher other).
This only impacts the |
extra_statistics |
This will add a second output reporting extra statistics for each stratum. These include the true max and min of the strata (regardless of strata_bound setting) and the F statistic and p-value for the regressions. |
report_GR |
This will add the Gelman-Rubin statistics for each stratum
to the output. Note this only works if the strata method is |
report_het |
This will add p-values for assessing the heterogeneity of the instrument - exposure relationship. The first column is the p-value of the Cochran Q heterogeneity test (Q); the second column is the p-value from the trend test (trend). |
return_assignment |
Reports the strata assignment of each participant, to assist in examining stratum distributions. |
seed |
The random seed to use when generating the quantiles
(for reproducibility). If set to |
Given vectors of an exposure x, an outcome y and an instrument g, as
well as a matrix of covariates E, this package implements
several possible models for stratifying over the exposure values.
The simplest of these the residual method ("residual"), as described in
Staley and Burgess,2017 https://doi.org/https://doi.org/10.1002/gepi.22041. where we
regress x on the genetic instrument and the covariate matrix E
where \beta_E is a suitable vector of coefficients, and calculate the residual value
Once the strata are formed, the genetic associations with x and y are calculated,
including the covariates matrix E e.g.
with and returned for each stratum.
This method performs poorly unless the genetic effects on the exposure are constant.
This assumption is often implausible, and thus this approach is not recommended.
See Burgess, 2023 https://doi.org/https://doi.org/10.1159/000531659.
The second option is "ranked", using Haodong Tian's double ranked method
to calculate strata. See Tian et al, 2022 <doi: https://doi.org/10.1101/2022.06.28.497930>
for more details on this method. However, there are concerns about this method's application, particularly in UK Biobank,
with thanks to Hamiliton et al, 2023 <doi: https://doi.org/10.1007/s10654-024-01113-9> for their
examples of this. In particular, this method performs poorly when there is a
GxE interaction, as explained in Zhao et al, 2026 <doi: https://doi.org/10.64898/2026.01.22.26344640>
The final method "interaction" is an extension of the ranked method developed
specifically to mitigate GxE-induced bias in that method, as detailed in
Zhou et al, 2026 <doi: https://doi.org/10.64898/2026.01.22.26344640>.
In this method, an interaction model is first fitted using two
additional matrices, passed using the gxe_covar (F, covariates) and
gxe_interaction (H, effect modifiers).
Then an interaction corrected value of X,
is used to form strata using the ranked method.
Within the strata, the associations with exposure and outcome are then
calculated using the usual covar covariate matrix E e.g.
with and returned for each stratum.
The two matrices supplied in gxe_covar and gxe_interaction are used to allow
flexibility in choice of models for correcting potential GxE interactions.
A list containing summary data and optional diagnostics.
summary: data frame with one row per stratum containing
bx, by, bxse, byse, xmean, xmin, and
xmax.
Dropped: always returned; integer giving the number of
individuals removed due to missing values in any of y, x,
g, covar, gxe_covar, gxe_interaction,
x_corrected, or x_strata. A message is also printed when
this value is greater than zero.
strata_statistics: returned when
extra_statistics = TRUE; per-stratum min/max of x and y,
mean x, and exposure-model F statistic.
GR_max: maximum Gelman–Rubin statistic for ranked strata.
GR_results: full Gelman–Rubin output when
report_GR = TRUE and strata_method = "ranked" or "interaction".
Heterogeneity_results: heterogeneity/trend test p-values when
report_het = TRUE and strata_method = "ranked" or "interaction".
Strata_assignment: strata assignment for each participant when
return_assignment = TRUE
Amy Mason
create_summary_data generates semi-summarized level data
create_summary_data( Ytype, q = 10, keep = FALSE, family = "gaussian", controlsonly = "TRUE", ... )create_summary_data( Ytype, q = 10, keep = FALSE, family = "gaussian", controlsonly = "TRUE", ... )
Ytype |
The relationship between X and Y; can be "linear", "quad", "sqrt", "log", "threshold" or "fracpoly" |
q |
The number of quantiles. |
keep |
Whether to retain the individual level data as well as the summary data |
family |
a description of the error distribution and link function to be used in the model. For piecewise_mr this can be a character string naming either the gaussian (i.e. "gaussian" for continuous data) or binomial (i.e. "binomial" for binary data) family function. |
controlsonly |
whether to estimate the gx association in all people, or in controls only. This is set to TRUE as default. It has no effect if family is set to "gaussian" |
... |
parameters passed to mr_create_data for control of X-Y relationship |
summary A data-frame containing the semi-summarised beta_X and beta_Y values, mean of X_0, mean of X, max of X and min of X for each quantile.
Amy Mason
frac_poly_summ_mr performs instumental variable analysis by fitting fractional polynomial models to localised average causal effects using meta-regression.
Please note that if you provide synthetic data that are too regular (eg the by associations are all zero or the xmean values are exactly 1, 2, 3, ...), the function may error as several fractional polynomials provide the same fit.
frac_poly_summ_mr( by = NULL, bx = NULL, byse = NULL, bxse = NULL, xmean = NULL, summ = NULL, method = "FE", d = "both", powers = c(0, -2, -1.5, -1, -0.5, 1, 2), pd = 0.05, average.exposure.associations = FALSE, ci = "model_se", nboot = 100, fig = FALSE, family = "binomial", offset = 0, pref_x = "x", pref_y = "y", ref = NA, ci_type = "overall", breaks = NULL, ylim_lower = NA, ylim_upper = NA, xlim_lower = NA, xlim_upper = NA, seed = 335 )frac_poly_summ_mr( by = NULL, bx = NULL, byse = NULL, bxse = NULL, xmean = NULL, summ = NULL, method = "FE", d = "both", powers = c(0, -2, -1.5, -1, -0.5, 1, 2), pd = 0.05, average.exposure.associations = FALSE, ci = "model_se", nboot = 100, fig = FALSE, family = "binomial", offset = 0, pref_x = "x", pref_y = "y", ref = NA, ci_type = "overall", breaks = NULL, ylim_lower = NA, ylim_upper = NA, xlim_lower = NA, xlim_upper = NA, seed = 335 )
by |
vector of gene-outcome associations. |
bx |
vector of gene-exposure associations. |
byse |
vector of standard errors of gene-outcome associations. |
bxse |
vector of standard errors of gene-exposure associations. |
xmean |
average value of the exposure in each stratum (or whatever summary of the exposure level in the stratum is desired). |
summ |
a dataframe contains bx, by, bxse, byse, xmean. This is the
summary output of the |
method |
meta-regression method parsed to the rma package. The default is fixed-effects ('FE'). |
d |
fractional polynomial degree. The default is degree 1. The other options are: 1, 2, or 'both'. |
powers |
fractional polynomial powers to test. |
pd |
p-value cut-off for choosing the best-fitting fractional polynomial of degree 2 over the best-fitting fractional polynomial degree 1. This option is only used if d='both'. The default is 0.05. |
average.exposure.associations |
TRUE means that the bx estimates are averaged across strata, FALSE means that they are not. Default option is FALSE. |
ci |
the type of 95\% confidence interval. There are three options: (i) using the model standard errors ('model_se'), (ii) using bootstrap standard errors ('bootstrap_se'), (iii) using bootstrap percentile confidence intervals ('bootstrap_per'). The default is the model standard errors. |
nboot |
the number of bootstrap replications (if required). The default is 100 replications. |
fig |
a logical statement as to whether the user wants the results displayed in a figure. The default is false. |
family |
a character string named either |
offset |
offset on the x-axis (default is zero). |
pref_x |
the prefix/label for the x-axis. The default is 'x'. |
pref_y |
the prefix/label for the y-axis. The default is 'y'. |
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.
If |
ci_type |
the type of confidence interval to be displayed on the graph. The default is 'overall' where confidence intervals are presented as bands across the range of x. The alternative option is 'quantile' where the confidence intervals are presented as error bars at the mean in each quantile of x. |
breaks |
breaks on the y-axis of the figure. |
ylim_lower |
lower limit for the y-axis of the figure. |
ylim_upper |
upper limit for the y-axis of the figure. |
xlim_lower |
lower limit for the x-axis of the figure. |
xlim_upper |
upper limit for the x-axis of the figure. |
seed |
The random seed to use when generating the bootstrap samples (for reproducibility). If set to |
model the model specifications. The first column is the number of quantiles (q); the second column is the position used to relate x to the LACE in each quantiles (xpos); the third column is the type of confidence interval constructed (ci); the fourth column is the number of bootstrap replications performed (nboot).
powers the powers of the chosen polynomial.
coefficients the regression estimates. The first column is the regression coefficients (beta); the second column is the standard errors of regression coefficients (se); the third column is the lower confidence interval (lci); the fourth column is the upper confidence interval (uci); the fifth column is the p-value (pval).
lace the localised average causal effect estimate in each quantile. The first column is the regression coefficients (beta); the second column is the standard errors of regression coefficients (se); the third column is the lower confidence interval (lci); the fourth column is the upper confidence interval (uci); the fifth column is the p-value (pval).
xcoef the association between the instrument and the exposure in each quantile. The first column is the regression coefficients (beta); the second column is the standard errors of regression coefficients (se).
p_tests the p-value of the non-linearity tests. The first column is the p-value of the test between the fractional polynomial degrees (fp_d1_d2); the second column is the p-value from the fractional polynomial non-linearity test (fp); the third column is the p-value from the quadratic test (quad); the fourth column is the p-value from the Cochran Q test (Q). The first column is the p-value of the Cochran Q heterogeneity test (Q); the second column is the p-value from the trend test (trend).
figure ggplot command to produce a figure.
Stephen Burgess [email protected], leaning heavily on James R Staley [email protected]
Simulated individual-level data generated by create_ind_data,
used in package examples and tests.
generated_datagenerated_data
A data frame with 10000 rows and 12 variables:
gene count of 0, 1 or 2. Distributed binomial with n=2 and p=0.3
"unmeasured" confounder, Uniform(0,1)
Error term for X, ~Exp(1)
Error term for Y, ~N(0,1)
Exposure. X = 2 + 0.25*g + u + errorX
Linear outcome. Y = X + 0.8u + errorY
Quadratic outcome. Y = 2X^2 + X + 0.8u + errorY
Square root outcome.
Log outcome.
if , otherwise
Binary outcome. Bernoulli with probability , centred
Fractional polynomial outcome.
Generated with set.seed(1234) and
create_ind_data(N = 10000, beta2 = 2, beta1 = 1).
Dataset was regenerated on 2026-05-06 to add the y.bin column.
getGRvalues calculates the the Gelman–Rubin (GR) statistics for each strata (i.e. LACE-strata) as described in Haodong's paper on doubly-ranked methods in Text S1
getGRvalues(X = X, Zstratum = Zstratum, NC = 2, tl = 1.02)getGRvalues(X = X, Zstratum = Zstratum, NC = 2, tl = 1.02)
X |
vector of coarsened exposures |
Zstratum |
vector of pre-strata index column |
NC |
number of chains - a lower NC is encouraged |
tl |
threshold level, should be >1 |
max_GR is the maximum G-R statistic accross all strata
statified_strata is a list of the strata where the GR-statistic meets the threshold limit
GR_values is a table of the a and b values for each strata
Haodong Tian for underlying code, Amy Mason for conversion to R function [email protected]
#Toy data example------------------------------------------------------------------ N<-10000 #N is the total ssample size Z<-rnorm( N,0,0.5 ) # instrument U1<-rnorm(N,0,1) U2<-rnorm(N,0,1) #U2 is confounder h_X<-function(Z){ 0.5*Z } X<-h_X(Z)+U2+U1 fitX<-lm( X~Z ) RR<-as.numeric(summary(fitX)$r.squared[1]) No<-1000 #No is the number of pre-strata (i.e. IV-strata) X_<-X # true exact X X<-round(X) #coarsened by round dat<-cbind( Z, X, X_) # X: coarsened exposure; X_: exact exposure dat_order<-dat[ order(dat[,1] ), ] #ordered by Z dat_order<-cbind( dat_order , sort(rep( 1:No, N/No ))) dat_order<-as.data.frame( dat_order ) names(dat_order)<-c( 'Z_order', 'X','X_' ,'ZStratum') getGRvalues( X=dat_order$X, Zstratum = dat_order$ZStratum, NC=2, tl = 1.02 ) #--------------------------------------------------------------------------------------#Toy data example------------------------------------------------------------------ N<-10000 #N is the total ssample size Z<-rnorm( N,0,0.5 ) # instrument U1<-rnorm(N,0,1) U2<-rnorm(N,0,1) #U2 is confounder h_X<-function(Z){ 0.5*Z } X<-h_X(Z)+U2+U1 fitX<-lm( X~Z ) RR<-as.numeric(summary(fitX)$r.squared[1]) No<-1000 #No is the number of pre-strata (i.e. IV-strata) X_<-X # true exact X X<-round(X) #coarsened by round dat<-cbind( Z, X, X_) # X: coarsened exposure; X_: exact exposure dat_order<-dat[ order(dat[,1] ), ] #ordered by Z dat_order<-cbind( dat_order , sort(rep( 1:No, N/No ))) dat_order<-as.data.frame( dat_order ) names(dat_order)<-c( 'Z_order', 'X','X_' ,'ZStratum') getGRvalues( X=dat_order$X, Zstratum = dat_order$ZStratum, NC=2, tl = 1.02 ) #--------------------------------------------------------------------------------------
iv_free computes the IV-free exposure.
iv_free( y, x, g, covar = NULL, gxe_covar = NULL, gxe_interaction = NULL, q = 10, controlsonly = T, family = "gaussian" )iv_free( y, x, g, covar = NULL, gxe_covar = NULL, gxe_interaction = NULL, q = 10, controlsonly = T, family = "gaussian" )
y |
vector of outcome values. |
x |
vector of exposure values. |
g |
the instrumental variable. |
covar |
a matrix of covariates. |
gxe_covar |
a matrix of covariates for use in the interaction correction |
gxe_interaction |
a matrix of covariates to use as interaction terms in the interaction correction |
q |
the number of quantiles the exposure distribution is to be split into. The default is deciles (i.e. 10 quantiles). |
controlsonly |
whether to estimate the gx association in all people,
or in controls only. This is set to TRUE by default, but only takes effect
when |
family |
the outcome family; one of |
xcoef |
the association between the exposure and the instrument |
x0 |
the IV-free exposure if covar is supplied OR the interaction free exposure if an interaction term is supplied. |
x0q |
the quantiles of x0. |
Amy Mason [email protected] based on similar function in nlmr by James R Staley
UK Biobank dataset containing the allele score-associations with ldl-cholesterol and CAD diagnosis, by 10 quantiles of residual ldl.
LDL_CADLDL_CAD
A data frame with 10 rows and 8 variables:
linear association between ldl-cholesterol and allele score, unadjusted
logistic regression coefficent between CAD diagnosis and allele score, unadjusted
standard error for the bx term from the linear regression
standard error for the by term from the logistic regression
Average ldl in stratum
Minimum ldl in stratum
Maximum ldl in stratum
...
UK Biobank dataset containing the allele score-associations with ldl-cholesterol and CAD diagnosis adjusted for age, sex and first 10 principle components, by 10 quantiles of residual ldl.
LDL_CAD_covarLDL_CAD_covar
A data frame with 10 rows and 8 variables:
linear association between ldl-cholesterol and allele score, adjusted
logistic regression coefficent between CAD diagnosis and allele score, adjusted
standard error for the bx term from the linear regression
standard error for the by term from the logistic regression
Average ldl in stratum
Minimum ldl in stratum
Maximum ldl in stratum
...
function to obtain the lower coefficient values
(i.e. b in Text S1) for each pre-strata
lowfun(vec)lowfun(vec)
vec |
input vector |
piecewise_figure plots the piecewise linear function.
piecewise_summ_figure( xcoef, coef, xmean, lci, uci, xbreaks, family = "gaussian", ref = mean(xmean), pref_x = "x", pref_x_ref = "x", pref_y = "y", breaks = NULL, ci_fig = "point" )piecewise_summ_figure( xcoef, coef, xmean, lci, uci, xbreaks, family = "gaussian", ref = mean(xmean), pref_x = "x", pref_x_ref = "x", pref_y = "y", breaks = NULL, ci_fig = "point" )
xcoef |
the association between the exposure and the instrument. |
coef |
the coefficients of the localized causal effects. |
xmean |
mean of each x stratum (for plotting point estimates) |
lci |
upper confidence interval range for each causal effects |
uci |
upper confidence interval range for each causal effects. |
xbreaks |
breakpoints in x (for plotting line estimates) |
family |
a description of the error distribution and link function to be used in the model. This is a character string naming either the gaussian (i.e. "gaussian" for continuous data) or binomial (i.e. "binomial" for binary data) family function. |
ref |
the reference point for the figure. This is the value of the that represents the expected difference in the outcome compared with this reference value when the exposure is set to different values. The default is the mean of x. |
pref_x |
the prefix/label for the x-axis. The default is "x". |
pref_x_ref |
the prefix for the reference value displayed on the y-axis. The default is "x". |
pref_y |
the prefix/label for the y-axis. The default is "y". |
breaks |
breaks on the y-axis of the figure. |
ci_fig |
point confidence intervals, or as ribbon ("point" or "ribbon") |
the plot of the piecewise linear function.
Amy Mason [email protected], leaning on work by James Statley and Matt Arnold
piecewise_summ_mr performs instumental variable analysis by fitting piecewise linear functions to localised average causal effects
piecewise_summ_mr( by = NULL, bx = NULL, byse = NULL, bxse = NULL, xmean = NULL, xmin = NULL, xmax = NULL, summ = NULL, xbreaks = NULL, family = "gaussian", average.exposure.associations = FALSE, ci = "model_se", nboot = 1000, fig = T, ref = mean(xmean), pref_x = "x", pref_x_ref = "x", pref_y = "y", breaks = NULL, ci_fig = "point", seed = 875 )piecewise_summ_mr( by = NULL, bx = NULL, byse = NULL, bxse = NULL, xmean = NULL, xmin = NULL, xmax = NULL, summ = NULL, xbreaks = NULL, family = "gaussian", average.exposure.associations = FALSE, ci = "model_se", nboot = 1000, fig = T, ref = mean(xmean), pref_x = "x", pref_x_ref = "x", pref_y = "y", breaks = NULL, ci_fig = "point", seed = 875 )
by |
vector of gene-outcome associations. |
bx |
vector of gene-exposure associations. |
byse |
vector of standard errors of gene-outcome associations. |
bxse |
vector of standard errors of gene-exposure associations. |
xmean |
average value of the original exposure in each iv-free strata (or whatever summary of the exposure level in the stratum is desired). |
xmin |
min value of the original exposure in each stratum (see note) |
xmax |
max value of the original exposure in each stratum (see note) |
summ |
a dataframe contains bx, by, bxse, byse, xmean. This is the
summary output of the |
xbreaks |
break points for the stratum x values (see note) |
family |
a character string named either |
average.exposure.associations |
TRUE means that the bx estimates are averaged across strata, FALSE means that they are not. Default option is FALSE. |
ci |
the type of 95\% confidence interval. There are four options: (i) using the model standard errors ('model_se'), (ii) using bootstrap standard errors ('bootstrap_se'), (iii) using bootstrap percentile confidence intervals ('bootstrap_per') The default is the model standard errors. |
nboot |
the number of bootstrap replications (if required). The default is 1000 replications. |
fig |
a logical statement as to whether the user wants the results displayed in a figure. The default is false. |
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. The default is the mean of x. |
pref_x |
the prefix/label for the x-axis. The default is "x". |
pref_x_ref |
the prefix for the reference value displayed on the y-axis. The default is "x". |
pref_y |
the prefix/label for the y-axis. The default is "y". |
breaks |
breaks on the y-axis of the figure. |
ci_fig |
setting confidence interval type. "point" places error bars at the mean of each stratum; "ribbon" draws upper and lower piecewise lines. |
seed |
The random seed to use when generating the bootstrap samples (for reproducibility). If set to |
model the model specifications. The first column is the number of quantiles (q); the second column is the position used to relate x to the LACE in each quantiles (xpos); the third column is the type of confidence interval constructed (ci); the fourth column is the number of bootstrap replications performed (nboot).
powers the powers of the chosen polynomial.
coefficients the regression estimates. The first column is the regression coefficients (beta); the second column is the standard errors of regression coefficients (se); the third column is the lower confidence interval (lci); the fourth column is the upper confidence interval (uci); the fifth column is the p-value (pval).
The non-linearity tests uses 'method="DL"' to calculate the p-value for the hetrogeneity trend. The fractional polynomial equivalent function allows you to set the method, meaning you may get different results.
There is no option for covariates; they would need to be applied at an earlier stage in the individual data, using the mr_summarise function.
The min and max of x stratum values are used to choose the appropiete range for fitting of each causal estimate. In the code for summarising data, this is set at the 10% point, and the 90% of each stratum; 20% and 80% in the external ends of the end strata. The first lower value and all upper value are used to set the break points for the estimates in the graph. Alternatively you can hardset this using xbreaks.
Amy Mason, leaning heavily on work by James Statley and Matt Arnold
summary method for class 'frac_poly_mr'.
## S3 method for class 'frac_poly_mr' print(x, ...)## S3 method for class 'frac_poly_mr' print(x, ...)
x |
an object of class 'frac_poly_mr'. |
... |
additional arguments affecting the summary produced. |
James R Staley [email protected]
print.summary method for class 'frac_poly_mr'.
## S3 method for class 'summary.frac_poly_mr' print(x, ...)## S3 method for class 'summary.frac_poly_mr' print(x, ...)
x |
an object of class 'frac_poly_mr'. |
... |
additional arguments affecting the summary produced. |
James R Staley [email protected]
print summary method for class "piecewise_mr".
## S3 method for class 'summary.piecewise_summ_mr' print(x, ...)## S3 method for class 'summary.piecewise_summ_mr' print(x, ...)
x |
an object of class "piecewise_mr". |
... |
Arguments to be passed to or from other methods, |
Amy Mason [email protected]
This function creates a matrix of a repeated vector where each row is the same.
reprow(x, n)reprow(x, n)
x |
vector to be repeated |
n |
number of repeats |
James R Staley [email protected]
summary method for class 'frac_poly_mr'.
## S3 method for class 'frac_poly_mr' summary(object, ...)## S3 method for class 'frac_poly_mr' summary(object, ...)
object |
an object of class 'frac_poly_mr'. |
... |
additional arguments affecting the summary produced. |
James R Staley [email protected]
summary method for class "piecewise_summ_mr".
## S3 method for class 'piecewise_summ_mr' summary(object, ...)## S3 method for class 'piecewise_summ_mr' summary(object, ...)
object |
an object of class "piecewise_summ_mr". |
... |
Arguments to be passed to or from other methods, |
Amy Mason [email protected]
function to obtain the upper coefficient values (i.e. a in Text S1) for
each pre-strata
upfun(vec)upfun(vec)
vec |
input vector |