predict.cv.ordinis: Prediction function for fitted cross validation ordinis...

Description Usage Arguments Value Examples

Description

Prediction function for fitted cross validation ordinis objects

Usage

1
2
3
## S3 method for class 'cv.ordinis'
predict(object, newx, s = c("lambda.min",
  "lambda.1se"), ...)

Arguments

object

fitted "cv.ordinis" model object

newx

Matrix of new values for x at which predictions are to be made. Must be a matrix; can be sparse as in the CsparseMatrix objects of the Matrix package This argument is not used for type = c("coefficients","nonzero")

s

Value(s) of the penalty parameter lambda at which predictions are required. Default is the entire sequence used to create the model. For predict.cv.ordinis(), can also specify "lambda.1se" or "lambda.min" for best lambdas estimated by cross validation

...

used to pass the other arguments for predict.ordinis

Value

An object depending on the type argument

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
set.seed(123)
n.obs <- 1e4
n.vars <- 100
n.obs.test <- 1e3

true.beta <- c(runif(15, -0.5, 0.5), rep(0, n.vars - 15))

x <- matrix(rnorm(n.obs * n.vars), n.obs, n.vars)
y <- rnorm(n.obs, sd = 3) + x %*% true.beta
x.test <- matrix(rnorm(n.obs.test * n.vars), n.obs.test, n.vars)
y.test <- rnorm(n.obs.test, sd = 3) + x.test %*% true.beta

fit <- cv.ordinis(x = x, y = y,
                  gamma = 1.4,
                  nlambda = 10)


preds.best <- predict(fit, newx = x.test, type = "response")

apply(preds.best, 2, function(x) mean((y.test - x) ^ 2))

jaredhuling/ordinis documentation built on May 23, 2019, 4:03 a.m.