Multidimensional Scaling

No Metric

Preparamos la data

library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.3.1
library(readr)
gaseosas<-read.csv("gaseosas.csv",sep = ";")
gaseosas%>% kable() %>% kable_styling()
Gaseosa Coca_Cola Inka_Cola Condor KR Pepsi Big_Cola
Coca_Cola NA NA NA NA NA NA
Inka_Cola 50 NA NA NA NA NA
Condor 70 60 NA NA NA NA
KR 60 70 30 NA NA NA
Pepsi 20 50 60 40 NA NA
Big_Cola 75 90 10 20 65 NA

Codificando la data para eliminar “NA” y convirtiendolo en una matriz de distancias

rownames(gaseosas) <- gaseosas$Gaseosa
gaseosas$Gaseosa <- NULL
gaseosas <- as.dist(gaseosas)
gaseosas
##           Coca_Cola Inka_Cola Condor KR Pepsi
## Inka_Cola        50                          
## Condor           70        60                
## KR               60        70     30         
## Pepsi            20        50     60 40      
## Big_Cola         75        90     10 20    65

Se carga la libreria smacof

Por defecto se utilizan 2 dimensiones

library(smacof)
## Warning: package 'smacof' was built under R version 4.3.1
## Loading required package: plotrix
## Loading required package: colorspace
## Loading required package: e1071
## Warning: package 'e1071' was built under R version 4.3.1
## 
## Attaching package: 'smacof'
## The following object is masked from 'package:base':
## 
##     transform
gas <- smacofSym(gaseosas,type = "ordinal")
gas
## 
## Call:
## smacofSym(delta = gaseosas, type = "ordinal")
## 
## Model: Symmetric SMACOF 
## Number of objects: 6 
## Stress-1 value: 0.004 
## Number of iterations: 16
summary(gas)
## 
## Configurations:
##                D1      D2
## Coca_Cola -0.6737  0.3648
## Inka_Cola -0.6297 -0.5204
## Condor     0.4748 -0.2857
## KR         0.3957  0.1397
## Pepsi     -0.3130  0.3277
## Big_Cola   0.7460 -0.0259
## 
## 
## Stress per point (in %):
## Coca_Cola Inka_Cola    Condor        KR     Pepsi  Big_Cola 
##     15.81     15.51     18.58      0.00     18.71     31.39

Codificando a 3 Dimensiones

gas3 <-smacofSym(gaseosas, ndim=3,type="ordinal")
gas3
## 
## Call:
## smacofSym(delta = gaseosas, ndim = 3, type = "ordinal")
## 
## Model: Symmetric SMACOF 
## Number of objects: 6 
## Stress-1 value: 0.001 
## Number of iterations: 10
summary(gas3)
## 
## Configurations:
##                D1      D2      D3
## Coca_Cola -0.5664  0.3432  0.2168
## Inka_Cola -0.6578 -0.5167 -0.0406
## Condor     0.4661 -0.3077  0.0759
## KR         0.3944  0.1277 -0.1942
## Pepsi     -0.3587  0.3211 -0.1503
## Big_Cola   0.7224  0.0324  0.0925
## 
## 
## Stress per point (in %):
## Coca_Cola Inka_Cola    Condor        KR     Pepsi  Big_Cola 
##     12.30     12.69     24.98      0.00     25.02     25.01

Gráfico utilizando SMACOF

SMACOF es el plot por defecto

plot(gas, main="Conf SMACOF")

Grafico utilizando STRESSPLOT

plot(gas, plot.type = "stressplot", main="Stressplot")

Grafico utilizando SHEPARD

Se grafica el diagrama de “Shepard: Regresión monótona” especificando en plot.type.

plot(gas, plot.type = "Shepard", main="Shepard")

Grafico utilizando RESPLOT

plot(gas, plot.type = "resplot", main="Residuos")