View source: R/predict.ordPen.R
predict.ordPen | R Documentation |
Obtains predictions from an ordPen
object.
## S3 method for class 'ordPen'
predict(object, newx, newu = NULL, newz = NULL,
offset = rep(0,nrow(as.matrix(newx))),
type = c("link", "response", "class"), ...)
object |
an |
newx |
the matrix (or |
newu |
a matrix (or |
newz |
a matrix (or |
offset |
potential offset values. |
type |
the type of prediction; |
... |
additional arguments (not supported at this time). |
A matrix of predictions whose columns correspond to the different values of
the penalty parameter lambda
of the ordPen
object.
Jan Gertheiss, Aisouda Hoshiyar
ordSelect
, ordSmooth
, ordFusion
# 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/fusing
o1 <- ordSmooth(x = x, y = y, lambda = lambda)
o2 <- ordSelect(x = x, y = y, lambda = lambda)
o3 <- ordFusion(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)
round(predict(o3, newx), digits=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.