predict-methods {robustfa} | R Documentation |
Calculates prediction
Description
Calculates prediction using the results in object. The newdata argument is an optional data frame or matrix in which to look for variables with which to predict. If newdata is omitted, the scores are used.
Usage
predict(object, ...)
Arguments
object |
an object of class |
... |
additional arguments, e.g., newdata: an optional data frame or matrix in which to look for variables with which to predict. If newdata is not missing, newdata should be scaled before |
Methods
signature(object = "Fa")
-
generic functions - see
print
,summary
,predict
,plot
,getCenter
,getEigenvalues
,getFa
,getLoadings
,getQuan
,getScores
,getSdev
Author(s)
Ying-Ying Zhang (Robert) robertzhangyying@qq.com
References
Zhang, Y. Y. (2013), An Object Oriented Solution for Robust Factor Analysis.
Examples
data("hbk")
hbk.x = hbk[,1:3]
faCovPcaRegMcd = FaCov(x = hbk.x, factors = 2, method = "pca",
scoresMethod = "regression", cov.control = rrcov::CovControlMcd()); faCovPcaRegMcd
## If missing newdata, the scores are used
predict(faCovPcaRegMcd)
##
## If not missing newdata, newdata should be scaled first.
##
newdata = hbk.x[1, ]
cor = FALSE # the default
newdata = {
if (cor == TRUE)
# standardized transformation
scale(newdata, center = faCovPcaRegMcd@center,
scale = sqrt(diag(faCovPcaRegMcd@covariance)))
else # cor == FALSE
# centralized transformation
scale(newdata, center = faCovPcaRegMcd@center, scale = FALSE)
}
##
## Now, prediction = predict(faCovPcaRegMcd)[1,] = faCovPcaRegMcd@scores[1,]
##
prediction = predict(faCovPcaRegMcd, newdata = newdata)
prediction
[Package robustfa version 1.1-0 Index]