alt text

https://www.polymetrix.mx

Introducción

El uso de las escalas de Likert se pueden utilizar a través de la librería likert que se presenta en este trabajo

Escalas de Likert

La escala de Likert es una herramienta de medición que, a diferencia de preguntas dicotómicas con respuesta sí/no, nos permite medir actitudes y conocer el grado de conformidad del encuestado con cualquier afirmación que le propongamos. El mayor valor de las escalas de Likert es la ambivalencia entre variable categórica y numérica a la vez, para este caso los valores serán:

Construcción del dataset

Se van a construir 5 variables, con 100 datos.

  1. folio, integer

  2. sexo, character

  3. limpieza, factor

  4. tiempo, factor

  5. precio, factor

Construcción del folio

folio = c(1:100)
folio
##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
##  [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
##  [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
##  [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
##  [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
##  [91]  91  92  93  94  95  96  97  98  99 100
class(folio)
## [1] "integer"

Construcción de sexo

Se pone en plural para que en las tablas y gráficos aparezcan en plural

set.seed(5)
sexo = sample(c("hombres","mujeres"), 100, replace = T)
sexo
##   [1] "mujeres" "hombres" "hombres" "hombres" "hombres" "hombres" "hombres"
##   [8] "hombres" "mujeres" "hombres" "hombres" "hombres" "hombres" "mujeres"
##  [15] "mujeres" "hombres" "hombres" "mujeres" "mujeres" "mujeres" "hombres"
##  [22] "mujeres" "hombres" "hombres" "mujeres" "mujeres" "hombres" "mujeres"
##  [29] "hombres" "mujeres" "mujeres" "hombres" "hombres" "mujeres" "mujeres"
##  [36] "mujeres" "mujeres" "hombres" "hombres" "hombres" "hombres" "mujeres"
##  [43] "mujeres" "mujeres" "mujeres" "mujeres" "hombres" "mujeres" "mujeres"
##  [50] "mujeres" "mujeres" "mujeres" "mujeres" "mujeres" "mujeres" "mujeres"
##  [57] "hombres" "hombres" "mujeres" "mujeres" "hombres" "hombres" "hombres"
##  [64] "mujeres" "hombres" "hombres" "hombres" "mujeres" "hombres" "mujeres"
##  [71] "mujeres" "mujeres" "mujeres" "hombres" "mujeres" "mujeres" "mujeres"
##  [78] "mujeres" "hombres" "mujeres" "hombres" "hombres" "hombres" "mujeres"
##  [85] "mujeres" "hombres" "mujeres" "hombres" "mujeres" "hombres" "hombres"
##  [92] "mujeres" "hombres" "mujeres" "hombres" "hombres" "mujeres" "hombres"
##  [99] "mujeres" "hombres"
class(sexo)
## [1] "character"
table(sexo)
## sexo
## hombres mujeres 
##      48      52

Construcción de las escalas de Likert

escala = c("Muy insatisfecho","Insatisfecho", "Neutral", "Satisfecho", "Muy satisfecho")
escala
## [1] "Muy insatisfecho" "Insatisfecho"     "Neutral"          "Satisfecho"      
## [5] "Muy satisfecho"

Construcción de datos limpieza

