glsmr: GAM and linear-strata Mendelian randomization

View source: R/glsmr.R

glsmrR Documentation

GAM and linear-strata Mendelian randomization

Description

This function derives strata defined observational and TSLS (MR) estimates using linear modeling. The full data set will be fit to a linear model and a generalized linear model (GAM). Then subsequently the exposure data will be stratified and a linear model will be used to derive effect estimates for each strata.

Usage

glsmr(
  wdata,
  outcome = NA,
  exposure = NA,
  instrument = NA,
  linear_covariates = NA,
  smooth_covariates = NA,
  strata = 4,
  rnt_outcome = FALSE,
  weights_variable = NA,
  outlier_method = "iqr",
  outlier_cutoff = 5,
  messages = FALSE,
  return_models = FALSE
)

Arguments

wdata

a data frame passed to function containing necessary data for analysis

outcome

a single string character of the column name for the outcome or dependent or response variable

exposure

a single string character of the column name for the exposure or independent or explanatory variable

instrument

a data frame passed to function containing necessary data for analysis

linear_covariates

a vector of string(s) that are also column names used to define variables that will be set as parametric (linear) covariates.

smooth_covariates

a vector of string(s) that are also column names used to define variables that will be set as non-linear (smooth, s()) covariates.

strata

a single integer or vector to define how strata should be defined. * 'strata = 4': will define quartiles or 4 evenly sized bins * 'strata = 10': will define deciles or 10 evenly sized bins * 'strata = c(1,10,20,30)': a user defined numeric vector to define boundaries for each strata. - The numeric vector example provided will define 4 strata. Lower bound values are inclusive, upper bounds are exclusive, to the exception of the last bounding value.

rnt_outcome

binary TRUE or FALSE if the dependent or response variable should be rank normal transformed.

weights_variable

a single string character of the column name for a weights variable

outlier_method

a single string character of "iqr" or "sd" to determine if outlier should be determined by means and sd or medians and iqr.

outlier_cutoff

a single numeric value to define a cutoff value for how many iqr or sd units outlier values

messages

should a progress message be printed to screen - binary TRUE or FALSE

return_models

should the model data data frame and each gam and linear model be returned (TRUE or FALSE). Default is FALSE.

Value

returns a glsmr object containing the complete linear and GAM models for the full data set, summary statistics for the data, a strata observational table, and a strata TSLS (MR) table.

Examples

glsmr()

hughesevoanth/glsmr documentation built on May 14, 2023, 3:41 p.m.