## knitr configuration: http://yihui.name/knitr/options#chunk_options library(knitr) showMessage <- FALSE showWarning <- TRUE set_alias(w = "fig.width", h = "fig.height", res = "results") opts_chunk$set(comment = "##", error= TRUE, warning = showWarning, message = showMessage, tidy = FALSE, cache = FALSE, echo = TRUE, fig.width = 7, fig.height = 7, fig.path = "man/figures")
The package require all variables to be numerical. So a multi-categorical factor needs to be converted to dummy variables or multiple dichotomous indicators. For survival outcome models, the indicator variable is for the event (1 = event, 0 = censored).
library(regmedint) library(tidyverse) ## Prepare dataset data(vv2015)
regmedint objectFollowing typical modeling workflow in R (e.g., lm and glm), a constructor function is used to create a model fit object. The summary method is the main user function for examining the results in the object. Lower-level methods such as coef, vcov, and confint are also provided for flexibility. The print method is mainly for meaningful implicit printing when only the object name is evaluated. All methods for the regmedint object has arguments a0, a1, m_cde, and c_cond. These are used to re-evaluate the results without re-fitting the underlying models.
regemedint() object constructorregmedint_obj <- regmedint(data = vv2015, ## Variables yvar = "y", avar = "x", mvar = "m", cvar = c("c"), eventvar = "event", ## Values at which effects are evaluated a0 = 0, a1 = 1, m_cde = 1, c_cond = 0.5, ## Model types mreg = "logistic", yreg = "survAFT_weibull", ## Additional specification interaction = TRUE, casecontrol = FALSE)
summary() for regmedintsummary(regmedint_obj) summary(regmedint_obj, exponentiate = TRUE) summary(regmedint_obj, m_cde = 0, c_cond = 1) summary(regmedint_obj, m_cde = 0, c_cond = 1, level = 0.99)
coef() for regmedintcoef(regmedint_obj) coef(regmedint_obj, m_cde = 0, c_cond = 1)
vcov() for regmedintvcov(regmedint_obj) vcov(regmedint_obj, m_cde = 0, c_cond = 1)
confint() for regmedintconfint(regmedint_obj) confint(regmedint_obj, m_cde = 0, c_cond = 1) confint(regmedint_obj, m_cde = 0, c_cond = 1, level = 0.99)
print() for regmedintregmedint_obj # Implicit printing print(regmedint_obj) print(regmedint_obj, m_cde = 0, c_cond = 1)
summary_regmedintThe summary method for the regmedint object returns an object of class summary_regmedint. To extract the mediation analysis result table as a matrix, use the coef method.
coef() for summary_regmedintcoef(summary(regmedint_obj))
print() for summary_regmedintregmedint_summary_obj <- summary(regmedint_obj) regmedint_summary_obj # Implicit printing print(regmedint_summary_obj)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.