predict.cv.DMR: predict.cv.DMR

View source: R/predict.cv.DMR.R

predict.cv.DMRR Documentation

predict.cv.DMR

Description

Makes predictions from a cv.DMR object (for the model with minimal cross-validated error /the default/ or the smallest model falling under the upper curve of a prediction error plus one standard deviation).

Usage

## S3 method for class 'cv.DMR'
predict(
  object,
  newx,
  type = "link",
  md = "df.min",
  unknown.factor.levels = "error",
  ...
)

Arguments

object

Fitted cv.DMR object.

newx

Data frame of new values for X at which predictions are to be made. The intercept column should NOT be passed in a call to predict.

type

One of: "link", "response", "class". For family="gaussian" for all values of type it gives the fitted values. For family="binomial" and type="link" it returns the linear predictors, for type="response" it returns the fitted probabilities and for type="class" it produces the class labels corresponding to the maximum probability.

md

Value of the model dimension parameter at which predictions are required. The default is md="df.min" value indicating the model minimizing the cross validation error. Alternatively, md="df.1se" can be used, indicating the smallest model falling under the upper curve of a prediction error plus one standard deviation.

unknown.factor.levels

The way of handling factor levels in test data not seen while training a model. One of "error" (the default - throwing an error) or "NA" (returning NA in place of legitimate value for problematic rows).

...

Further arguments passed to or from other methods.

Details

Similar to other predict methods, this function predicts fitted values from a fitted cv.DMR object.

Value

Vector of predictions.

Examples

## cv.DMR for linear regression
set.seed(13)
data(miete)
ytr <- miete$rent[1:1500]
Xtr <- miete$area[1:1500]
Xte <- miete$area[1501:2053]
cv <- cv.DMR(Xtr, ytr)
print(cv)
plot(cv)
coef(cv)
ypr <- predict(cv, newx = Xte)


DMRnet documentation built on Aug. 7, 2023, 5:11 p.m.