Description Usage Arguments Details Value Author(s) See Also Examples
Rotation of models
lda
models are invariant to rotation,
i.e. the predicted posterior probabilities and classes do
not change if the LD scores lda$x
are
rotated.
1 2 3 4 5 6 7 8 9 10 |
object |
a model to rotate |
R |
rotation matrix, see
|
... |
further parameters |
Rotate is a post-processing method for models.
the rotated model
Claudia Beleites
rotmat
for calculating rotation
matrices
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ## clockwise rotation of lda
model <- lda (Species ~ ., data = iris)
pred <- predict (model)
plot (pred$x, col = iris$Species, pch = 19, cex = 0.3, asp = 1)
model.rot <- rotate (model, rotmat (alpha = pi/40, ndim = ncol (model$scaling), 1, 2))
pred.rot <- predict (model.rot)
points (pred.rot$x, col = iris$Species, cex = 0.5)
## check difference between original model's predictions and rotated model's predictions
diff <- pred$posterior - pred.rot$posterior
summary (diff)
boxplot (diff)
## clockwise rotation of pcalda
model <- pcalda (X = iris [,1:4], grouping = iris$Species, comps=1:3)
pred <- predict (model)
plot (pred$x, col = iris$Species, pch = 19, cex = 0.3, asp = 1)
model.rot <- rotate (model, rotmat (alpha = pi/40, ndim = 2, 1, 2))
pred.rot <- predict (model.rot)
points (pred.rot$x, col = iris$Species, cex = 0.5)
## check difference between original model's predictions and rotated model's predictions
diff <- pred$posterior - pred.rot$posterior
summary (diff)
boxplot (diff)
## clockwise rotation of plslda
model <- plslda (X = iris [,1:4], grouping = iris[,5], ncomp=2)
pred <- predict (model)
plot (pred$x, col = iris$Species, pch = 19, cex = 0.3, asp = 1)
model.rot <- rotate (model, rotmat (alpha = pi/40, ndim = 2, 1, 2))
pred.rot <- predict (model.rot)
points (pred.rot$x, col = iris$Species, cex = 0.5)
## check difference between original model's predictions and rotated model's predictions
diff <- pred$posterior - pred.rot$posterior
summary (diff)
boxplot (diff)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.