predict.OHPL: Make Predictions Based on the Fitted OHPL Model

View source: R/predict.OHPL.R

predict.OHPLR Documentation

Make Predictions Based on the Fitted OHPL Model

Description

Make predictions on new data by an OHPL model object.

Usage

## S3 method for class 'OHPL'
predict(object, newx, ncomp = NULL, type = "response", ...)

Arguments

object

An object of class OHPL fitted by OHPL.

newx

Predictor matrix of the new data.

ncomp

Optimal number of components. If is NULL, the optimal number of components stored in the model object will be used.

type

Prediction type.

...

Additional parameters.

Value

Numeric matrix of the predicted values.

Examples

# generate simulation data
dat <- OHPL.sim(
  n = 100, p = 100, rho = 0.8,
  coef = rep(1, 10), snr = 3, p.train = 0.5,
  seed = 1010
)

# split training and test set
x <- dat$x.tr
y <- dat$y.tr
x.test <- dat$x.te
y.test <- dat$y.te

# fit the OHPL model
fit <- OHPL(x, y, maxcomp = 3, gamma = 0.5, G = 10, type = "max")
# make predictions
y.pred <- predict(fit, x.test)
y.pred

road2stat/OHPL documentation built on Feb. 4, 2023, 6:24 a.m.