predict-methods: Calculates prediction

Description Usage Arguments Methods Author(s) References Examples

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

1
predict(object, ...)

Arguments

object

an object of class "Fa" or of a class derived from "Fa"

...

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

Methods

signature(object = "Fa")

generic functions - see show, 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
data("hbk")
hbk.x = hbk[,1:3] 

faCovPcaRegMcd = FaCov(x = hbk.x, factors = 2, method = "pca",
scoresMethod = "regression", cov.control = 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

robustfa documentation built on May 1, 2019, 9:26 p.m.