set.seed(100)
# limpieza es completamente aleatorio
limpieza = sample(escala, 100, replace = T, prob = NULL)
limpieza = factor(limpieza, levels = escala, ordered = T)
limpieza
##   [1] Insatisfecho     Neutral          Muy insatisfecho Insatisfecho    
##   [5] Satisfecho       Satisfecho       Insatisfecho     Neutral         
##   [9] Insatisfecho     Muy satisfecho   Satisfecho       Neutral         
##  [13] Neutral          Insatisfecho     Muy insatisfecho Insatisfecho    
##  [17] Neutral          Satisfecho       Satisfecho       Satisfecho      
##  [21] Muy satisfecho   Neutral          Muy insatisfecho Neutral         
##  [25] Satisfecho       Insatisfecho     Muy satisfecho   Muy satisfecho  
##  [29] Muy satisfecho   Muy insatisfecho Muy satisfecho   Satisfecho      
##  [33] Neutral          Muy insatisfecho Muy insatisfecho Muy insatisfecho
##  [37] Neutral          Muy insatisfecho Muy insatisfecho Satisfecho      
##  [41] Neutral          Muy satisfecho   Neutral          Satisfecho      
##  [45] Neutral          Neutral          Neutral          Satisfecho      
##  [49] Neutral          Muy satisfecho   Satisfecho       Satisfecho      
##  [53] Neutral          Muy insatisfecho Insatisfecho     Muy satisfecho  
##  [57] Neutral          Muy satisfecho   Satisfecho       Muy satisfecho  
##  [61] Satisfecho       Satisfecho       Muy satisfecho   Muy insatisfecho
##  [65] Insatisfecho     Muy insatisfecho Insatisfecho     Satisfecho      
##  [69] Muy satisfecho   Insatisfecho     Insatisfecho     Satisfecho      
##  [73] Muy insatisfecho Insatisfecho     Neutral          Neutral         
##  [77] Neutral          Insatisfecho     Insatisfecho     Muy insatisfecho
##  [81] Muy satisfecho   Neutral          Insatisfecho     Neutral         
##  [85] Insatisfecho     Neutral          Satisfecho       Insatisfecho    
##  [89] Muy satisfecho   Muy insatisfecho Satisfecho       Insatisfecho    
##  [93] Neutral          Insatisfecho     Neutral          Neutral         
##  [97] Satisfecho       Muy insatisfecho Insatisfecho     Insatisfecho    
## 5 Levels: Muy insatisfecho < Insatisfecho < Neutral < ... < Muy satisfecho
class(limpieza)
## [1] "ordered" "factor"

Construcción de datos tiempo

tiempo = rep(escala, c(10,20,10,35,25))
# se les da un orden aleatorio
set.seed(1)
tiempo = sample(tiempo)
tiempo = factor(tiempo, levels = escala, ordered = T)
tiempo
##   [1] Satisfecho       Neutral          Muy insatisfecho Neutral         
##   [5] Muy satisfecho   Satisfecho       Insatisfecho     Muy satisfecho  
##   [9] Satisfecho       Satisfecho       Muy satisfecho   Insatisfecho    
##  [13] Satisfecho       Satisfecho       Muy insatisfecho Satisfecho      
##  [17] Muy satisfecho   Neutral          Muy satisfecho   Muy satisfecho  
##  [21] Satisfecho       Muy satisfecho   Neutral          Neutral         
##  [25] Satisfecho       Muy satisfecho   Satisfecho       Neutral         
##  [29] Insatisfecho     Insatisfecho     Satisfecho       Muy satisfecho  
##  [33] Neutral          Satisfecho       Insatisfecho     Muy satisfecho  
##  [37] Muy satisfecho   Satisfecho       Muy insatisfecho Insatisfecho    
##  [41] Neutral          Muy satisfecho   Muy insatisfecho Satisfecho      
##  [45] Insatisfecho     Insatisfecho     Muy satisfecho   Muy satisfecho  
##  [49] Muy satisfecho   Satisfecho       Muy satisfecho   Satisfecho      
##  [53] Insatisfecho     Satisfecho       Satisfecho       Satisfecho      
##  [57] Satisfecho       Insatisfecho     Insatisfecho     Neutral         
##  [61] Insatisfecho     Satisfecho       Satisfecho       Satisfecho      
##  [65] Muy satisfecho   Insatisfecho     Satisfecho       Satisfecho      
##  [69] Muy satisfecho   Satisfecho       Insatisfecho     Insatisfecho    
##  [73] Satisfecho       Muy satisfecho   Muy satisfecho   Satisfecho      
##  [77] Satisfecho       Muy insatisfecho Muy satisfecho   Insatisfecho    
##  [81] Satisfecho       Satisfecho       Muy satisfecho   Muy insatisfecho
##  [85] Insatisfecho     Insatisfecho     Muy satisfecho   Insatisfecho    
##  [89] Muy insatisfecho Satisfecho       Satisfecho       Neutral         
##  [93] Insatisfecho     Muy insatisfecho Satisfecho       Satisfecho      
##  [97] Muy satisfecho   Muy insatisfecho Muy satisfecho   Muy insatisfecho
## 5 Levels: Muy insatisfecho < Insatisfecho < Neutral < ... < Muy satisfecho
class(tiempo)
## [1] "ordered" "factor"

