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

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

View source: R/predict.splsda.R

Description

Make predictions or extract coefficients from a fitted SPLSDA object.

Usage

1
2
3
4
5
## S3 method for class 'splsda'
predict( object, newx, type = c("fit","coefficient"),
    fit.type = c("class","response"), ... )
## S3 method for class '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.

Details

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

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").

Author(s)

Dongjun Chung and Sunduz Keles.

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

1
2
3
4
5
6
7
8
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" ))

Example output

Sparse Partial Least Squares (SPLS) Regression and
Classification (version 2.2-2)

         x54         x105         x118         x126         x127         x292 
-0.079858427  0.062790549  0.200050675  0.151102721  0.125336124  0.097054753 
        x306         x308         x526         x535         x665        x1455 
 0.072054245 -0.035031567  0.011647612 -0.033456449 -0.003465278  0.111368189 
       x1839        x2425        x2619        x3006        x3032        x3118 
 0.344341295  0.222652673  0.502701945  0.118372469  0.037222124  0.209313921 
       x3183        x3300        x3423        x3587        x3665        x3743 
 0.070443118 -0.122593897  0.402374565 -0.049870115  0.076675783 -0.057151555 
       x3826        x3858        x3950        x4091        x4155        x4288 
-0.166120994 -0.008313119 -0.002198880  0.024707507  0.213824118 -0.379608007 
       x4353        x4448        x4498        x4701        x5016        x5214 
 0.034728924  0.234539768  0.072599251 -0.406717619 -0.417611040 -0.144379126 
       x5248        x5249        x5343        x5344        x5742        x5784 
 0.018682757  0.088453884  0.064227582 -0.314783831 -0.137700748 -0.137121968 
       x5808        x5983 
 0.130724156 -0.287282180 
  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [75] 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1
Levels: 0 1

spls documentation built on May 6, 2019, 1:09 a.m.