Para variáveis métricas, exemplo da tabela 9.3 de Fávero e Belfiore (2017, p.317).
Para variáveis binárias, exemplo da tabela 9.9 de Fávero e Belfiore (2017, p.322).
Obs.: Para visualização das referências, ver ementa da disciplina.
# Preparando os dados
library(haven)
exemp1 <- read_dta("D:/dados/exemp1.dta")
View(exemp1)
attach(exemp1)
library(haven)
exemp1 <- read_dta("D:/dados/exemp1.dta")
View(exemp1)
attach(exemp1)
## The following objects are masked from exemp1 (pos = 3):
##
## x1, x2, x3
# Cálculo da distância
dist_m<-dist(exemp1, method = "euclidean")
dist_m
## 1
## 2 10.13213
dist_m<-dist(exemp1, method = "manhattan")
dist_m
## 1
## 2 17
dist_m<-dist(exemp1, method = "canberra")
dist_m
## 1
## 2 1.56883
detach(exemp1)
library(haven)
exemp2 <- read_dta("D:/dados/exemp2.dta")
View(exemp2)
attach(exemp2)
## The following objects are masked from exemp1:
##
## x1, x2, x3
library(proxy)
##
## Attaching package: 'proxy'
## The following objects are masked from 'package:stats':
##
## as.dist, dist
## The following object is masked from 'package:base':
##
## as.matrix
simil(exemp2, method="Jaccard")
## 1
## 2 0.5
simil(exemp2, method="Dice")
## 1
## 2 0.6666667
simil(exemp2, method="Ochiai")
## 1
## 2 0.6708204
simil(exemp2, method="Yule")
## 1
## 2 0.2
simil(exemp2, method="Hamman")
## 1
## 2 0.1428571