$$ \begin{aligned} Y(x)=x^2 + 1 \end{aligned} $$
This is most helpful in a situation where the user has continuous data over a series of intervals and believes that the values can be interpolated within each interval. ## Step Function Interaction The second type of time-dependent covariate changes based on conditional statements. One example is a covariate to split data into bins by time. Colossus uses a string to identify where to change value. The user inputs a string of the form "#l?" for a time value "#", a condition "l", and a question mark as a delimiter. Colossus allows for four conditions: * l: less than or equal to * g: greater than or equal to * a: strictly above * b: strictly below So the following would be equivalent to "$0g?6g?12g?$" ```{r, fig.cap='Monotonic Step Function Applied'} dft <- data.table("x" = c(-1, 1, 5, 8, 13), "y" = c(0, 1, 1, 2, 3)) g <- ggplot2::ggplot(dft, ggplot2::aes(x = .data$x, y = .data$y)) + ggplot2::geom_point(color = "black") dft <- data.table("x" = c(-1, -0.01, 0, 1, 5.99, 6, 11.99, 12, 13), "y" = c(0, 0, 1, 1, 1, 2, 2, 3, 3)) g <- g + ggplot2::geom_line(data = dft, ggplot2::aes(x = .data$x, y = .data$y), color = "black") + ggplot2::labs(x = "age (days)", y = "Covariate Value") g ```$$ \begin{aligned} Y(x)=\begin{cases} 0 &(x < 0) \\ 1 & (x \ge 0) \\ 2 &(x \ge 6) \\ 3 &(x \ge 12) \end{cases}\\ \end{aligned} $$
Meanwhile the following is equivalent to "$0g?6g?12l?$" ```{r, fig.cap='Step Function Applied'} dft <- data.table("x" = c(-1, 1, 5, 8, 13), "y" = c(1, 2, 2, 3, 2)) g <- ggplot2::ggplot(dft, ggplot2::aes(x = .data$x, y = .data$y)) + ggplot2::geom_point(color = "black") dft <- data.table("x" = c(-1, -0.01, 0, 1, 5.99, 6, 11.99, 12, 13), "y" = c(1, 1, 2, 2, 2, 3, 3, 2, 2)) g <- g + ggplot2::geom_line(data = dft, ggplot2::aes(x = .data$x, y = .data$y), color = "black") + ggplot2::labs(x = "age (days)", y = "Covariate Value") g ```$$ \begin{aligned} Y(x)=\begin{cases} 1 &(x < 0) \\ 2 & (x \ge 0) \\ 3 &(x \ge 6) \\ 2 &(x \ge 12) \end{cases}\\ \end{aligned} $$
This is most helpful in situations where the user has reason to believe that the effect of a covariate on events is not uniform over time despite the covariate being constant over each interval. This allows the user to generate a list of factors to interact with any covariate of interest. ## Examples of Use The following provide a basic example for each method listed above. We start by setting up the data, which for this example is the cancer data from the R survival package. ```{r} # Setting up the data for use data(cancer, package = "survival") df <- data.table(cancer) df$UserID <- seq_len(nrow(df)) df$status <- df$status - 1 df$sex <- df$sex - 1 t0 <- "%trunc%" t1 <- "time" event <- "status" df <- df[, c("time", "status", "sex", "UserID")] ``` For the first example we will linearly interpolate the product of time and biological sex. ```{r, fig.cap='Linear Interpolation Example'} grt_f <- function(df, time_col) { return((df[, "sex"] * df[, get(time_col)] / 400)[[1]]) } func_form <- c("lin") iscox <- TRUE dt <- 0.01 df_new <- gen_time_dep( df, t0, t1, event, iscox, dt, c("sex_time"), c(), c(grt_f), "test_new.csv", func_form, nthreads = 1 ) g <- ggplot2::ggplot(df_new, ggplot2::aes(x = .data$time, y = .data$sex_time, colour = factor(.data$sex))) + ggplot2::geom_point() + ggplot2::geom_line() + ggplot2::labs(x = "Time", y = "Covariate Value") g ``` For the second example we will use a step functions that increases at 200, 500, and 700 days. ```{r, fig.cap='Monotonic Step Function Example'} func_form <- c("step?0g?200g?500g?700g?") df_new <- gen_time_dep( df, t0, t1, event, iscox, dt, c("time_step"), c(), c(grt_f), "test_new.csv", func_form, nthreads = 1 ) g <- ggplot2::ggplot(df_new, ggplot2::aes(x = .data$time, y = .data$time_step)) + ggplot2::geom_point(color = "black") + ggplot2::geom_line() + ggplot2::labs(x = "Time", y = "Covariate Value") g ``` For the third example we will use a step functions that increases at 200, 400, and 700 days and decreases at 600 and 800 days. ```{r, fig.cap='Step Function Example'} func_form <- c("step?0g?200g?400g?600l?700g?800b?") df_new <- gen_time_dep( df, t0, t1, event, iscox, dt, c("time_step"), c(), c(grt_f), "test_new.csv", func_form, nthreads = 1 ) g <- ggplot2::ggplot(df_new, ggplot2::aes(x = .data$time, y = .data$time_step)) + ggplot2::geom_point(color = "black") + ggplot2::geom_line() + ggplot2::labs(x = "Time", y = "Covariate Value") g ```RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4