predict.streg: Predict Method for Parametric Proportional Hazards Survival...

View source: R/predict.streg.R

predict.stregR Documentation

Predict Method for Parametric Proportional Hazards Survival Models

Description

Obtain model-based predictions from a parametric proportional hazards survival model fitted by streg().

Usage

## S3 method for class 'streg'
predict(object, newdata = NULL, type = "xb", se.fit = FALSE, ...)

Arguments

object

A fitted streg() object.

newdata

Optionally, a data frame in which to look for variables with which to predict. If NULL (the default), predictions will be computed for the data used to fit the model. In this scenario, passing an streg() model fitted with the argument x = TRUE is required.

type

The type of prediction required. The default "xb" is to return the linear predictor. Other possible predictions are the hazard function (type = "hazard") and the survival function (type = "survival").

se.fit

Logical switch indicating if standard errors are required.

...

Not used.

Details

If newdata is omitted the predictions are based on the data used for the fit.

Value

If se.fit = FALSE, a vector with the required predictions.

If se.fit = TRUE a data.frame is returned with a column for the predictions (named fit) and a column for the fitted standard errors (named se.fit).

Note

Standard errors are estimated using the numerical delta method, as implemented in rstpm2::predictnl() — which is equivalent, in principle — to Stata's predictnl command.

Examples


library(streg)
data("kva", package = "streg")

# Fit a model
fit <- streg(Surv(failtime, event) ~ load + bearings, data = kva, distribution = "exp", x = TRUE)

# Predict the hazard for each subject
predict(fit, type = "surv")

# Predict the survival probability, including a standard error for the fitted value
predict(fit, type = "surv", se.fit = TRUE)

# Predictions for a new dataset
nd <- data.frame(failtime = 30, event = 1, load = 10, bearings = 3)
predict(fit, newdata = nd, type = "surv")
predict(fit, newdata = nd, type = "surv", se.fit = TRUE)

ellessenne/streg documentation built on Sept. 19, 2022, 7:34 a.m.