Learn R Programming

broom (version 0.4.3)

survreg_tidiers: Tidiers for a parametric regression survival model

Description

Tidies the coefficients of a parametric survival regression model, from the "survreg" function, adds fitted values and residuals, or summarizes the model statistics.

Usage

# S3 method for survreg
tidy(x, conf.level = 0.95, ...)

# S3 method for survreg augment(x, data = stats::model.frame(x), newdata, type.predict = "response", type.residuals = "response", ...)

# S3 method for survreg glance(x, conf.level = 0.95, ...)

Arguments

x

a "survreg" model

conf.level

confidence level for CI

...

extra arguments (not used)

data

original data; if it is not provided, it is reconstructed as best as possible with model.frame

newdata

New data to use for prediction; optional

type.predict

type of prediction, default "response"

type.residuals

type of residuals to calculate, default "response"

Value

All tidying methods return a data.frame without rownames, whose structure depends on the method chosen.

tidy returns a data.frame with one row for each term

term

name of term

estimate

estimate of coefficient

stderror

standard error

statistic

Z statistic

p.value

p-value

conf.low

low end of confidence interval

conf.high

high end of confidence interval

augment returns the original data.frame with the following additional columns:

.fitted

Fitted values of model

.se.fit

Standard errors of fitted values

.resid

Residuals

glance returns a one-row data.frame with the columns:

iter

number of iterations

df

degrees of freedom

statistic

chi-squared statistic

p.value

p-value from chi-squared test

logLik

log likelihood

AIC

Akaike information criterion

BIC

Bayesian information criterion

df.residual

residual degrees of freedom

Details

When the modeling was performed with na.action = "na.omit" (as is the typical default), rows with NA in the initial data are omitted entirely from the augmented data frame. When the modeling was performed with na.action = "na.exclude", one should provide the original data as a second argument, at which point the augmented data will contain those rows (typically with NAs in place of the new columns). If the original data is not provided to augment and na.action = "na.exclude", a warning is raised and the incomplete rows are dropped.

See Also

na.action

Examples

Run this code
# NOT RUN {
if (require("survival", quietly = TRUE)) {
    sr <- survreg(Surv(futime, fustat) ~ ecog.ps + rx, ovarian,
           dist="exponential")

    td <- tidy(sr)
    augment(sr, ovarian)
    augment(sr)
    glance(sr)

    # coefficient plot
    library(ggplot2)
    ggplot(td, aes(estimate, term)) + geom_point() +
        geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) +
        geom_vline(xintercept = 0)
}

# }

Run the code above in your browser using DataLab