| rpcr | R Documentation |
Robust principal component regression by the RPCR method of Hubert and
Verboven (2003): the robust principal components of the predictors
(robpca()), followed by a robust regression of the responses on the
scores. Outlying spectra and wrong reference values have little influence
on the model, and the regression outlier map (plot_outlier_map())
classifies them.
rpcr(x, y, ncomp, ncomp_max = 10, alpha = 0.75, ndir = 250, nsamp = 500)
x |
A numeric matrix or data frame of the predictors (spectra), one observation per row. |
y |
A numeric vector, matrix or data frame of the responses, with one row per observation. |
ncomp |
The number of components of the model. |
ncomp_max |
The largest number of components considered: the number of
components of the robust PCA, so the model also depends on |
alpha |
The fraction of observations assumed to be regular, between
0.5 and 1, for |
ndir |
The number of random directions of the outlyingness in
|
nsamp |
The number of random subsets of FAST-MCD in |
The method has two steps:
Robust PCA. robpca() is applied to the predictors with ncomp_max
components. It gives a robust center \hat\mu_x, the loadings
P and the eigenvalues l_a, and the scores
t_i = P^T (x_i - \hat\mu_x).
Robust regression. The responses are regressed on the first
ncomp scores. With one response, this is the reweighted least
trimmed squares (LTS) regression of robustbase::ltsReg(). With
several responses, it is the MCD regression of Rousseeuw, Van Aelst,
Van Driessen and Agullo (2004): least squares from the reweighted MCD
of the scores and responses, then least squares on the observations
whose residual distance is below \sqrt{\chi^2_{q, 0.99}}.
The regression coefficients are B = P_k A_k, from the loadings
P_k and the slopes A_k of the regression on the first ncomp
scores.
Diagnostics. As for rsimpls(): the score distance
SD_i = \sqrt{\sum_a t_{ia}^2 / l_a} has the cut-off
\sqrt{\chi^2_{k, 0.975}}, the residual distance (with one response,
the absolute standardized residual) the cut-off
\sqrt{\chi^2_{q, 0.975}}, and the orthogonal distance
OD_i = \|x_i - \hat\mu_x - P t_i\| the cut-off of robpca().
Observations beyond the score cut-off only are good leverage points,
beyond the residual cut-off only vertical outliers, and beyond both
bad leverage points. The robust R^2 of the model (R2) is
computed on the observations whose orthogonal and residual distances are
both below their cut-offs.
Number of components. components gives, for 1 to ncomp_max
components, the robust R^2 and root mean squared error on the
observations that are regular in every one of these models; use
robust_rmsecv() for the robust cross-validated error. These models all
come from the same robust PCA, with ncomp_max components, of which they use
the first ncomp, so the model also depends on ncomp_max. With
ncomp_max = ncomp, the robust PCA has ncomp components, as in the paper.
Differences from the paper.
The models with fewer components than ncomp_max use the first components
of the robust PCA with ncomp_max components (see above).
The residual covariance of the MCD regression is multiplied by the
consistency factor 0.99 / P(\chi^2_{q+2} \le \chi^2_{q, 0.99}), as
the observations beyond the cut-off are left out.
This is an independent implementation of the published description.
robpca(), the LTS and the MCD use random subsets, so use set.seed()
for reproducible results.
An object of class specproc_rpcr, a list with:
coefficients, intercept: the regression coefficients (a
p \times q matrix) and intercepts.
x_loadings, x_scores, eigenvalues: the loadings P, scores
T and eigenvalues of the ncomp components.
y_loadings: the slopes A of the regression of the responses on
the scores (ncomp rows).
center: the robust center of the predictors.
fitted, residuals: the fitted values and residuals.
sigma: the robust covariance matrix of the residuals.
sd, rd, od: the score, residual and orthogonal distances of
each observation, and cutoff_sd, cutoff_rd, cutoff_od their
cut-offs.
R2: the robust R^2 of the model (see Details).
outlier_type: a factor classifying each observation as "regular",
"good leverage", "vertical outlier" or "bad leverage".
weights: 1 for the observations of the final (reweighted)
regression, 0 for the others.
components: a tibble with the robust R2 and RMSE of the models
with 1 to ncomp_max components.
models: the coefficients and intercept of the models with 1 to
ncomp_max components, for predictions with another number of components
(predict(fit, newdata, ncomp = )).
ncomp, ncomp_max, h, alpha: the settings used, and regression,
"LTS" or "MCD".
Use predict() for the predictions of new observations.
Christian L. Goueguel
Hubert, M., Verboven, S. (2003). A robust PCR method for high-dimensional regressors. Journal of Chemometrics, 17(8-9):438-452.
Rousseeuw, P.J., Van Aelst, S., Van Driessen, K., Agullo, J. (2004). Robust multivariate regression. Technometrics, 46(3):293-305.
Hubert, M., Rousseeuw, P.J., Vanden Branden, K. (2005). ROBPCA: a new approach to robust principal component analysis. Technometrics, 47(1):64-79.
predict.specproc_rpcr(), plot_outlier_map(),
robust_rmsecv(), rsimpls(), robpca()
data(forageLIBS)
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
spectra <- forageLIBS[which(wl > 380 & wl < 430)] # Ca II and Ca I lines
cal <- 1:300
set.seed(1)
fit <- rpcr(spectra[cal, ], forageLIBS$Ca[cal], ncomp = 5)
fit
head(predict(fit, spectra[-cal, ]))
plot_outlier_map(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.