Visualizando possíveis outliers

Eu estou começando pelo pacote shapes, mas há outros possíveis. Se vc ainda não o instalou, use esse comando install.packages(“shapes”).

Primeiro estou fazendo 2 configurações com 3 pontos cada, onde o terceiro marco está bem errado na segunda configuração. As configurações são entradas como matrizes simples.

library(shapes)
## Loading required package: scatterplot3d
## Loading required package: rgl
## Loading required package: MASS

A <- matrix(c(0, 0, 1, 0, 1, 1), ncol = 2)
B <- matrix(c(0.1, 0.1, 1.1, 0.1, 1.1, 2.2), ncol = 2)

Vc pode visualizar cada uma separadamente:

plotshapes(A, joinline = 1:3)

plot of chunk unnamed-chunk-2

Ou mais de um:

plotshapes(A, B, joinline = 1:3)

plot of chunk unnamed-chunk-3

E a sobreposição de Procrustes é muito simples e retorna 6 objetos:

ans <- procOPA(A, B)
ans
## $R
##        [,1]    [,2]
## [1,] 0.9182 -0.3961
## [2,] 0.3961  0.9182
## 
## $s
## [1] 0.6443
## 
## $Ahat
##         [,1]    [,2]
## [1,] -0.3333 -0.6667
## [2,] -0.3333  0.3333
## [3,]  0.6667  0.3333
## 
## $Bhat
##         [,1]     [,2]
## [1,] -0.4609 -0.52630
## [2,] -0.2057  0.06535
## [3,]  0.6667  0.46094
## 
## $OSS
## [1] 0.1404
## 
## $rmsd
## [1] 0.153

Estes objetos são:

R
The estimated rotation matrix (may be an orthogonal matrix if reflection is allowed)

s
The estimated scale matrix

Ahat
The centred configuration A

Bhat
The Procrustes registered configuration B

OSS The ordinary Procrustes sum of squares, which is \( \|Ahat-Bhat\|^2 \)

rmsd
rmsd = sqrt(OSS/(km))