rotate: rotate

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rotate.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  rotate(object, R, ...)

  ## S3 method for class 'lda'
 rotate(object, R = NULL, ...)

  ## S3 method for class 'pcalda'
 rotate(object, R = NULL, ...)

  ## S3 method for class 'plslda'
 rotate(object, R = NULL, ...)

Arguments

object

a model to rotate

R

rotation matrix, see rotmat and example

...

further parameters

Details

Rotate is a post-processing method for models.

Value

the rotated model

Author(s)

Claudia Beleites

See Also

rotmat for calculating rotation matrices

lda

pcalda

plslda

Examples

 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)

cbmodels documentation built on May 31, 2017, 2:11 a.m.