Learn R Programming

RobustAFT (version 1.4-7)

predict.TML: Predict method for "TML" objects

Description

Obtains predictions from a fitted Truncated Maximum Likelihood (TML) object.

Usage

# S3 method for TML
predict(object, newdata = NULL, ...)

Value

Returns a vector of predictions.

Arguments

object

An object of class "TML", usually, a result of a call to TML.noncensored or TML.censored.

newdata

Optionally, a vector, a matrix or a data frame containing the variables with which to predict. If omitted, the fitted values of object are returned.

...

Additional arguments affecting the predictions produced.

Details

newdata must have the same number of variables (that is of columns) as the model. If object is a model with an intercept, newdata must have a first column of 1.

See Also

TML.noncensored, TML.censored, predict

Examples

Run this code
if (FALSE) {
     data(D243)
     Cost <- D243$Cost                             # Cost (Swiss francs)
     LOS  <- D243$LOS                              # Length of stay (days)
     Adm  <- D243$Typadm; Adm <- (Adm==" Urg")*1   # Type of admission 
                                                   # (0=on notification, 1=Emergency)

     # Fitting the model
     z    <- TML.noncensored(log(Cost)~log(LOS)+Adm, errors="logWeibull")

     # With a vector of data
     vec  <- c(1, 2.4, 1)
     predict(object = z, newdata = vec)
     # With a matrix of data
     mat  <- matrix(c(1,1,2.4,2.7,1,0), ncol=3)
     predict(z, mat)
     # With a data frame
     dat  <- as.data.frame(cbind("intercept"=c(1,1,1), "log(LOS)"=c(2.4,2.7,2.2), 
             "Adm"=c(1,0,1)))
     predict(z, dat)
}

Run the code above in your browser using DataLab