Learn R Programming

ChemoSpec (version 3.0-1)

hypTestScores: Conduct MANOVA using PCA Scores and Factors in a Spectra Object

Description

This function provides a convenient interface for carrying out manova using the scores from PCA and the factors (groups) stored in a "Spectra" object. The function will do anova as well, if you only provide one vector of scores, though this is probably of limited use. A "Spectra" object contains group information stored in its spectra$groups element, but you can also use splitSpectraGroups to generate additional groups/factors that might be more useful than the original.

Usage

hypTestScores(spectra, pca, pcs = 1:3, fac = NULL, ...)

Arguments

spectra
An object of S3 class "Spectra".
pca
An object of class prcomp.
pcs
An integer vector giving the PCA scores to use as the response in the manova analysis.
fac
A character vector giving the factors to be used in the manova. They will be searched for within the Spectra object.
...
Additional arguments to be passed downstream, in this case to aov. Untested.

Value

  • The results of the analysis print to the console unless assigned. If assigned, the object class is one of several described in aov depending upon the data passed to it.

Details

This function is an extraordinarily thin wrapper which helps the user to avoid writing a very tedious formula specification.

References

https://github.com/bryanhanson/ChemoSpec

See Also

splitSpectraGroups which can be used to create additional factor elements in the "Spectra" object, which can then be used with this function.

Examples

Run this code
data(CuticleIR)
res <- classPCA(CuticleIR)
hypTestScores(CuticleIR, res, fac = "groups")
# from splitSpectraGroups:
new.groups <- list(gen = c("G", "T"), trt = c("C", "E"))
new.CuticleIR <- splitSpectraGroups(CuticleIR, new.groups)
hypTestScores(new.CuticleIR, res, fac = c("trt", "gen"))

Run the code above in your browser using DataLab