# \donttest{
# Clear workspace
rm(list = ls())
# Load the survival package
library(survival)
# Set random seed
set.seed(123)
# Load and preprocess data
data <- survival::lung
data[, "intercept"] <- rep(1, nrow(data))
data[, "status"] <- data[, "status"] - 1
data <- data[, c("time", "status", "intercept", "age", "sex")]
colnames(data) <- c("Y", "Delta", "X0", "X1", "X2")
# Standardize age variable
data[, "X1"] <- scale(data[, "X1"])
## Example:
## - Link function: AFT link function (default setting)
## - Number of IF: 5 IF per continuous covariate (default setting)
## - Search method: Binary search
## - Type of IF: Cubic spline functions for continuous covariate, indicator
## function for discrete covariate (default setting).
# Settings for main estimation function
idx.param.of.interest <- 2 # Interest in effect of age
idxs.c <- 1 # X1 (age) is continuous
t <- 200 # Model imposed at t = 200
search.method <- "GS" # Use binary search
par.space <- matrix(rep(c(-10, 10), 3), nrow = 3, byrow = TRUE)
add.options <- list()
picturose <- TRUE
parallel <- FALSE
# Estimate the identified intervals
pi.surv(data, idx.param.of.interest, idxs.c, t, par.space,
search.method = search.method, add.options = add.options,
picturose = picturose, parallel = parallel)
# }
Run the code above in your browser using DataLab