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

Description Usage Arguments Value See Also Examples

View source: R/methods.R

Description

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

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'cv.SplitReg'
predict(
  object,
  newx,
  index = object$index_opt,
  type = c("response", "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.

Value

Either a matrix with predictions or a vector of coefficients

See Also

predict.cv.SplitReg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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")

SplitReg documentation built on March 26, 2020, 7:26 p.m.