Construcción de datos precio

precio = rep(escala, c(25,35,5,25,10))
# se les da un orden aleatorio para hacerlo más interesante
set.seed(1)
precio = sample(precio)
precio = factor(precio, levels = escala, ordered = T)
precio
##   [1] Satisfecho       Insatisfecho     Muy insatisfecho Insatisfecho    
##   [5] Satisfecho       Insatisfecho     Muy insatisfecho Satisfecho      
##   [9] Insatisfecho     Insatisfecho     Satisfecho       Muy insatisfecho
##  [13] Insatisfecho     Satisfecho       Muy insatisfecho Satisfecho      
##  [17] Satisfecho       Insatisfecho     Satisfecho       Muy satisfecho  
##  [21] Insatisfecho     Satisfecho       Insatisfecho     Insatisfecho    
##  [25] Satisfecho       Muy satisfecho   Insatisfecho     Insatisfecho    
##  [29] Muy insatisfecho Insatisfecho     Satisfecho       Satisfecho      
##  [33] Insatisfecho     Satisfecho       Muy insatisfecho Muy satisfecho  
##  [37] Muy satisfecho   Satisfecho       Muy insatisfecho Muy insatisfecho
##  [41] Insatisfecho     Muy satisfecho   Muy insatisfecho Insatisfecho    
##  [45] Muy insatisfecho Muy insatisfecho Muy satisfecho   Satisfecho      
##  [49] Muy satisfecho   Neutral          Muy satisfecho   Neutral         
##  [53] Muy insatisfecho Satisfecho       Insatisfecho     Insatisfecho    
##  [57] Neutral          Muy insatisfecho Muy insatisfecho Insatisfecho    
##  [61] Muy insatisfecho Satisfecho       Insatisfecho     Insatisfecho    
##  [65] Satisfecho       Insatisfecho     Insatisfecho     Insatisfecho    
##  [69] Satisfecho       Satisfecho       Muy insatisfecho Muy insatisfecho
##  [73] Insatisfecho     Satisfecho       Satisfecho       Insatisfecho    
##  [77] Neutral          Muy insatisfecho Satisfecho       Muy insatisfecho
##  [81] Insatisfecho     Insatisfecho     Muy satisfecho   Muy insatisfecho
##  [85] Insatisfecho     Muy insatisfecho Satisfecho       Insatisfecho    
##  [89] Muy insatisfecho Insatisfecho     Neutral          Insatisfecho    
##  [93] Insatisfecho     Muy insatisfecho Insatisfecho     Insatisfecho    
##  [97] Muy satisfecho   Muy insatisfecho Satisfecho       Muy insatisfecho
## 5 Levels: Muy insatisfecho < Insatisfecho < Neutral < ... < Muy satisfecho
class(precio)
## [1] "ordered" "factor"

Agrupación de bases

#concatenarlo mediante cbind.data.frame() que respeta la clase de cada variable
w = cbind.data.frame(folio, sexo, limpieza, tiempo, precio)
# La clase es data.frame y cada variable mantiene sus características
head(w)
##   folio    sexo         limpieza           tiempo           precio
## 1     1 mujeres     Insatisfecho       Satisfecho       Satisfecho
## 2     2 hombres          Neutral          Neutral     Insatisfecho
## 3     3 hombres Muy insatisfecho Muy insatisfecho Muy insatisfecho
## 4     4 hombres     Insatisfecho          Neutral     Insatisfecho
## 5     5 hombres       Satisfecho   Muy satisfecho       Satisfecho
## 6     6 hombres       Satisfecho       Satisfecho     Insatisfecho
class(w)
## [1] "data.frame"
str(w)
## 'data.frame':    100 obs. of  5 variables:
##  $ folio   : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ sexo    : chr  "mujeres" "hombres" "hombres" "hombres" ...
##  $ limpieza: Ord.factor w/ 5 levels "Muy insatisfecho"<..: 2 3 1 2 4 4 2 3 2 5 ...
##  $ tiempo  : Ord.factor w/ 5 levels "Muy insatisfecho"<..: 4 3 1 3 5 4 2 5 4 4 ...
##  $ precio  : Ord.factor w/ 5 levels "Muy insatisfecho"<..: 4 2 1 2 4 2 1 4 2 2 ...

