## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup-------------------------------------------------------------------- library(redeem) ## ----data--------------------------------------------------------------------- # Simulated instantaneous event sequence n_nodes <- 10 events <- matrix(c( 1.0, 1, 2, 1.5, 3, 4, 2.0, 2, 1, 2.8, 1, 3, 3.5, 4, 3, 4.0, 1, 4 ), ncol = 3, byrow = TRUE) colnames(events) <- c("time", "from", "to") ## ----fit---------------------------------------------------------------------- # Fit the Relational Event Model fit_rem <- rem( events = events, n_nodes = n_nodes, formula = ~1, control = control.redeem(estimate = "Blockwise") ) # View summaries using `summary.redeem_result` summary(fit_rem) ## ----residuals---------------------------------------------------------------- # Extract residuals for diagnostics using `get_residuals()` # Note: Ensure return_data = TRUE was set in `control.redeem()` resids <- get_residuals(fit_rem) # Plot the Kaplan-Meier estimate of the residual survival vs. Theoretical Exp(1) plot(resids$time, resids$surv, type = "l", log = "y", xlab = "Cox-Snell Residuals", ylab = "Survival Probability", main = "Cox-Snell Residual Diagnostic") lines(resids$time, resids$theoretical, col = "red", lty = 2) legend("topright", legend = c("Empirical", "Theoretical Exp(1)"), col = c("black", "red"), lty = 1:2)