SparkR (version 2.1.2)

spark.survreg: Accelerated Failure Time (AFT) Survival Regression Model

Description

spark.survreg fits an accelerated failure time (AFT) survival regression model on a SparkDataFrame. Users can call summary to get a summary of the fitted AFT model, predict to make predictions on new data, and write.ml/read.ml to save/load fitted models.

Usage

spark.survreg(data, formula)

# S4 method for AFTSurvivalRegressionModel,character write.ml(object, path, overwrite = FALSE)

# S4 method for SparkDataFrame,formula spark.survreg(data, formula)

# S4 method for AFTSurvivalRegressionModel summary(object)

# S4 method for AFTSurvivalRegressionModel predict(object, newData)

Arguments

data

a SparkDataFrame for training.

formula

a symbolic description of the model to be fitted. Currently only a few formula operators are supported, including '~', ':', '+', and '-'. Note that operator '.' is not supported currently.

object

a fitted AFT survival regression model.

path

the directory where the model is saved.

overwrite

overwrites or not if the output path already exists. Default is FALSE which means throw exception if the output path exists.

newData

a SparkDataFrame for testing.

Value

spark.survreg returns a fitted AFT survival regression model.

summary returns summary information of the fitted model, which is a list. The list includes the model's coefficients (features, coefficients, intercept and log(scale)).

predict returns a SparkDataFrame containing predicted values on the original scale of the data (mean predicted value at scale = 1.0).

See Also

write.ml

survival: https://cran.r-project.org/package=survival

Examples

Run this code
# NOT RUN {
df <- createDataFrame(ovarian)
model <- spark.survreg(df, Surv(futime, fustat) ~ ecog_ps + rx)

# get a summary of the model
summary(model)

# make predictions
predicted <- predict(model, df)
showDF(predicted)

# save and load the model
path <- "path/to/model"
write.ml(model, path)
savedModel <- read.ml(path)
summary(savedModel)
# }

Run the code above in your browser using DataLab