Learn R Programming

qrmix (version 0.9.0)

predict.qrmix: Predict Method for qrmix Fits

Description

Obtains clusters, predictions, or residuals from a fitted qrmix object.

Usage

# S3 method for qrmix
predict(object, newdata = NULL, type = "clusters", ...)

Arguments

object
a fitted object of class "qrmix".
newdata
optional data frame for which clusters, predictions, or residuals will be obtained from the qrmix fitted object. If omitted, the training values will be used.
type
the type of prediction. type = "clusters" (default value) for predicted clusters, "yhat" for the response predicted value corresponding to the predicted cluste, "residuals" for the residuals corresponding to the response predicted values.

...
other argumets passed to other methods.

Value

A vector with predicted clusters, responses, or residuals, depending on type.

Examples

Run this code

data(blood.pressure)

set.seed(8)
sampleInd = sort(sample(1:500, 400))
bpSample1 = blood.pressure[sampleInd,]
bpSample2 = blood.pressure[-sampleInd,]

mod1 = qrmix(bmi ~ ., data = bpSample1, k = 3)

#Cluster assigned to the training values
predict(mod1)

#Residuals corresponding to the response predicted values from mod1 for new data
predict(mod1, newdata = bpSample2, type = "residuals")

Run the code above in your browser using DataLab