knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The goal of matchsurv is to estimate the cumulative excess risk for exposed individuals when matched survival data are available. Excess risk regression models are available on both hazard and cumulative incidence scale. More info in vignette("matchsurv")
.
You can install matchsurv from github with:
# install.packages("devtools") devtools::install_github("cribosch/matchsurv")
and call the package with:
library(matchsurv) ## other useful packages library(timereg) library(geepack) library(ggplot2)
The package works with matched cohort data where the outcome on study is time-to-event. For each exposed individual we have a defined number of unexposed individuals, matched according to some relevant factors (the number of unexposed individuals per exposed can be different). To simulate data:
dhaz<-sim.data.MatchH(5000,5) head(dhaz,10)
Or when working with cumulative incidence functions:
dcif<-sim.data.MatchCR(1000,5) head(dcif, 10)
Further info about the function options are available through vignette()
or example()
.
This is a basic example which shows you how to:
1) estimate the excess risk 2) visualize your results - coefficient estimates and cumulative excess
in both the two settings.
Data set up
example("compdata")
Model estimate
example("matchpropexc")
Data set up
example("compcomp")
Model estimate based on GEE function geepack::geese()
tp<-c(0.5,1,2,5,10,15,25) setdcif1<-compcomp(Event(time=FALSE,time2=time,cause=cause)~X1+X2, data=dcif, cluster=i, idControl=j, time.points=tp, cens.formula=NULL, event=1) exc.cif.mod1<-geese(Rt~-1+factor(h)+X1+X2, data=setdcif1, family="gaussian", #error distribution mean.link = "log", #link function for Rt corstr="independence", #correlation structure id=clust.num, #cluster vector weights=weights #censoring weights )
To visualize the coefficient estimates: summary(model)
To estimate the cumulative baseline excess hazard:
example("exccumhaz")
To plot the cumulative baseline excess hazard:
Note: if your model has strata, you can chose which strata to plot (option: stratas=
, followed by the number of the strata, the first one is number 0). You can also decide to show the relative survival (option: relsurv=TRUE
).
example("excplot")
To visualize the estimated effects:
example("ecif.coef")
To predict the excess cumulative incidence for different covariate values:
example("ecif.pred")
Further info on plotting the results available in vignette("matchsurv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.