Here we create an object including the loading plots (as line plots)
for all the effects included in the model as well as the combined effect
and the residuals.
all_loadings_pl <- lmpLoading1dPlot(resASCA,
effectNames = c(
"Hippurate", "Citrate", "Time",
"Hippurate:Time",
"Hippurate+Time+Hippurate:Time",
"Residuals"
),
axes = 1, xlab = "ppm"
)
The score matrices are represented two components at a time on a
scatterplot with the function lmpScorePlot
.
Main effects
The scores and loadings of the main effects included in the model are
represented below.
They show that, thank to the ASCA analysis, Hippurate and Citrate
peaks are clearly and separately retrieved in the respective loading
plots compared to the classical PCA (see Section @ref(pca)) where peaks
of these two chemicals are both present in the two first PCs. The
loading profile of the Time
effect shows a high peak on the
left side of the removed water area.
# Hippurate
hip_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Hippurate",
color = "Hippurate", shape = "Hippurate"
)
hip_loadings_pl <- all_loadings_pl$Hippurate + hip_peaks
grid.arrange(hip_scores_pl, hip_loadings_pl, ncol = 2)
# Citrate
cit_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Citrate",
color = "Citrate", shape = "Citrate"
)
cit_loadings_pl <- all_loadings_pl$Citrate + cit_peaks
grid.arrange(cit_scores_pl, cit_loadings_pl, ncol = 2)
# Time
tim_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Time", color = "Time",
shape = "Time"
)
Warning in FUN(X[[i]], ...): The variance of PC2 is inferior to 1%. Graph
scaled
time_peaks <- annotate("rect",
xmin = c(5.955364), xmax = c(6.155364),
ymin = -Inf, ymax = Inf, alpha = 0.2,
fill = c("royalblue")
)
tim_loadings_pl <- all_loadings_pl$Time + time_peaks
grid.arrange(tim_scores_pl, tim_loadings_pl, ncol = 2)
Interaction Hippurate:Time
The scores and loadings fot the interaction term is represented here.
It is not straighforward to interpret the scores plot of such an
interaction term but the loadings of PC1 indicate a shift in the
spectrum, along the whole spectral profile (but mostly around 3
ppm).
# Hippurate:Time
hiptim_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Hippurate:Time",
color = "Hippurate", shape = "Time"
)
hiptim_loadings_pl <- all_loadings_pl$`Hippurate:Time` +
time_peaks +
hip_peaks
grid.arrange(hiptim_scores_pl, hiptim_loadings_pl, ncol = 2)
Combination of effects
Hippurate+Time+Hippurate:Time
The scores and the loadings of a combination of effects, in this case
"Hippurate+Time+Hippurate:Time"
can also be visualised.
# Hippurate+Time+Hippurate:Time
hiptimInter_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Hippurate+Time+Hippurate:Time",
color = "Hippurate", shape = "Time"
)
hiptimInter_loadings_pl <- all_loadings_pl$`Hippurate:Time` +
time_peaks + hip_peaks
grid.arrange(hiptimInter_scores_pl, hiptimInter_loadings_pl, ncol = 2)
However, note that a better graphical representation is possible with
the function lmpEffectPlot
(see Section @ref(effects-plot))
to depict interaction terms or combinations of effects.
Model residuals
PCA on the model residuals can also be applied to spot outliers or an
unexpected underlying structure of the data. The scores plot shows that
the effect of Day
, which was excluded in our modeling step,
could have been included as well as it spans the two first PCs of the
residuals.
resid_scores_pl <- lmpScorePlot(resASCA,
effectNames = "Residuals",
color = "Day", shape = "Day",
drawShapes = "segment"
)
resid_loadings_pl <- all_loadings_pl$Residuals
grid.arrange(resid_scores_pl, resid_loadings_pl, ncol = 2)