Learn R Programming

SplitReg (version 1.0.3)

predict.cv.SplitReg: Make predictions from a cv.SplitReg object.

Description

Make predictions from a cv.SplitReg object, similar to other predict methods.

Usage

# S3 method for cv.SplitReg
predict(
  object,
  newx,
  index = object$index_opt,
  type = c("response", "coefficients"),
  ...
)

Value

Either a matrix with predictions or a vector of coefficients

Arguments

object

Fitted cv.SplitReg object.

newx

Matrix of new values of x at which prediction are to be made. Ignored if type is "coefficients".

index

Indices indicating values of lambda_S at which to predict. Defaults to the optimal value.

type

Either "response" for predicted values or "coefficients" for the estimated coefficients.

...

Additional arguments for compatibility.

See Also

predict.cv.SplitReg

Examples

Run this code
library(MASS)
set.seed(1)
beta <- c(rep(5, 5), rep(0, 45))
Sigma <- matrix(0.5, 50, 50)
diag(Sigma) <- 1
x <- mvrnorm(50, mu = rep(0, 50), Sigma = Sigma)
y <- x %*% beta + rnorm(50)
fit <- cv.SplitReg(x, y, num_models=2)
x.new <- mvrnorm(50, mu = rep(0, 50), Sigma = Sigma)
split.predictions <- predict(fit, newx = x.new, type="response")

Run the code above in your browser using DataLab