View source: R/predict.streg.R
predict.streg | R Documentation |
Obtain model-based predictions from a parametric proportional hazards survival model fitted by streg()
.
## S3 method for class 'streg' predict(object, newdata = NULL, type = "xb", se.fit = FALSE, ...)
object |
A fitted |
newdata |
Optionally, a data frame in which to look for variables with which to predict.
If |
type |
The type of prediction required.
The default |
se.fit |
Logical switch indicating if standard errors are required. |
... |
Not used. |
If newdata
is omitted the predictions are based on the data used for the fit.
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
).
Standard errors are estimated using the numerical delta method, as implemented in rstpm2::predictnl()
— which is equivalent, in principle — to Stata's predictnl
command.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.