d.spls.predict: Makes predictions from a fitted Dual-SPLS model

View source: R/d.spls.predict.R

d.spls.predictR Documentation

Makes predictions from a fitted Dual-SPLS model

Description

The function d.spls makes predictions from a fitted Dual-SPLS model.

Usage

d.spls.predict(mod.dspls,X,liste_cp)

Arguments

mod.dspls

a fitted Dual-SPLS object.

X

a numeric matrix of predictors values. Each row represents an observation and each column a predictor variable.

liste_cp

a numeric vector of the components for which prediction is required.

Details

The coefficients computed in the Dual-SPLS object are used to predict the fitted response values of new matrix X. Users can choose how many Dual-SPLS components should be used.

Value

Vector or matrix of estimated responses.

Author(s)

François Wahl Louna Alsouki

Examples

### load dual.spls library
library(dual.spls)
### parameters
n <- 100
p <- 50
nondes <- 20
sigmaondes <- 0.5
data=d.spls.simulate(n=n,p=p,nondes=nondes,sigmaondes=sigmaondes)

X <- data$X
y <- data$y

pcal <- 70
ncells <- 3

split <- d.spls.calval(X=X,pcal=pcal,y=y,ncells=ncells)

indcal= split$indcal
indval= split$indval

Xcal=X[indcal,]
Xval=X[indval,]
ycal=y[indcal]
yval=y[indval]

#fitting the model
ncp=10
mod.dspls <- d.spls.lasso(X=Xcal,y=ycal,ncp=ncp,ppnu=0.9,verbose=TRUE)

ycalhat=mod.dspls$fitted.values
rescal=mod.dspls$residuals
# predictions on validation
yvalhat=d.spls.predict(mod.dspls,Xval, liste_cp=1:ncp)

#Computing RMSE error
RMSEcal.dspls=apply(rescal,2,function(u) sqrt(mean(u^2)) )
RMSEval.dspls=apply(yvalhat,2,function(u) sqrt(mean((yval-u)^2)) )




dual.spls documentation built on April 19, 2023, 1:07 a.m.