stdize(x, center = TRUE, scale = TRUE)
## S3 method for class 'stdized':
predict(object, newdata, \dots)
## S3 method for class 'stdized':
makepredictcall(var, call)
x
.x
."stdized"
, normally
the result of a call to stdize
.stdize
and predict.stdized
return a scaled and/or
centered matrix, with attributes "stdized:center"
and/or
"stdized:scale"
the vector used for centering and/or scaling.
The matrix is given class c("stdized", "matrix")
.makepredictcall.stdized
is an internal utility function; it is noe
meant for interactive use. See makepredictcall
for details. If center
is TRUE
, x
is centered by subtracting
the coloumn mean from each coloumn. If center
is a numeric
vector, it is used in place of the coloumn means.
If scale
is TRUE
, x
is scaled by dividing each
coloumn by its sample standard deviation. If scale
is a
numeric vector, it is used in place of the standard deviations.
mvr
, pcr
, plsr
,
msc
, scale
data(NIR)
## Direct standardization:
Ztrain <- stdize(NIR$X[NIR$train,])
Ztest <- predict(Ztrain, NIR$X[!NIR$train,])
## Used in formula:
mod <- plsr(y ~ stdize(X), ncomp = 6, data = NIR[NIR$train,])
pred <- predict(mod, newdata = NIR[!NIR$train,]) # Automatically standardized
Run the code above in your browser using DataLab