lplsCV: Function for Cross-Validation in exo or endo-lpls.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/lplsCV.R

Description

The cross-validation is based on a fitted lpls object of type exo or endo (not exo_ort). The predictive ability of the model is measured in terms of root mean sums of squares of prediction (RMSEP) over the set of components from 1 to npc as defined in the call to the lpls-object. Cross-validation is only implmented across segments defined as rows of X1 and X2 (horizontal prediction) or across columns of X2 (rows of X3) (vertical prediction). Cross-validation requires that all missing values have been imputed in the model fit, that is, option impute=TRUE must be used in the call to lpls.

Usage

1
lplsCV(fit, segments1 = NULL, segments2 = NULL, trace=TRUE)

Arguments

fit

A fitted lpls object of type endo or exo.

segments1

A list of cross-validation segments for horizontal prediction. For leave-one-out-CV across n objects use segments1=as.list(1:n).

segments2

A list of cross-validation segments for vertical prediction. For leave-one-out-CV across p variables use segments1=as.list(1:p).

trace

Logical. If TRUE the iteration number of the cross-validation loop is printed.

Details

If no segment list is supplied a horizontal leave-one-out CV is performed across the components 1:npc.

Value

rmsep

The rmsep values across the components 1:npc

pred

An array of predicted values. The last dimension of pred is the number of components used in the prediction.

Author(s)

Solve S?b?

See Also

lpls

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
    simdata <- lpls.sim()
    X1 <- simdata$X1
    X2 <- simdata$X2
    X3 <- simdata$X3

    #To run endo-LPSL:
    fit.endo <- lpls(X1,X2,t(X3), npc=2, type="endo")
    
    #To cross-validate horizontally
    cv <- lplsCV(fit.endo, segments1=as.list(1:dim(X1)[1]))
    #To cross-validate vertically
    cv <- lplsCV(fit.endo, segments2=as.list(1:dim(X2)[2]))
    #Three-fold CV, horizontal
    segmat <- matrix(1:30, nrow=3, byrow=TRUE)
    segs <- list()
    for(i in 1:3){segs[[i]] <- segmat[i,]}
    cv <- lplsCV(fit.endo, segments1=segs)
    

solvsa/lpls documentation built on May 30, 2019, 6:10 a.m.