## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
data.table::setDTthreads(2)

## ----setup--------------------------------------------------------------------
library(SEQTaRget)

options <- SEQopts(km.curves = TRUE, #asks the function to return survival and risk estimates
                   bootstrap = TRUE, #asks the model to perform bootstrapping
                   bootstrap.nboot = 20) #asks the model for 20 bootstrap samples

## ----running------------------------------------------------------------------
data <- SEQdata
model <- SEQuential(data, id.col = "ID", 
                          time.col = "time", 
                          eligible.col = "eligible",
                          treatment.col = "tx_init",
                          outcome.col = "outcome",
                          time_varying.cols = c("N", "L", "P"),
                          fixed.cols = "sex",
                          method = "ITT", options = options)

## ----outcome, fig.alt="Survival curve by treatment group."--------------------
outcome(model)     # Returns a list of only the outcome models 
km_curve(model)    # Prints the survival curve
risk_data(model)
risk_comparison(model)

