| reflect | R Documentation |
candisc and cancor objects have coefficients for the X and Y and weighted scores for these,
whose signs are arbitrary, in the sense that a given column can be reflected (multiplied by -1) without changing the fit.
But, often you will want to reverse the direction of one or more dimensions for ease of interpretation.
This function allows you to reflect any columns of the variable coefficients (and corresponding observation scores). This is often useful for interpreting a biplot, for example when a component (often the first) has all negative signs.
reflect(object, columns = 1:2, ...)
## S3 method for class 'data.frame'
reflect(object, columns = 1:2, ...)
## S3 method for class 'cancor'
reflect(object, columns = 1:2, ...)
## S3 method for class 'candisc'
reflect(object, columns = 1:2, ...)
object |
An object whose columns are to be reflected |
columns |
a vector of indices of the columns to reflect |
... |
Unused |
reflect methods are available for:
data.frames, for numeric columns
"cancor" objects, for the coefficients and scores of the X and Y variables
"candisc" objects, for the coefficients, structure correlations and scores
Note that plot.candisc() and plot.candisc() can handle this internally using the argument rev.axes.
The object with specified columns of the appropriate components (variable coefficients, observation scores, ...) multiplied by -1.
reflect(data.frame): "data.frame" method.
reflect(cancor): "cancor" method.
reflect(candisc): "candisc" method.
Michael Friendly
ggbiplot::reflect has similar methods for PCA-like objects
# reflect cols in a data.frame
X <- data.frame(x1 = 1:4, x2 = 5:8)
reflect(X)
reflect(X, 1)
reflect(X, 2)
cbind (X, letters[1:4]) |> reflect(1)
# reflect a candisc
iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
iris.can <- candisc(iris.mod, data=iris)
coef(iris.can)
# reflect Can1
iris.can |> reflect(1) |> coef()
# reflect a cancor
data(Rohwer, package="heplots")
X <- as.matrix(Rohwer[,6:10]) # the PA tests
Y <- as.matrix(Rohwer[,3:5]) # the aptitude/ability variables
Rohwer.can <- cancor(X, Y, set.names=c("PA", "Ability"))
coef(Rohwer)
Rohwer.can |> reflect() |> coef()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.