I am doing PLS regression with the mixOmics package but struggle with the prediction part. So, if my model with three compoments is pls.res
, predict(pls.res, newdata)
gives a list with predict
, variates
and B.hat
. predict
is a matrix with dimensions 100x1x3. The documentation says that the latter dimension is the model dimensions. Since my response is a one-dimensional vector only, I guess that the model dimensions correspond to the components. But how can I get the most accurate prediction of Y from the PLS model?
An example; if I want to predict wt from the mtcars dataset using PLS regression:
library("mixOmics")
df <- mtcars
pls.res <- pls(df[,1:5], df$wt, mode = "regression")
pls.pred <- predict(pls.res, df[,1:5])
head(pls.pred)
produces the following (truncuated) output
$predict
, , dim1
Y
Mazda RX4 2.857348
Mazda RX4 Wag 2.857348
...
, , dim2
Y
Mazda RX4 2.847449
Mazda RX4 Wag 2.847449
...
$variates
dim1 dim2
Mazda RX4 -0.8392959 -0.02104679
Mazda RX4 Wag -0.8392959 -0.02104679
...
$B.hat
, , dim1
Y
mpg -0.2161400
cyl 0.1949251
...
, , dim2
Y
mpg -0.4171832787
cyl 0.0002618905
...
$call
predict.mixo_pls(object = pls.res, newdata = df[, 1:5])
and I don't understand the difference between the (in this case) two dimensions of $predict