Skip to content

Instantly share code, notes, and snippets.

@daynebatten
Created December 23, 2015 14:13
Show Gist options
  • Save daynebatten/e7b2e539e64407665876 to your computer and use it in GitHub Desktop.
Save daynebatten/e7b2e539e64407665876 to your computer and use it in GitHub Desktop.
# Load the survival package
library(survival)
# Read in the CSV
data <- read.csv('C:/users/dbatten/desktop/time_varying_covariate.csv')
# Fit a cox model of a survival object on whether or not the user contacted support
fit <- coxph(Surv(start_time, end_time, churned) ~ contacted_support, data = data)
# Have a gander at the results
summary(fit)
# Make sure we haven't violated the proportional hazards assumption
cox.zph(fit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment