## S3 method for class 'mvr':
predict(object, newdata, comps = 1:object$ncomp,
type = c("response", "scores"), cumulative = TRUE, ...)
type
is "response", a three dimensional array of
predicted response values is returned. The dimensions correspond to
the observations, the response variables and the model sizes,
respectively. When type
is "scores", a score matrix is returned.
type
is "response" (default), predicted response
values are returned. If cumulative
is TRUE
, the
elements of comps
are interpreted cumulatively,
i.e. predictions for models with comps[1]
components,
comps[2]
components, etc., are returned. Otherwise, predicted
response values for a single model with the exact components in
comps
are returned. When type
is "scores", predicted score values are
returned for the components given in comps
.
mvr
, summary.mvr
,
coef.mvr
, plot.mvr
data(NIR)
nir.mvr <- mvr(y ~ X, ncomp = 5, data = NIR[NIR$train,])
## Predicted responses for models with 1, 2, 3 and 4 components
pred.resp <- predict(nir.mvr, comps = 1:4, newdata = NIR[!NIR$train,])
## Predicted responses for a single model with components 1, 2, 3, 4
predict(nir.mvr, comps = 1:4, cumulative = FALSE, newdata = NIR[!NIR$train,])
## Predicted scores
predict(nir.mvr, comps = 1:3, type = "scores", newdata = NIR[!NIR$train,])
Run the code above in your browser using DataLab