Post on 22-Oct-2018
transcript
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Visualización y análisis de escalas LikertSección de Apoyo Estadístico (SAI)1, Univ. de Murcia
Antonio J. Perán (antoniojose.peran@um.es)
Edif. SACE, 30 de septiembre 2016
1http://sae.saiblogs.inf.um.es/Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Variables ordinales discretas o de tipo Likert
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Miscelánea
Las variables ordinales discretas más ampliamente utilizadasson las escalas Likert, cuyo nombre se debe al educador ypsicólogo Rensis Likert, quien publicó en 1932 un informedonde describía su uso.Son ampliamente utilizadas en psicología y las ciencias socialesdebido a su sencillez y fácil construcción.Se ha comprobado empíricamente que declararse de acuerdocon cualquier enunciado de tipo Likert, implica un menoresfuerzo psíquico por parte del entrevistado.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Qué vamos a ver
El paquete likert.La función plot.likert.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
El paquete likert
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
El paquete likert
Description: Functions to analyze and visualize likert type items.Date: 2015-12-14Author: Jason Bryer jason@bryer.org, Kimberly Speerschneiderkimkspeer@gmail.comMaintainer: Jason Bryer jason@bryer.orgURL: http://jason.bryer.org/likert,http://github.com/jbryer/likertLicense: GPLDepends: R (>= 3.0), ggplot2, xtableImports: psych, reshape2, gridExtra, grid, plyr
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Instalación
Puede instalarse haciendo uso del paquete devtools que debemoshaber instalado previamente.
require(devtools)install_github('likert', 'jbryer')
A continuación podemos cargarlo haciendo simplemente
library(likert)
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
pisaitems
Datos procedentes del Informe PISA de 2009 realizado conestudiantes norteamericanos, es decir, estudiantes de México,Canadá y EEUU. Este informe suele realizarse cada 3 años porengargo de la OCDE.La primera columna de la matriz de datos recoge el país en elque el estudiante está recibiendo su educación al momento derealizar el informe.Para el ejemplo, utilizaremos los once primeros ítems de laencuesta, que se responden con uno de estos cuatro niveles:Strongly disagree, Disagree, Agree, Strongly agree.El dataframe que contiene estos datos se encuentra en paquetelikert.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
pisaitems
Los enunciados de los once items que usaremos son:
[1] "1. I read only if I have to."[2] "2. Reading is one of my favorite hobbies."[3] "3. I like talking about books with other people."[4] "4. I find it hard to finish books."[5] "5. I feel happy if I receive a book as a present."[6] "6. For me, reading is a waste of time."[7] "7. I enjoy going to a bookstore or a library."[8] "8. I read only to get information that I need."[9] "9. I cannot sit still and read for more than a few minutes."
[10] "10. I like to express my opinions about books I have read."[11] "11. I like to exchange books with my friends."
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Cargamos los datos. . .
data(pisaitems)items_without_names <- pisaitems[, 2:12]
head(items_without_names[1:6, 1:6])
## ST24Q01 ST24Q02 ST24Q03## 68038 Disagree Strongly agree Strongly agree## 68039 Agree Strongly disagree Strongly disagree## 68040 Strongly agree Strongly disagree Strongly disagree## 68041 Disagree Disagree Agree## 68042 Strongly disagree Disagree Strongly disagree## 68043 Agree Strongly disagree Strongly disagree## ST24Q04 ST24Q05 ST24Q06## 68038 Strongly disagree Strongly agree Strongly disagree## 68039 Strongly agree Strongly disagree Agree## 68040 Agree Strongly disagree Strongly agree## 68041 Strongly disagree Disagree Disagree## 68042 Disagree Strongly disagree Disagree## 68043 Agree Strongly disagree Agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Objeto likert
l11 <- likert(items_without_names)summary(l11)
Table 1: Tabla summary() del objeto l11 de tipo likert.
Item low neutral high mean sd
10 ST24Q10 41.08 0 58.92 2.605 0.9015 ST24Q05 46.93 0 53.07 2.467 0.94478 ST24Q08 50.4 0 49.6 2.485 0.9097 ST24Q07 51.21 0 48.79 2.429 0.91643 ST24Q03 54.99 0 45.01 2.328 0.90911 ST24Q11 55.54 0 44.46 2.343 0.96092 ST24Q02 56.64 0 43.36 2.345 0.92771 ST24Q01 58.73 0 41.27 2.292 0.93694 ST24Q04 65.35 0 34.65 2.178 0.89929 ST24Q09 76.25 0 23.75 1.975 0.87936 ST24Q06 82.89 0 17.11 1.81 0.8612
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Observaciones
IMPORTANTE: Para calcular las columnas mean y sd usalos valores numéricos resultantes de pasar los ítems(factores)como argumento a la función as.numeric.En principio, la función likert solo acepta objetos de tipodataframe como argumento, por lo que si queremos contruírun objeto likert con un único factor debemos introducirlocomo:
# Para construír un likert de un único íteml11a <- likert(items_without_names[ , 1, drop = F])
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráficos
El paquete likert permite construír tres tipos de gráficos básicos alos que se pueden añadir diversas características mediante atributos.Los distintos tipos son:
Gráficos de barras, o de tipo bar.Gráficos de densidad, o de tipo density.Gráficos de calor, o de tipo heat.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras centrado
plot(l11, type = "bar", centered = TRUE)
41%
47%
50%
51%
55%
56%
57%
59%
65%
76%
83%
59%
53%
50%
49%
45%
44%
43%
41%
35%
24%
17%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
6. For me, reading is a waste of time.
7. I enjoy going to a bookstore or a library.
8. I read only to get information that I need.
9. I cannot sit still and read for more than afew minutes.
10. I like to express my opinions about books Ihave read.
11. I like to exchange books with my friends.
100 50 0 50 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras sin centrar
plot(l11, type = "bar", centered = FALSE)
41%
47%
50%
51%
55%
56%
57%
59%
65%
76%
83%
59%
53%
50%
49%
45%
44%
43%
41%
35%
24%
17%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
6. For me, reading is a waste of time.
7. I enjoy going to a bookstore or a library.
8. I read only to get information that I need.
9. I cannot sit still and read for more than afew minutes.
10. I like to express my opinions about books Ihave read.
11. I like to exchange books with my friends.
0 25 50 75 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras con porcentajes
library(plyr)plot(l11, type = "bar", centered = TRUE, plot.percents = TRUE)
41%
47%
50%
51%
55%
56%
57%
59%
65%
76%
83%
59%
53%
50%
49%
45%
44%
43%
41%
35%
24%
17%11% 6%
17% 7%
27% 8%
31% 11%
32% 11%
32% 12%
36% 9%
37% 12%
36% 14%
40% 13%
44% 15%
41%42%
43%33%
40%25%
36%23%
36%20%
33%23%
34%21%
33%18%
35%15%
28%19%
28%14%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
6. For me, reading is a waste of time.
7. I enjoy going to a bookstore or a library.
8. I read only to get information that I need.
9. I cannot sit still and read for more than afew minutes.
10. I like to express my opinions about books Ihave read.
11. I like to exchange books with my friends.
100 50 0 50 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras ordenado
plot(l11, group.order = colnames(items_with_names))
41%
47%
50%
51%
55%
56%
57%
59%
65%
76%
83%
59%
53%
50%
49%
45%
44%
43%
41%
35%
24%
17%
11. I like to exchange books with my friends.
10. I like to express my opinions about books Ihave read.
9. I cannot sit still and read for more than afew minutes.
8. I read only to get information that I need.
7. I enjoy going to a bookstore or a library.
6. For me, reading is a waste of time.
5. I feel happy if I receive a book as a present.
4. I find it hard to finish books.
3. I like talking about books with other people.
2. Reading is one of my favorite hobbies.
1. I read only if I have to.
100 50 0 50 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de densidad
plot(l11, type = "density")
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
6. For me, reading is a waste of time.
7. I enjoy going to a bookstore or a library.
8. I read only to get information that I need.
9. I cannot sit still and read for more than a few minutes.
10. I like to express my opinions about books I have read.
11. I like to exchange books with my friends.
Stronglydisagree
(1)
Disagree(2)
Agree (3) Stronglyagree (4)
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de calor
plot(l11, type = "heat")
2.60 (0.90)
2.47 (0.94)
2.48 (0.91)
2.43 (0.92)
2.33 (0.91)
2.34 (0.96)
2.34 (0.93)
2.29 (0.94)
2.18 (0.90)
1.97 (0.88)
1.81 (0.86)
22.8%
20.3%
21.2%
25.0%
19.3%
42.2%
17.8%
15.0%
33.1%
13.5%
22.5%
35.9%
36.3%
33.7%
40.4%
27.7%
40.6%
33.4%
35.4%
43.1%
27.5%
33.0%
30.5%
31.9%
36.0%
26.5%
40.2%
11.0%
36.9%
35.8%
16.9%
43.8%
32.1%
10.7%
11.4%
9.0%
8.1%
12.9%
6.1%
11.9%
13.8%
6.8%
15.1%
12.4%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
6. For me, reading is a waste of time.
7. I enjoy going to a bookstore or a library.
8. I read only to get information that I need.
9. I cannot sit still and read for more than afew minutes.
10. I like to express my opinions about books Ihave read.
11. I like to exchange books with my friends.
Mean (SD) Strongly disagree Disagree Agree Strongly agree
0
25
50
75
100Percent
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Agrupando los datos de acuerdo a un factor
Una característica interesante que ofrece el paquete likert esque permite realizar los cálculos y construir los gráficosseparando de acuerdo a un factor que le indiquemos de unaforma muy intuitiva.Al principio vimos que hay una variable en la matriz de datosinicial pisaitems que recoge el país en el que estudia cadaindividuo. Esta se llama CNT. Sería útil, entonces, podercomparar los resultados de los tres países por separado.
l11_grouped <- likert(items_with_names[ , 1:5], grouping = pisaitems$CNT)
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras agrupado
plot(l11_grouped, type = "bar")
61%
59%
50%
39%
41%
50%
62%
52%
70%
38%
48%
30%
57%
53%
59%
43%
47%
41%
72%
61%
69%
28%
39%
31%
50%
43%
62%
50%
57%
38%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
Canada
Mexico
United States
Canada
Mexico
United States
Canada
Mexico
United States
Canada
Mexico
United States
Canada
Mexico
United States
100 50 0 50 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de barras agrupado con histograma
plot(l11_grouped, type = "bar", include.histogram = TRUE)
61%
59%
50%
39%
41%
50%
62%
52%
70%
38%
48%
30%
57%
53%
59%
43%
47%
41%
72%
61%
69%
28%
39%
31%
50%
43%
62%
50%
57%
38%
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
United States
Mexico
Canada
United States
Mexico
Canada
United States
Mexico
Canada
United States
Mexico
Canada
United States
Mexico
Canada
100 50 0 50 100Percentage
Response Strongly disagree Disagree Agree Strongly agree
22597
37728
5166
22601
37787
5168
22581
37676
5157
22591
37728
5161
22563
37756
5157
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
0 10000 20000 30000n
Missing Completed
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico de densidad agrupado
plot(l11_grouped, type = "density")
1. I read only if I have to.
2. Reading is one of my favorite hobbies.
3. I like talking about books with other people.
4. I find it hard to finish books.
5. I feel happy if I receive a book as a present.
Stronglydisagree
(1)
Disagree(2)
Agree (3) Stronglyagree (4)
Group
Canada
Mexico
United States
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
ResumenParámetros vistos para la función likert()
grouping Le pasamos un factor para que realice los cálculos agrupando losdatos de acuerdo a este.
Parámetros vistos para la función plot()
type Indica el tipo de gráfica; que puede ser bar, density o heat.centered Se usa en gráficos tipo bar. Toma el valor TRUE por defecto, y leindicaremos el valor FALSE en caso de que no queramos que las barras dela gráfica se muestren centradas en el nivel neutral.plot.percents Toma el valor FALSE por defecto. Le indicaremos el valorTRUE si queremos que imprima los porcentajes de cada nivel sobre las barraen gráficos de tipo bar. Requiere plyr.group.ordered Toma como valor un vector que indica el orden en quequeremos que se muestren los ítems en el gráfico.include.histogram Toma el valor FALSE por defecto. Le indicaremos elvalor TRUE si queremos que imprima un histograma del factor que pasamosmediante el parámetro grouping a la derecha del gráfico. Requiere grid.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
La función plot.likert
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
La función plot.likert
Es una función creada y descrita en detalle por el usuarioSascha W. en la entrada de r-bloggers:https://www.r-bloggers.com/visualisation-of-likert-scale-results/.Admite diversos argumentos de entre los que pasamos adescribir a continuación los más importantes.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Parámetros de la función plot.likert
vec Vector numérico que recoge los valores de una variable ordinal discreta.posible.values Valores posibles de la escala, en caso de la variable aanalizar no tome alguno de ellosleft Nivel inferior de nuestra escala Likert.right Nivel superior de nuestra escala Likert.plot.median Le indicaremos el valor TRUE para que pinte la mediana comouna línea verde vertical en la gráfica. Toma el valor FALSE por defecto.plot.sd Toma el valor TRUE por defecto. Pinta una línea horizontal sobre lamedia que indica la desviación típica de los valores a ambos lados de esta.include.absolutes Toma el valor TRUE por defecto. Imprime la frecuenciaabsoluta de cada uno de los niveles de la variable.include.percentages Toma el valor TRUE por defecto. Imprime lafrecuencia relativa como porcentaje de cada uno de los niveles de lavariable.own.margins Por defecto es own.margins = c(2, 2, 3, 2). Secorresponde con los márgenes inferior, izquierdo, superior y derechorespectivamente.
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico resultante de la función plot.likert
plot.likert(as.numeric(pisaitems$ST24Q01),left = "Strongly disagree",right = "Strongly agree",plot.median = T,plot.sd = T,main = names_items[1])
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gráfico resultante de la función plot.likert
1 2 3 4
23 % 36 % 31 % 11 %14947 23515 20000 7029
Str
ongl
y di
sagr
ee
Str
ongl
y ag
ree
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Enlaces de referencia
https://cran.r-project.org/web/packages/likert/likert.pdf
http://jason.bryer.org/likert
https://www.r-bloggers.com/visualisation-of-likert-scale-results/
https://es.wikipedia.org/wiki/Escala_Likert
http://www.ict.edu.mx/acervo_bibliotecologia_escalas_Escala%20de%20Likert.pdf
Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert
Variables ordinales discretas o de tipo LikertEl paquete likert
La función plot.likert
Gracias
Visualización y análisis de escalas LikertSección de Apoyo Estadístico (SAI)2, Univ. de Murcia
Antonio J. Perán (antoniojose.peran@um.es)
Edif. SACE, 30 de septiembre 2016
2http://sae.saiblogs.inf.um.es/Antonio J. Perán (antoniojose.peran@um.es) Visualización y análisis de escalas Likert