View source: R/quality_of_fit.R
quality_of_fit | R Documentation |
Calculate LOF (lack-of-fit), GOF (goodness-of-fit) and RMSE (root of mean squared error) for original and reconstructed spectra.
quality_of_fit(obj = NULL, fit)
spFitEval(obj, fit)
obj |
The first set of (original) spectra. Either a matrix or a hyperSpec object. |
fit |
The second set of usually processed or reconstructed spectra, that will be compared to the first set. Either a matrix or a hyperSpec object. |
A dataframe with following parameters for each row in obj
and fit
:
$LOF
- Lack of fit in percent (%):
\frac{\sum{(obj - fit)^2}}{\sum{obj^2}} \cdot 100\%
$GOF
- Goodness of fit in percent (%):
100\% - LOF
$RMSE
- Root of mean squared error:
\sqrt{(obj - fit)^2}
obj <- Spectra2
fit <- reconstructSp(Loadings2, Scores2)
evaluation <- quality_of_fit(obj, fit)
head(evaluation)
par(mfrow = c(3,1))
plot(density(evaluation$RMSE), main = "RMSE", col = 2)
plot(density(evaluation$LOF), main = "Lack-of-fit")
plot(density(evaluation$GOF), main = "Goodness-of-fit")
par(mfrow = c(1,1))
# Density plot of LOF by group:
DATA <- cbind(obj$.., evaluation)
qplot(LOF, data = DATA, fill = gr, color = gr,
geom = "density", alpha = I(.2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.