dynamichazard (version 0.5.0)

predict.ddhazard: Predict method for ddhazard

Description

Predict method for ddhazard.

Usage

# S3 method for ddhazard
predict(object, new_data, type = c("response", "term"),
  tstart = "start", tstop = "stop", use_parallel = F, sds = F,
  max_threads = getOption("ddhazard_max_threads"), ...)

Arguments

object

result of a ddhazard call.

new_data

new data to base predictions on.

type

either "response" for predicted probability of death or "term" for predicted terms in the linear predictor.

tstart

name of the start time column in new_data. It must be on the same time scale as the tstart used in the Surv(tstart, tstop, event) in the formula passed to ddhazard.

tstop

same as tstart for the stop argument.

use_parallel

TRUE if computation for type = "response" should be computed in parallel with the mcmapply. Notice the limitation in the help page of mcmapply.

sds

TRUE if point wise standard deviation should be computed. Convenient if you use functions like ns and you only want one term per term in the right hand site of the formula used in ddhazard.

max_threads

maximum number of threads to use. -1 if it should be determined by a call to detectCores.

...

not used.

Term

The result with type = "term" is a list with the following elements

terms

is a 3D array. The first dimension is the number of bins, the second dimension is rows in new_data and the last dimension is the state space terms.

sds

similar to terms for the point wise confidence intervals using the smoothed co-variance matrices.

fixed_terms

vector of the fixed effect terms for each observation.

Response

The result with type = "response" is a list with the elements below. The function check if there are columns in new_data which's names match tstart and tstop. If not, then each row in new data will get a predicted probability of dying in every bin.

fits

fitted probability of dying.

istart

vector with the index of the first bin the elements in fits is in.

istop

vector with the index of the last bin the elements in fits is in.

Examples

Run this code
# NOT RUN {
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 = list(method = "GMA"))
predict(fit, type = "response", new_data =
 data.frame(time = 0, status = 2, bili = 3))
predict(fit, type = "term", new_data =
 data.frame(time = 0, status = 2, bili = 3))

# }

Run the code above in your browser using DataCamp Workspace