dynamichazard (version 0.6.6)

residuals.ddhazard: Residuals Method for ddhazard Object

Description

Residuals method for the result of a ddhazard call.

Usage

# S3 method for ddhazard
residuals(object, type = c("std_space_error",
  "space_error", "pearson", "raw"), data = NULL, ...)

Arguments

object

result of ddhazard call.

type

type of residuals. Four possible values: "std_space_error", "space_error", "pearson" and "raw". See the sections below for details.

data

data.frame with data for the Pearson or raw residuals. This is only needed if the data set is not saved with the object. Must be the same data set used in the initial call to ddhazard.

...

not used.

Pearson and raw residuals

Is the result of a call with a type argument of either "pearson" or "raw" for Pearson residuals or raw residuals. Returns a list with class "ddhazard_residual" with the following elements.

residuals

list of residuals for each bin. Each element of the list contains a 2D array where the rows corresponds to the passed data and columns are the residuals (residuals), estimated probability of death (p_est), outcome (Y) and row number in the initial data set (row_num). The data rows will only have a residuals in a given risk list if they are at risk in that risk set.

type

the type of residual.

State space errors

Is the result of a call with a type argument of either "std_space_error" or "space_error". The former is for standardized residuals while the latter is non-standardized. Returns a list with class. "ddhazard_space_errors" with the following elements:

residuals

2D array with either standardized or non-standardized state space errors. The row are bins and the columns are the parameters in the regression.

standardize

TRUE if standardized state space errors.

Covariances

3D array with the smoothed co-variance matrix for each set of the state space errors.

Examples

Run this code
# NOT RUN {
library(dynamichazard)
fit <- ddhazard(
 Surv(time, status == 2) ~ log(bili), pbc, id = pbc$id, max_T = 3600,
 Q_0 = diag(1, 2), Q = diag(1e-4, 2), by = 50,
 control = ddhazard_control(method = "GMA"))
resids <- residuals(fit, type = "pearson")$residuals
head(resids[[1]])
head(resids[[2]])

# }

Run the code above in your browser using DataCamp Workspace