predict-methods | R Documentation |
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.
predict(object, ...)
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 |
signature(object = "Fa")
generic functions - see print
, summary
, predict
, plot
, getCenter
, getEigenvalues
, getFa
, getLoadings
, getQuan
, getScores
, getSdev
Ying-Ying Zhang (Robert) robertzhangyying@qq.com
Zhang, Y. Y. (2013), An Object Oriented Solution for Robust Factor Analysis.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.