Curiosidades 1 de factor: estima de manera directa la frecuencia de variables a través de table, pero no puede estimar la media o desviación estándar

table(limpieza)
## limpieza
## Muy insatisfecho     Insatisfecho          Neutral       Satisfecho 
##               16               22               26               21 
##   Muy satisfecho 
##               15
mean(limpieza)
## Warning in mean.default(limpieza): argument is not numeric or logical: returning
## NA
## [1] NA

Curiosidades 2 de factor: Para estimar la media y desviación estándar se desclasifica unclass() “character” y convertirlo “número”

# escala sin desclasificar
table(unclass(limpieza))
## 
##  1  2  3  4  5 
## 16 22 26 21 15
mean(unclass(limpieza))
## [1] 2.97
sd(unclass(limpieza))
## [1] 1.298445

Uso de la librería likert()

likert es un paquete de R diseñado para ayudar a analizar y visualizar elementos de tipo Likert. Es necesario tener instalada likert(), ggplot2() y xtable()

# activación de likert
library(likert)
## Warning: package 'likert' was built under R version 4.1.3
## Loading required package: ggplot2
## Loading required package: xtable
## Warning: package 'xtable' was built under R version 4.1.3
library(ggplot2)
library(xtable)

Aplicación de likert sobre la base w

# Definimos una nueva variable con la función de likert, donde su clase será likert aprovechando la base construida w
xlik = likert(w[,3:5])
summary(xlik)
##       Item low neutral high mean       sd
## 2   tiempo  30      10   60 3.45 1.328590
## 1 limpieza  38      26   36 2.97 1.298445
## 3   precio  60       5   35 2.60 1.363300
# La clase de las variables es likert
class(xlik)
## [1] "likert"
str(xlik)
## List of 6
##  $ results :'data.frame':    3 obs. of  6 variables:
##   ..$ Item            : chr [1:3] "limpieza" "tiempo" "precio"
##   ..$ Muy insatisfecho: num [1:3] 16 10 25
##   ..$ Insatisfecho    : num [1:3] 22 20 35
##   ..$ Neutral         : num [1:3] 26 10 5
##   ..$ Satisfecho      : num [1:3] 21 35 25
##   ..$ Muy satisfecho  : num [1:3] 15 25 10
##  $ items   :'data.frame':    100 obs. of  3 variables:
##   ..$ limpieza: Ord.factor w/ 5 levels "Muy insatisfecho"<..: 2 3 1 2 4 4 2 3 2 5 ...
##   ..$ tiempo  : Ord.factor w/ 5 levels "Muy insatisfecho"<..: 4 3 1 3 5 4 2 5 4 4 ...
##   ..$ precio  : Ord.factor w/ 5 levels "Muy insatisfecho"<..: 4 2 1 2 4 2 1 4 2 2 ...
##  $ grouping: NULL
##  $ factors : NULL
##  $ nlevels : int 5
##  $ levels  : chr [1:5] "Muy insatisfecho" "Insatisfecho" "Neutral" "Satisfecho" ...
##  - attr(*, "class")= chr "likert"

Gráficos

plot(xlik,type = "bar", centered = T, group.order = colnames(w[,3:5]))

Barras centrado likert:

plot(xlik,type = "bar", centered = F, group.order = colnames(w[,3:5]), legend.position = "right")

Barras sin centrar de likert:

plot(xlik,type = "density", centered = F)

Densidad likert:

# Finalmente, en este gráfico se pueden visualizar la frecuencia de las variables cualitativas (Muy insatisfecho, ..., Muy Satisfecho) y las numércias como la media y la desviación estándar.
plot(xlik,type = "heat", legend.position = "left") +
  theme( axis.text.x = element_text( size = 8 ),
         axis.text.y = element_text( size = 18, hjust = 0 ),
         legend.text = element_text( size = 14 ),
         legend.title = element_text( size = 10 ) )

Gráfico de calor likert:

Gráficos separados por variable categórica (sexo)

xlikgroup = likert(w[,3:5], grouping = w$sexo)
plot(xlikgroup, type = "bar", centered = T)

Barras centrado likert:

plot(xlikgroup,type = "bar", centered = F)

Barras sin centrar de likert:

plot(xlikgroup, type = "density", centered = F, legend.position = "right")

Densidad likert: