Predict method for ordPen objects

Description

Obtains predictions from an ordPen object.

Usage

1
2
3
4
## S3 method for class 'ordPen'
predict(object, newx, newu = NULL, newz = NULL,
  offset = rep(0,nrow(as.matrix(newx))), 
  type = c("link", "response"), ...)

Arguments

object

an ordPen object.

newx

the matrix (or data.frame) of new observations of the considered ordinal predictors, with each column corresponding to one predictor and containing numeric values from {1,2,...}.

newu

a matrix (or data.frame) of new observations of the additional categorical (nominal) predictors, with each column corresponding to one (additional) predictor and containing numeric values {1,2,...}.

newz

a matrix (or data.frame) of new observations of the additional metric predictors, with each column corresponding to one (additional) predictor.

offset

potential offset values.

type

the type of prediction. type = "link" is on the scale of linear predictors, whereas type = "response" is on the scale of the response variable, i.e. type = "response" applies the inverse link function to the linear predictors.

...

additional arguments.

Value

A matrix of predictions whose columns correspond to the different values of the penalty parameter lambda of the ordPen object.

Author(s)

Jan Gertheiss

See Also

ordSelect, ordSmooth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# the training data
set.seed(123)

# generate (ordinal) predictors
x1 <- sample(1:8,100,replace=TRUE)
x2 <- sample(1:6,100,replace=TRUE)
x3 <- sample(1:7,100,replace=TRUE)

# the response
y <- -1 + log(x1) + sin(3*(x2-1)/pi) + rnorm(100)

# x matrix
x <- cbind(x1,x2,x3)

# lambda values
lambda <- c(1000,500,200,100,50,30,20,10,1)

# selecting and/or smoothing
o1 <- ordSmooth(x = x, y = y, lambda = lambda)
o2 <- ordSelect(x = x, y = y, lambda = lambda)

# new data
x1 <- sample(1:8,10,replace=TRUE)
x2 <- sample(1:6,10,replace=TRUE)
x3 <- sample(1:7,10,replace=TRUE)
newx <- cbind(x1,x2,x3)

# prediction
round(predict(o1, newx), digits=3)
round(predict(o2, newx), digits=3)