spls (version 2.2-3)

predict.splsda: Make predictions or extract coefficients from a fitted SPLSDA model

Description

Make predictions or extract coefficients from a fitted SPLSDA object.

Usage

# S3 method for splsda
predict( object, newx, type = c("fit","coefficient"),
    fit.type = c("class","response"), ... )
# S3 method for splsda
coef( object, ... )

Arguments

object

A fitted SPLSDA object.

newx

If type="fit", then newx should be the predictor matrix of test dataset. If newx is omitted, then prediction of training dataset is returned. If type="coefficient", then newx can be omitted.

type

If type="fit", fitted values are returned. If type="coefficient", coefficient estimates of SPLSDA fits are returned.

fit.type

If fit.type="class", fitted classes are returned. If fit.type="response", fitted probabilities are returned. Relevant only when type="fit".

...

Any arguments for predict.splsda should work for coef.splsda.

Value

Matrix of coefficient estimates if type="coefficient". Matrix of predicted responses if type="fit" (responses will be predicted classes if fit.type="class" or predicted probabilities if fit.type="response").

Details

Users can input either only selected variables or all variables for newx.

References

Chung D and Keles S (2010), "Sparse partial least squares classification for high dimensional data", Statistical Applications in Genetics and Molecular Biology, Vol. 9, Article 17.

See Also

print.splsda.

Examples

Run this code
# NOT RUN {
data(prostate)
# SPLSDA with eta=0.8 & 3 hidden components
f <- splsda( prostate$x, prostate$y, K=3, eta=0.8, scale.x=FALSE )
# Print out coefficients
coef.f <- coef(f)
coef.f[ coef.f!=0, ]
# Prediction on the training dataset
(pred.f <- predict( f, type="fit" ))
# }

Run the code above in your browser using DataCamp Workspace