knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
dena
is an R package that aids in preprocessing, modeling, and visualization of categorical time-to-event data and egocentric social network dynamics. This readme file will show you
dena
packagedena
can be used for preprocessing nested time-to-event datadena
's wrapper functions to estimate competing multistate modelsdena
can be used to visualize data and model results, for example: library(dena) data(simdat2) fit <- cmm(Surv(time, type) ~ Covariate2 + Covariate3 + (1 | id), dat = simdat2, verbose = F) plot.cmm(fit[[1]])
You can install the development version of dena from GitHub with:
# install.packages("devtools") devtools::install_github("timonelmer/dena")
dena
can be loaded with the following function
library(dena)
When analyzing (categorical) time-to-event data of multiple participants, we enounter often data of the following format:
data(simdat2) # loading the example dataset head(simdat2[,c(1,2,3,7,5)])
with the meanCenteringNested
function, we can mean center variables up to three nesting layers (e.g., within participants, within burst, within week).
simdat2 <- meanCenteringNested(dat = simdat2, vars = c("Covariate1","Covariate2"), nestVars = "id", verbose = F) head(simdat2[,c("id","Covariate1","Covariate1_id_MeanC","Covariate1_id_Mean")])
or we can lag variables:
simdat2 <- lagVarsNested(dat = simdat2, lags = 1, vars = c("Covariate1","Covariate2"), nestVars = "id", verbose = F) head(simdat2[,c("id","Covariate1","Covariate1Lag1")])
The cmm
function, for example, is a wrapper function for fitting multiple coxme
functions with multiple categorical target states (a so-called competing risk model)
fit <- cmm(formula = Surv(time, type) ~ Covariate2 + Covariate3 + (1 |id), dat = simdat2, catVar = "type", from = NULL, verbose = F) fit[[1]] # summary of fixed effects estimates
data(simdat) survivalFunction(simdat, "time")
Visualizing the transitions between (interaction) states
plotTransitionNetwork(dat = simdat2, title = "ID = all", type ="sum",catVar = "type")
Visualizing coxme
and coxph
model estimates:
model1 <- coxme(Surv(time, event) ~ Covariate1 + Covariate2 + (1 | id), dat = simdat2) plot.coxme(model1)
Visualizing multistate model results:
fit <- cmm(Surv(time, type) ~ Covariate2 + Covariate3 + (1 | id), dat = simdat2) plot.cmm(fit[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.