Está en la página 1de 20

Pecvnia Monográfico 2012, pp.

1-20

MIDIENDO LA VARIABILIDAD EN CARACTERES


CUALITATIVOS / measuring variability in
qualitative characteristics

Jesús Basulto Santos1


basulto@us.es
José Antonio Camúñez Ruiz1
camunez@us.es
Francisco Javier Ortega Irizo1
fjortega@us.es
María Dolores Pérez Hidalgo1
mdperez@us.es

Universidad de Sevilla

Resumen
El estudio de la variabilidad en caracteres categóricos rara vez es abordado. A partir de un
enfoque menos usado de la variabilidad en variables cuantitativas, el de la disparidad, distinto al
de la dispersión que, por ejemplo, proporciona la varianza, se propone la construcción de dos
coeficientes de medida de la variabilidad en variables cualitativas o categóricas a los que
llamamos coeficientes de disparidad. La sencillez y proximidad de los mismos permiten que sean
abordados en un curso introductorio de estadística descriptiva. Ejemplos sencillos son ofrecidos
para introducir las medidas y para, también, que el profesor constate la idea que el alumno tiene
sobre variabilidad, dispersión y disparidad.

Palabras clave: Variables cualitativas o categóricas; Variabilidad; Dispersión; Disparidad.

Abstract
The study of variability in categorical characteristics is rarely discussed. From a less used
viewpoint of variability in quantitative variables, as it is the one of dissimilarity, which is different
from the dispersion that, for example, the variance provides, we propose the construction of two
coefficients that measure the variability in qualitative or categorical variables, which we call

1
Departamento de Economía Aplicada I. Facultad de Ciencias Económicas y Empresariales,
Universidad de Sevilla, Avda. Ramón y Cajal, 1, 41018-Sevilla.
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

coefficients of dissimilarity. Simple examples are provided to introduce the measures, so that the
teacher can also evaluate the idea students have about variability, dispersion and dissimilarity.

Keywords: Qualitative or categorical variables; Variability; Dispersion; Dissimilarity.

1. INTRODUCCIÓN 1. INTRODUCTION

Las variables cualitativas o categóricas Qualitative or categorical variables have


siempre han ocupado un mínimo espacio always been residually dealt with in
en los cursos introductorios de estadística. introductory statistics courses. These
Se suelen definir, clasificar en nominales courses usually include their definition,
u ordinales, introducir la moda como una classification into nominal or ordinal
medida representativa y, en el caso de las variables, the presentation of the mode
ordinales, alguna medida similar a la as a representative measure and, in the
mediana. También, representarlas gráfi- case of the ordinal variables, other kind of
camente, siendo en este aspecto donde, measures similar to the median. They are
quizás, encontramos más variedad de also graphically represented, following a
propuestas: diagramas de barras, de variety of options: bar chart, pie chart,
sectores, pictogramas, y una pluralidad pictograms, and a diversity of charts whose
de gráficos cuyo nivel de sofisticación level of sophistication, it can be said,
depende, casi, de la imaginación de la depends on the imagination of the person
persona interesada. La media aritmética, la in question. The arithmetic mean, which
que presenta mayores posibilidades de presents the largest possibility of being
manipulación algebraica, la más conocida y algebraically manipulated, which is the
utilizada, la medida por antonomasia en most known and used and the measure
variables cuantitativas, no dispone de su par excellence in the case of quantitative
equivalente entre las categóricas. variables, has no counterpart in the case
of the categorical ones.
Prácticamente, nuestro trabajo en el aula
se reduce a lo que acabamos de citar en From a practical point of view, our work in
el caso del estudio de una variable the classroom is reduced to what we have
categórica aislada. Después, al tratar con just mentioned in the case of the study of a
dos variables cualitativas relacionadas separate categorical variable. After that,
entre si, las tablas de contingencia, con when dealing with two related categorical
sus medidas asociadas, amplían un poco variables, the use of contingency tables and
la visión sobre este tipo de estadísticas. their associated measures allow spreading
a bit the idea of this kind of statistics.
Desde luego, la variabilidad, (cualidad de
variable, según el diccionario de la Real Certainly, variability –defined as the
Academia Española) tan profusamente quality of variable, according to the
estudiada en cuantitativas, no es tratada Academy of Spanish Language (RAE)–,
en general en las categóricas, dando la which has been so profusely studied in
sensación, entonces, de que este tipo de the case of quantitative variables, is not
usually dealt with for the categorical ones,
which seems to mean that this type of
2
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

medidas no existe. Es claro que esa idea de measures does not exist. It is clear that the
variabilidad alrededor de la media, signifi- idea of variability around the mean, which
cado habitual que damos a varianza o is the usual meaning given to the variance
desviación típica, no tiene sentido. Se suele or standard deviation, makes no sense in
usar el término “dispersión” para esta the case of categorical variables. For this
forma de variabilidad. kind of variability, the term ‘dispersion” is
generally used.
Pero hay otra manera de entender la
variabilidad, la que se detiene en el análisis However, there is another way of
comparativo de respuestas donde la understanding variability, which is the one
comparación se reduce a igualdad o that focuses on the comparative analysis of
desigualdad de las mismas, sin pararse en responses, where the comparison is
medir la magnitud de esa desigualdad. reduced to their similarity or disparity, but it
Podemos usar en este caso el término does not deal with measuring the amount
“disparidad” (desemejanza, desigualdad y of disparity. In this case, the term
diferencia de unas cosas respecto de otras, ‘dissimilarity’ can be used (which is defined
según el diccionario de la Real Academia as disparity, inequality or difference of
Española). Estas medidas, que se emplean some things with regard to others by the
aunque con menos frecuencia en variables Academy of Spanish Language). These
cuantitativas, pueden extenderse a las cua- measures, which are used for quantitative
litativas, pues la disparidad existe siempre variables but less frequently, can be spread
que se manifiesten opiniones distintas. O to the qualitative ones, since dissimilarity
sea, la variabilidad existe en las categóricas exists as long as there are different options.
(no tendría sentido cualquier estudio That is, variability exists in the case of
estadístico si no fuese así). Creemos que es categorical variables (otherwise, any
algo que debemos inculcar a nuestros statistical analysis would make no sense).
alumnos y que, si es posible, construir We think this is something we must instil in
medidas o indicadores de dicha variabi- our students and, if possible, construct
lidad. measures or indicators of the above-
mentioned variability.
En este trabajo presentamos un par de
medidas sencillas para casos categóricos In this paper we present a couple of simple
(aunque en concepto podríamos hablar de measures for categorical cases (although
una sola, dado que la diferencia entre strictly speaking we could talk about only
ambas es la misma que la existente entre one, since the difference between them is
varianza y cuasivarianza), a las que the same as the one between variance and
proponemos llamar “coeficientes de quasivariance), which are proposed to be
disparidad”, y las aplicamos a ejemplos named as ‘dissimilarity coefficients’ and we
sencillos que nos permiten observar, en el apply them in simple examples which allow
aula, si la percepción de variabilidad que us to observe in the classroom if the
tienen nuestros estudiantes es coherente perception of variability our students have
con la que mide estos coeficientes. is coherent with the one these coefficients
measure.
En algunos trabajos hemos comprobado la
utilidad de estas medidas que, acompa- We have checked in some papers the
ñada de lo intuitivas que resultan, creemos, usefulness of these measures, which,
deben ser medidas que engrosen el together with the fact of being so
contenido de una asignatura dedicada a intuitive, must widen the contents of a
3

Estadística Descriptiva. subject in Descriptive Statistics.


Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

Dado que en variables categóricas la Provided in categorical variables the


proporción de respuestas en un sentido u proportion of responses in one and another
otro es uno de los primeros cálculos que sense is one of the first computations that
realizamos y que, la idea de proporción are carried out, this idea of proportion is
enlaza con la de probabilidad para el connected with the one of probability, so
caso de variables aleatorias, terminamos we conclude with analysing the similarity
analizando la similitud entre una de las between one of the proposed measures
medidas propuestas y la varianza de una and the variance of a Bernoulli
variable probabilística dicotómica tipo dichotomous random variable.
Bernoulli.

2. VARIABILITY IN QUANTITATIVE:
2. VARIABILIDAD EN CUANTITATIVAS: DISPERSION AND DISSIMILARITY
DISPERSIÓN Y DISPARIDAD
In quantitative variables, the first measures
En variables cuantitativas nos of dispersion are variance and quasi-
encontramos como primeras medidas de variance, whose expressions are reminded:
dispersión la varianza y la cuasivarianza,
( x − X ) ( x − X )
2 2
i i
cuyas definiciones recordamos: and S 2 = i ,
S2 = i

 (x ) (x −X)
c
i −X
2
i
2
n n −1
S2 = i y S2 = i , respectively. When Gini (1912) studies
c
n n −1 variability in quantitative variables, he
respectivamente. Gini (1912), cuando distinguishes between two types of
estudia la variabilidad entre las variables: those which are defined as an
cuantitativas distingue dos tipos de only real value, μ, but when this is
variables: las que se definen como un measured there are different measu-
sólo valor real, μ, pero que al ser medido rements due to mistakes associated to the
se producen diferentes mediciones former, so the observed values or
debido a los errores asociados a las observations are in the form of xi = μ + ε i
mismas, por lo que los valores (actually, he talks about variables related to
observados u observaciones efectuadas the measurement in astronomy); and those
son de la forma xi = μ + ε i (habla de which present different qualitative
variables relacionadas con la medición en categories that arise with the repeated
astronomía), y las que presentan distintas observations of the variables. In this
modalidades cuantitativas que van context, for the first type, Gini (1912)
surgiendo con las repetidas observaciones proposes measures which are similar to the
de las variables. Pues bien, para el primer ones we have mentioned above, that is,
tipo, Gini (1912) propone medidas del tipo measures of dispersion around the mean
de las citadas anteriormente, o sea, (which is the real value of the variable),
medidas de dispersión alrededor de la whereas for the second group he
media (siendo ésta el valor real de la formulates measures that include all the
variable), mientras que para las del possible pairwise differences among
segundo formula medidas que recojan observed values. They would be, therefore,
todas las posibles diferencias, por parejas, measures that would be constructed from
entre los valores observados. Serían, pues, the following expressions:
medidas construidas a partir de los siguien-
4
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

( x − x ) ,  ( x − x ) , 
2 2
tes agregados: i
xi − xj , j i
xi − xj , (the distances
j
i j i j i j i j

(las distancias entre observaciones son among observations are measured as


medidas mediante diferencias al squared differences or differences in
cuadrado o diferencias en valor absoluto) absolute value), although this author
donde este autor apuesta más por el banks on the first one rather than the
segundo que por el primero, pues la que second, since he proposed the measure
propuso es la conocida como media de known as differences mean:
las diferencias:
 x − x i j

 x − x i j Δ=
i j
.
Δ=
i j
. n ( n − 1)
n ( n − 1)
For the first expression it is easy to prove
Para el primer agregado es fácil the following equality:
demostrar la siguiente igualdad:
( x − x ) = 2n xi − X( )
2 2
i j

( x − x ) = 2n xi − X . ( )
2 2
i j i
i j
i j i

Somehow, this equality makes


De alguna forma, esta igualdad genera agreement come, on both the variance
conciliación, tanto sobre la varianza como and the quasivariance, about the two
sobre la cuasivarianza, entre las dos formas ways of observing the dispersion from
de observar la dispersión desde los dos both types of variables, according to Gini
tipos de variables, según Gini (1912). (1912).

Podemos construir dos nuevas medidas We can construct two new measures
usando el agregado del primer miembro de using the first side in the previous
la igualdad anterior, a los que podemos equality, which can be called, for
llamar, por ejemplo, “promedios example, ‘squared means of pairwise
cuadráticos de diferencias por pares” y que differences” and which are defined as
definimos a continuación: follow:
( x − x )
2
( x − x )
2
i j i j
y Vc2 = ( x − x )
2
( x − x )
i j i j 2
V2 = i j
n ( n −1)
i j
n
2
i j and Vc2 = i j
.
V2 =
n2 n ( n −1)
La igualdad de arriba nos permite The above equality allows us to write the
escribir: V 2 = 2 ⋅ S 2 , V c2 = 2 ⋅ S 2 . c
expressions as: V 2 = 2 ⋅ S 2 , V c2 = 2 ⋅ S 2 . c

En todas las medidas citadas hasta ahora In all the aforementioned measures,
la variabilidad depende de dos factores, variability depends on two factors: on the
del número de valores diferentes que nos number of different values that can be
encontremos y de la distancia entre los found and on the distance among them
mismos (influida por la magnitud de los
correspondientes valores).
5
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

Dos valores, xi y xj , que estén muy (affected by the magnitude of the


respective values). Two values, xi and xj ,
separados entre sí, por ser dos cantidades
muy distintas, aportan mucho peso a la which are very separated from each other,
hora de calcular la dispersión mediante as they are two very different quantities,
cualquiera de esas medidas. Serían éstas las present a lot of weight in order to calculate
que al principio hemos llamado “medidas dispersion through any of those measures.
de dispersión”. These would be what at the beginning we
have called ‘measures of dispersion’.
Ahora, podemos plantearnos la variabili-
dad sólo desde el punto de vista de la In this point, we can consider variability
disparidad, del número de posibles parejas from the viewpoint of dissimilarity, of the
de componentes distintos que se pueden number of possible pairs of different
formar, lo que depende del número de components, which depends on the
valores distintos que presente una variable, number of different values a variable
sin tener en cuenta la magnitud de dichos presents, without taking into account
valores. Así, bajo este punto de vista se nos their magnitude. Thus, from this point of
ocurren dos posibles medidas a las que view, two measures can be defined,
podemos llamar “coeficientes de dispa- which can be called ‘coefficients of
ridad” (Perry y Kader, 2005): dissimilarity’ (Perry and Kader, 2005):

c(x , x ) i j  c ( x , x )
i j
1, si xi ≠ x j
c ( xi , x j ) = 
i j
D1 = y/and D2 = i j
, con/being .
n n ( n −1) 0, si xi = x j
2

Por tanto, el numerador de estos Therefore, the numerator in both


coeficientes cuenta el número de coefficients counts the number of
disparidades que encontramos entre los dissimilarities that are found among the
valores de la variable y, como se ha values of the variable and, as it has
dicho, no tiene en cuenta la magnitud de already been said, it does not take into
dichos valores ni, por tanto, la distancia account the magnitude of the values nor
entre los mismos. Cada disparidad la the distance among them. Every
cuenta dos veces, pues contamos la de xi dissimilarity is counted twice, since it is
con xj y la de xj con xi . counted the dissimilarity between xi and
xj , and the one between xj with xi .
Hemos de destacar que estas dos
medidas tienen carácter de coeficiente o It must be emphasised that these two
indicador, por dos razones: no depende measures present the nature of
de las unidades de la variable y su coefficient or indicator for two reasons:
recorrido es menor estricto que 1, en la they do not depend on the variable units
primera, y menor o igual que 1 en la and their range is less than 1, in the first
segunda. Téngase presente que en una measure, and less than or equal to 1, in
muestra tamaño n, si todos los valores the second one. It must also be
observados son distintos, el número total considered that in a sample of size n, if
all observed values are different, the total
6
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

de posibles parejas que se pueden formar, number of possible pairs xi with xj and xj
de xi con xj y de xj con xi , es n 2 . with xi ) to be formed n 2 . From that
number we subtract the pairs of the form
A ese número restamos las parejas del tipo
( x i , x i ) , which are n in total, so the
( xi , x i ) , que son n en total, nos queda
highest number of pairs with different
como número máximo de parejas con components is n 2 − n = n ( n − 1) . We can
componentes distintos n 2 − n = n ( n − 1) .
n −1
Podemos escribir: write: 0 ≤ D1 ≤ < 1 and 0 ≤ D 2 ≤ 1 .
n
n −1 When there is no disparity, when all the
0 ≤ D1 ≤ < 1 y 0 ≤ D 2 ≤ 1 . Cuando
n observations coincide, both coefficients
no hay disparidad, cuando todas las take the value zero. When there is no
observaciones coinciden, ambos coefi- dissimilarity, that is, when all
cientes toman el valor cero. Cuando se observations are the same, both
produce la máxima disparidad, cuando coefficients equal zero. When there is the
todas las observaciones son distintas, el highest dissimilarity, that is, when all
n −1 observations are different, the first
primero toma el valor y el segundo n −1
n coefficient equals and the second
el valor 1. En este aspecto, podríamos n
decir que se trata de medidas relativas de one equals 1. In this regard, it could be
variabilidad. said that they are relative measures of
variability.
Mostramos ejemplos ilustrativos sencillos:
Next some simple illustrative examples
Ejemplo 1: La variable X toma 5 valores are shown.
siendo todos distintos, X : {1, 2, 3, 4, 5} .
Example 1: Variable X presents 5
different values, X : {1, 2, 3, 4, 5} .
La media aritmética es 3.

Calculamos en primer lugar las “medidas The arithmetic mean is 3.


de dispersión” comentadas arriba.
We first calculate the aforementioned
‘measures of dispersion’.

Tabla 1. Cálculo de las desviaciones al cuadrado respecto de la media


Table 1. Calculation of squared differences around the mean

xi xi − X (x )
2
i −X
1 -2 4
2 -1 1
3 0 0
4 1 1
5 2 4
Total 10
7
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

10 10 10
Entonces, S 2 = = 2 y Sc2 = = 2'5 . Then, S 2 =
10
= 2 and Sc2 = = 2'5 .
5 4 5 4
Para la “media de las diferencias” For the ‘differences mean’ we construct
construimos la siguiente tabla: the following table:

Tabla 2. Cálculo de las diferencias por parejas en valor absoluto


Table 2. Calculation of squared pairwise differences in absolute value

xi − x j
xj Suma de cada fila
1 2 3 4 5
xi Total in row
1 0 1 2 3 4 10
2 1 0 1 2 3 7
3 2 1 0 1 2 6
4 3 2 1 0 1 7
5 4 3 2 1 0 10
Total 40

40
Δ= = 2 . Para los promedios cuadráticos de diferencias por pares: / For the squared
5⋅4
means of pairwise differences:

Tabla 3. Cálculo de las diferencias cuadráticas por parejas


Table 3. Calculation of squared pairwise differences

(x − xj)
2
i

xj Suma de cada fila


1 2 3 4 5
xi Total in row
1 0 1 4 9 16 30
2 1 0 1 4 9 15
3 4 1 0 1 4 10
4 9 4 1 0 1 15
5 16 9 4 1 0 30
Total 100

100 100
V2 = = 4 , Vc2 = = 5.
52 5⋅ 4

Calculamos por último los “coeficientes de disparidad” / We finally calculate the


‘coefficients of dissimilarity’:
8
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

Tabla 4. Cálculo de las disparidades por parejas


Table 4. Calculation of pairwise dissimilarities

c ( xi , x j )
xj Suma de cada fila
1 2 3 4 5
xi Total in row
1 0 1 1 1 1 4
2 1 0 1 1 1 4
3 1 1 0 1 1 4
4 1 1 1 0 1 4
5 1 1 1 1 0 4
Total 20

20 20
Por tanto / Therefore D1 = = 0'8 y / and D2 = = 1 .
25 20

Estamos en un caso de máxima disparidad, This is the case of highest dissimilarity,


todos los valores observados de la variable since all observed values of the variable
son distintos. are different.

No hay cosa mejor para visualizar la A better way of visualising variability is to


variabilidad que observar los propios observe the values through some
valores mediante alguna asociación geometric association, especially when
geométrica, sobre todo cuando, como en there are few observed values, like in this
este caso, tenemos pocos valores case. Then, we draw five bars, whose
observados. Construimos, entonces, cinco height is proportional to the magnitudes
barras cuyas longitudes son proporcio- of data and we suggest that our students
nales a la magnitudes de los datos, y observe them in order to compare with
proponemos a los estudiantes su obser- other variables which have also been
vación para que comparen con otras presented. We warn them about mistaking
variables también representadas. Adverti- this chart for the usual bar chart in
mos sobre la posible confusión de este statistics. In this example and for the
gráfico con el diagrama de barras following ones, every bar height does not
habitual en estadística. Aquí, y en los represent the absolute frequency for a
ejemplos que siguen, la longitud de cada value of the variable, but the value itself,
barra no representa la frecuencia and we observe how different to each
absoluta de un valor de la variable, sino other the observed values are within the
que es el propio valor, y observamos en set.
el conjunto cómo de diferentes son entre
sí los valores observados.
9
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

Gráfico 1. Visualización de 5 Graph 1. Visualisation of 5


valores observados observed values

Ejemplo 2. La variable X toma también 5 Example 2: Variable X also presents 5


valores distintos, X : {1, 3, 5, 7 , 9 } . La different values, X : {1, 3, 5, 7 , 9 } . The
diferencia con la anterior está en la difference with the previous one is their
magnitud de los mismos. Procedemos magnitude. We proceed with the same
con los mismos cálculos y representamos computations and present data in a
de manera similar al anterior. En la tabla similar way. In the summary table below
resumen que ponemos más abajo (Tabla (Table 5) all measures of dispersion and
5) aparecen los valores de los estadísticos dissimilarity are presented.
de dispersión y de disparidad.
Example 3. Variable X presents these 5
Ejemplo 3. La variable X toma estos cinco values, X : {1,1, 3, 5 , 5 } . In this case there
valores X : {1,1, 3, 5 , 5 } . Aquí se da más
is more similarity, or more correct, less
paridad o, quizás mejor, menos dissimilarity. This will also be summarised
disparidad. Resumiremos en la tabla. in the table, as it will be for the last
Igual haremos con el último de los cuatro example.
ejemplos.
Example 4. Variable X presents these 5
Ejemplo 4. La variable X toma estos cinco values, X : {1,1, 5, 9 , 9 } .
valores X : {1,1, 5, 9 , 9 } .

Tabla 5. Cuadro resumen de las medidas de variabilidad para los cuatro


ejemplos / Table 5. Summary Table of measures of variability for the four
examples

Ejemplo / Example S2 Sc2 Δ V2 Vc2 D1 D2

2 2’5 2 4 5 0’8 1
10
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

8 10 4 16 20 0’8 1

3’2 4 2’4 6’4 8 0’64 0’8

12’8 16 4’8 25’6 32 0’64 0’8

Comparamos entre sí los ejemplos: A comparison between examples is


carried out:
- Ejemplo 1 y Ejemplo 3: mayor dispersión
en el 3 y mayor disparidad en el 1. - Example 1 and Example 3: higher
Podemos decir que en el ejemplo 3 hay dispersion in 3 and higher dissimilarity in
mayor dispersión que en el 1 y, sin 1. It can be said that in example 3 there is
embargo, menor disparidad. more dispersion than in 1 but less
- Ejemplo 1 y Ejemplo 2: mayor dispersión dissimilarity.
en el 2 que en el 1 (las diferencias en - Example 1 and Example 2: higher
cuanto a sus magnitudes son mayores en dispersion in 2 than in 1 (the differences
los valores observados en el 2 que en el in the magnitude are higher in the
1) y la misma disparidad. observed values in 2 than in 1) and same
- Ejemplo 3 y Ejemplo 4: mayor dispersión dissimilarity.
en el 4 que en el 3 (las diferencias en - Example 3 and Example 4: higher
cuanto a sus magnitudes son mayores en dispersion in 4 than in 3 (the differences
los valores observados en el 4 que en el in the magnitude are higher in the
3) y la misma disparidad. observed values in 4 than in 3) and same
11

dissimilarity.
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

- De los cuatro ejemplos, el de mayor - Out of the four examples, the highest
dispersión es el 4 y, sin embargo, es uno dispersion is in 4 and, however, it is
de los de menor disparidad. one of the examples where there is less
- De los cuatro ejemplos, el de menor dissimilarity.
dispersión es el 1 y, sin embargo, es uno - Out of the four examples, the smallest
de los de mayor disparidad. dispersion is in 1 and, however, it is
one of the examples where there is
Por tanto, hemos de distinguir entre lo que more dissimilarity.
es el “cuánto” de lo que es “con qué
frecuencia”, o sea, la distinción entre Therefore, we have to distinguish between
medidas basadas en la distancia what is “how much” of what is “with what
(dispersión) de las más simples basadas en frequency”, or, the distinction between
la disyuntiva entre igualdad o no igualdad measures based on the distance (dispersion)
(disparidad). Es interesante intentar captar of the simplest stocks in the dilemma
la percepción que nuestros estudiantes between equality or not equality (disparity).
tienen de la variabilidad mediante el It is interesting to try to catch the
ejercicio sencillo de mostrar representacio- perception that our students have of the
nes similares a las anteriores para que se variability by means of the exercise simple
manifiesten sobre cuál presenta mayor o to show representations similar to the
menor variabilidad. previous ones in order that they
demonstrate on which he presents major
or minor variability.
3. MIDIENDO LA VARIABILIDAD EN
CATEGÓRICAS: COEFICIENTES DE 3. MEASURING VARIABILITY IN
DISPARIDAD CATEGORICAL CHARACTERISTICS:
COEFFICIENTS OF DISSIMILARITY
De las dos formas de medir la variabilidad Out of the two ways of measuring
comentadas en el apartado anterior, la variability which were presented in the
primera basada en las distancias no es previous section, the first one based on
aplicable en variables categóricas. Supon- distances is not applicable to categorical
gamos el caso más sencillo, una variable de variables. Let us figure out the simplest
carácter dicotómico donde las dos posibles case, a dichotomous variable where the
respuestas son representadas por A y B. two possible responses are represented
Esas respuestas no están definidas por by A and B. These responses are not
magnitudes numéricas (salvo que codifi- defined as numerical magnitudes (unless
quemos arbitrariamente) por lo que no they are arbitrarily codified), so we cannot
podemos medir la distancia entre A y B, o measure the distance between A and B,
sea, no podemos construir una “medida de that is, we cannot construct a ‘measure of
dispersión” para esta variable. Lo que sí dispersion’ for this variable. What we can
podemos hacer es comparar las respuestas do is to compare the individuals’ responses
de los individuos y ver si las mismas and observe whether they are the same or
coinciden o no. Por tanto, los dos not. Therefore, both coefficients of
coeficientes de disparidad introducidos dissimilarity which were presented for
para cuantitativas serían perfectamente quantitative variables could also be valid in
válidos en las cualitativas y esas son las the case of qualitative ones, and they are
medidas de variabilidad que proponemos the measure of variability we propose for
12

para las mismas. them.


Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

Planteamos tres ejemplos de variables We set out three examples of dichotomous


dicotómicas en los que, para los tres casos, variables where the response of 6
requerimos las respuestas de 6 individuos. individuals is needed. We show the
Visualizamos las respuestas y calculamos responses and calculate both coefficients of
los dos coeficientes de disparidad en cada dissimilarities for each of the three cases:
uno de los tres casos:
Example 1: X : { A , B , B , B , B , B } .
Ejemplo 1: X : { A , B , B , B , B , B } .
Example 2: X : { A , A , A , B , B , B } .
Ejemplo 2: X : { A , A , A , B , B , B } .
Example 3: X : { A , A , B , B , B , B } .
Ejemplo 3: X : { A , A , B , B , B , B } .

Gráfico 2. Visualización de tres variables categóricas con dos posibles


respuesta cada una / Graph 2. Visualisation of three categorical variables
with two possible responses

A B B B B B A A A B B B A A B B B B
Ejemplo 1/Example 1 Ejemplo 2/Example 2 Ejemplo 3/Example 3

Calculamos los coeficientes para los tres We calculate the coefficients for the three
ejemplos consecutivamente, usando tablas examples consecutively, using tables of
de disparidades similares a los ejemplos dissimilarities which are similar to the ones
de cuantitativas, donde hemos sombreado used in the examples of quantitative
las “cajas” donde aparecen 1 (disparida- variables. The cells in the tables where the
des). value is 1 (there is dissimilarity) have been
shaded.

Tabla 6. Disparidades del Ejemplo 1 / Table 6. Dissimilarities in Example 1

c ( xi , x j )
Suma de cada fila
A B B B B B
Total in row
A 0 1 1 1 1 1 5
B 1 0 0 0 0 0 1
B 1 0 0 0 0 0 1
B 1 0 0 0 0 0 1
B 1 0 0 0 0 0 1
B 1 0 0 0 0 0 1
Total 10

10 10
D1 = = 0'277 , D2 = = 0'333 .
62 6⋅5
13
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

Tabla 7. Disparidades del Ejemplo 2 / Table 7. Dissimilarities in Example 2

c ( xi , x j )
Suma de cada fila
A A A B B B
Total in row
A 0 0 0 1 1 1 3
A 0 0 0 1 1 1 3
A 0 0 0 1 1 1 3
B 1 1 1 0 0 0 3
B 1 1 1 0 0 0 3
B 1 1 1 0 0 0 3
Total 18

18 18
D1 = = 0 '5 , D2 = = 0 '6 .
62 6⋅5

Tabla 8. Disparidades del Ejemplo 3 / Table 8. Dissimilarities in Example 3

c ( xi , x j )
Suma de cada fila
A A B B B B
Total in row
A 0 0 1 1 1 1 4
A 0 0 1 1 1 1 4
B 1 1 0 0 0 0 2
B 1 1 0 0 0 0 2
B 1 1 0 0 0 0 2
B 1 1 0 0 0 0 2
Total 16

16 16
D1 = = 0'444 , D2 = = 0'533 .
62 6⋅5

Según estos coeficientes, la variable cate- According to these coefficients, the


górica donde hay menor variabilidad (en el categorical variable where there is the
sentido de disparidad), es la del Ejemplo 1, smallest variability (in the sense of
y la de mayor, la del Ejemplo 2. dissimilarity) is the one in Example 1,
whereas the highest one is in Example 2.
En el Ejemplo 1, para el primer coeficiente
podemos escribir, observando las di- In Example 1, observing the cells where a
mensiones de las cajas donde aparecen 1: value 1 is present, the first coefficient can
be written as:
14

1 ⋅ 5 + 5 ⋅1 2 ⋅ 1 ⋅ 5 1 5
D1 = = 2 = 2⋅ ⋅
62 6 6 6
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

1 1
Obsérvese que la primera fracción, , es la The first fraction, , is the proportion of
6 6
proporción de respuestas A que A responses that are found in that
encontramos en esa variable categórica, categorical variable, whereas the second
5 5
mientras que la segunda, , es la de one, , is the proportion of B responses.
6 6
respuestas B. Por tanto, en el caso de una Therefore, in the case of a categorical
variable categórica con dos posibles variable with two possible responses, if
respuestas, si p 1 es la proporción de p1 is the proportion of responses
respuestas correspondientes a la primera corresponding to the first category, that
n1 n1
categoría, o sea, p1 = , con n1 nú- is, p1 = , with n1 being the number of
n n
mero de veces que aparece la primera times the first responses is found, and if
respuesta, y si p 2 es la proporción para la p 2 is the proportion for the second

n2 n2
segunda respuesta, p2 = , podemos response, that is, p2 = , then, the first
n n
escribir el primer coeficiente de disparidad coefficient of dissimilarity can be written
como: as:

D1 = 2 ⋅ p1 ⋅ p 2 , D1 = 2 ⋅ p1 ⋅ p 2 ,

o sea, 2 veces la varianza de una variable That is, twice the variance of a Bernoulli
aleatoria Bernoulli (la misma relación que random variable (the same relationship
la existente entre varianza y cuasivarianza, as the one existing between variance and
por una parte, y los dos promedios quasivariance, on the one hand, and
cuadráticos de diferencias por pares, por both squared pairwise differences means,
la otra, en el caso cuantitativo). Podíamos on the other, in the case of quantitative
evitar ese 2 si contásemos las disparidades variables). We could eliminate ‘2’ in the
de una pareja una sola vez. Como ya se ha above expression by counting every
comentado, en los coeficientes propues- pairwise dissimilarity only once. As it was
tos contamos la disparidad de xi con xj y already said, in the proposed coefficients,
the dissimilarity of xi with xj and the one
la de xj con xi . A nivel práctico bastaría
of xj with xi is counted. At a practical
con dividir por 2 esos coeficientes. Ahora
bien, al hacerlo cambiaríamos el recorrido level, it would be enough to divide both
de ambos. Por ejemplo, D 2 , en lugar de coefficients by 2. Nevertheless, by doing
that their range would be modified. For
tomar valores entre 0 y 1, los tomaría instance, D 2 , instead of being between
entre 0 y 0’5, como ocurre con los
posibles valores de la varianza de una 0 and 1, would vary from 0 to 0,5, as it
distribución Bernoulli. happens with the possible values of the
variance in a Bernoulli distribution.
Alguna manipulación más es posible:
Some more manipulation is possible:
15
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

La suma de “unos” que aparece en cada tabla The addition of ‘ones’ in each table could
se podría construir así (mirar zonas be calculated as (observe the shaded
sombreadas): areas):

n1 ⋅ n 2 + n 2 ⋅ n1 = n1 ( n − n1 ) + n 2 ( n − n 2 )

Por tanto, / Therefore,

n1 ( n − n1 ) + n2 ( n − n2 ) n1 n − n1 n2 n − n2
D1 = = ⋅ + ⋅ .
n2 n n n n

O sea, ese coeficiente se puede escribir That is, the coefficient can also be
también como: written as:

D 1 = p1 (1 − p1 ) + p 2 (1 − p 2 ) . D 1 = p1 (1 − p1 ) + p 2 (1 − p 2 ) .

Aún otra expresión más. El número de There is also another possible expression.
“unos” que hay en la caja también se The number of ‘ones’ in the table can
puede calcular restando al total de celdas also be calculated by subtracting the
de la tabla el número de “ceros”. Así, en number of ‘zeros’ from the total number
el Ejemplo 3 sería 16 = 62 − 22 − 42 . Por of cells in the table. Thus, in Example 3, it
tanto, would be 16 = 62 − 22 − 42 . Therefore,
2 2 2 2
62 − 22 − 42 2 4 62 − 22 − 42 2 4
D1 = = 1 −   −   . En D1 = = 1 −   −   . In
62 6 6 62  
6 6
general, otra expresión más para el general, another expression for the
cálculo de este coeficiente es: computation of this coefficient is:

D1 = 1 − p12 − p 22 . D1 = 1 − p12 − p 22 .

A continuación planteamos otro ejemplo We next set out another example of


de variable categórica en el que hay tres categorical variable where there are three
posibles respuestas, A, B y C, de una possible responses, A, B and C, to a
cuestión planteada a 8 individuos, dando question posed to 8 individuals, resulting
como resultado la siguiente estadística ya in the following statistics, which have
agrupada por respuestas: already been grouped according to the
responses:
X : { A, B, B, C , C, C , C , C} . Visualizamos estas
respuestas, pero en este caso evitamos la X : { A, B , B , C , C , C , C , C } . We show these
utilización de la longitud como elemento responses but in this case we avoid the
distintivo de las respuestas con el objeto use of the height as a distinguishing
de que las mismas pueden ejercer element among the responses, since they
impacto visual ajeno a lo buscado. can have a visual impact different to the
proper one.
16
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

Gráfico 3. Visualización de una variable categórica con tres posibles


respuestas / Graph 3. Visualisation of a categorical variable with three
possible responses

A B B C C C C C

Calculamos para esta variable los dos coeficientes de disparidad. En primer lugar, la
tabla de disparidades: / We calculate both coefficients of dissimilarity for this variable,
We first present the table of dissimilarities:

Tabla 9. Disparidades de variable categórica con tres posibles respuestas


Table 9. Dissimilarities of a categorical variable with three possible
responses
c ( xi , x j )
Suma de cada fila
A B B C C C C C
Total in row
A 0 1 1 1 1 1 1 1 7
B 1 0 0 1 1 1 1 1 6
B 1 0 0 1 1 1 1 1 6
C 1 1 1 0 0 0 0 0 3
C 1 1 1 0 0 0 0 0 3
C 1 1 1 0 0 0 0 0 3
C 1 1 1 0 0 0 0 0 3
C 1 1 1 0 0 0 0 0 3
Total 34

Entonces, Then,
34 34 34 34
D1 = 2 = 0'531 y D2 = = 0'607 . Si D1 = 2 = 0'531 and D2 = = 0'607 . If
8 8⋅7 8 8⋅7
observamos la tabla, el número de we observe the table, the number of
“unos” que hay en la misma es la suma ‘ones’ that exists in the same one is the
del número de celdas contenidos en la sum of the number of cells contained in
tres cajas enmarcadas y sombreadas (la three boxes framed and shaded (her of A
de A con B, la de A con C, y la de B con with B, her of A with C, and her of B with
C) que, a su vez, están duplicadas. O sea, C) that, in turn, are duplicated. Or,
3 4 = 2 (1 ⋅ 2 + 1 ⋅ 5 + 2 ⋅ 5 ) . Por tanto, 3 4 = 2 (1 ⋅ 2 + 1 ⋅ 5 + 2 ⋅ 5 ) . Therefore,

2(1⋅ 2 +1⋅ 5 + 2 ⋅ 5)  1 2 1 5 2 5  . 2(1⋅ 2 +1⋅ 5 + 2 ⋅ 5)  1 2 1 5 2 5  .


D1 = = 2 ⋅ + ⋅ + ⋅  D1 = = 2 ⋅ + ⋅ + ⋅ 
82 8 8 8 8 8 8 82 8 8 8 8 8 8
Entonces, si p 1 , p 2 y p 3 son las If p 1 , p 2 and p 3 are the proportions of
proporciones de individuos que escogen individuals that who choose each of
cada una de las tres respuestas, tenemos: three responses, respectively, then:
17

D 1 = 2 ( p1 p 2 + p1 p 3 + p 2 p 3 ) D 1 = 2 ( p1 p 2 + p1 p 3 + p 2 p 3 )
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

También, el número de “unos” de la caja The number of ‘ones’ in the table above
anterior puede ser determinado mediante can also be calculated as
34 = 1 ⋅ ( 8 − 1 ) + 2 ⋅ ( 8 − 2 ) + 5 ⋅ ( 8 − 5 ) , por 34 = 1 ⋅ ( 8 − 1) + 2 ⋅ ( 8 − 2 ) + 5 ⋅ ( 8 − 5 ) , so the
lo que el coeficiente sería, coefficient would be:

1 ⋅ ( 8 − 1) + 2 ⋅ ( 8 − 2 ) + 5 ⋅ ( 8 − 5 ) 1 8 −1 2 8 − 2 5 8 − 5 1  1 
D1 = = ⋅ + ⋅ + ⋅ = 1 − 
82 8 8 8 8 8 8 8 8

2 2 5 5
+  1 −  +  1 −  . En general, / In general,
8 8 8 8

D1 = p1 (1 − p1 ) + p 2 (1 − p 2 ) + p 3 (1 − p 3 ) .

Por último, la suma de “unos” puede Finally, the sum of ‘ones’ can also be
calcularse también restando al total de calculated by subtracting from the total
celdas de la caja, 82 , el total de ceros que number of cells in the table, 82 , the
hay en ella. O sea, 34 = 82 −12 − 22 − 52 . Por number of ‘zeros’ in it. That is,
tanto, 34 = 82 −12 − 22 − 52 . Therefore,

2 2 2 2 2 2
82 −12 − 22 − 52 1  2 5 82 −12 − 22 − 52 1  2 5
D1 = = 1 −   −   −   . En D1 = = 1 −   −   −   . In
8  8  8 8  8 8
2 2
8 8
general, general,

D1 = 1 − p12 − p 22 − p 32 . D1 = 1 − p12 − p 22 − p 32 .

A partir de los ejemplos analizados para From the examples above for two or
dos o tres posibles respuestas de una three possible responses of a qualitative
variable cualitativa nos resulta relativa- variable it is relatively easy to define
mente fácil establecer diferentes expre- different expressions for the first
siones para el primer coeficiente de coefficient of dissimilarity: If there is a
disparidad: Si una variable categórica categorical variable with k possible
tiene k posibles respuestas o categorías y responses o categories, if there are a
si disponemos de un número finito de finite number of observations, n, and if
observaciones, n, y si n1 , n 2 ,..., ni , ..., n k n1 , n2 ,..., ni ,..., nk , represent the frequency
representan la frecuencia con que of appearance of every category, with
aparece cada una de las categorías con, n1 + n 2 + ... + n i + ... + n k = n , then
naturalmente, n1 + n2 + ... + ni + ... + nk = n ,
n1
pi = , i = 1, 2,..., k , is the proportion of
n n
llamamos pi = 1 , i = 1, 2,..., k , o sea, la
n responses in the category i for the
proporción de respuestas que corres- observations.
ponde a la categoría i entre las observa-
18

ciones.
Midiendo la variabilidad en caracteres cualitativos
Measuring variability in qualitative characteristics

Entonces, podemos escribir para el primer coeficiente de disparidad las siguientes


expresiones: / Then, the first coefficient of dissimilarity can be written as:

D1 = 2 pi pj ,
i< j
k
D1 =  pi (1− pi ) ,
i =1
k
D1 = 1 −  pi2 .
i =1

4. CONCLUSIONES 4. CONCLUSIONS

El concepto de variabilidad es más amplio The concept of variability is wider than


de lo que habitualmente se explica en los the one that is usually discussed in
libros de texto y en clase. En variables literature and classroom. In the case of
cuantitativas, además de la idea de quantitative variables, apart from the
dispersión, en general ligada a la desviación idea of dispersion, in general related to
respecto a la media, podemos introducir the deviation around the mean, it can be
por ejemplo la de disparidad, que conduce introduced, for example, the idea of
a medidas sencillas e intuitivas. La dissimilarity, which results in simple and
distinción entre el “cuánto” y “con qué intuitive measures. The difference between
frecuencia” es la base de la separación ‘when’ and ‘how frequently’ is the base
entre dispersión y disparidad. Aunque el to distinguish between dispersion and
“cuánto se diferencian los datos” no se dissimilarity. Even though ‘how much data
puede medir en variables categóricas, sí are different’ cannot be measured in
podemos contar “con qué frecuencia son categorical variables, it is possible to
distintas las respuestas”. Por tanto, count ‘how frequently responses are
medidas relacionadas con la disparidad son different’. Therefore, measures related to
posibles en variables cualitativas. Creemos dissimilarity are possible to be defined in
que dichas medidas, a las que hemos qualitative variables. We think that these
llamado “coeficientes de disparidad”, por measures, which we have called
su naturalidad y sencillez, deben ser ‘coefficients of dissimilarity’, due to their
abordadas en un curso de introducción a la naturalness and simplicity, must be dealt
estadística descriptiva llenando así uno de with in a descriptive statistics introductory
los vacíos tradicionales de la enseñanza de course, filling in this way one of the gags
esta disciplina. La estadística existe al existir in the teaching of this subject. Statistics
variabilidad dentro de un carácter medido exists because variability inside a
en una población y dicho carácter puede characteristic measured on a population
ser cuantitativo o cualitativo. Es función del exists, and that characteristic can be
usuario de la estadística poder medir dicha quantitative or qualitative. To measure
variabilidad. La visualización de ejemplos that variability is a role corresponding to
simples por parte de los alumnos permitirá the user of statistics. The visualization of
al profesor la captación de las ideas que simple examples by students will allow
sobre variabilidad tienen los mismos. the teacher to catch the idea they have
19

on variability.
Pecvnia, Monográfico (2012), 1-20
J. Basulto, J.A. Camúñez, F.J. Ortega y M.D. Pérez

BIBLIOGRAFÍA/REFERENCES

Agresti, A. (1990). Categorical data analysis. John Wiley & Sons.


Blasius, J. y Greenacre, M. (1998). Visualization of categorical data. San Diego (CA): Academic
Press.
Gini, C.W. (1912). Variability and mutability, contribution to the study of statistical distributions and
relations. Estudi Economico-Giuricici della R. Universita de Cagliari.
Gordon, T. (1986). Is the standard deviation tied to the mean? Teaching Statistics, 8(2), 67-70.
Kader, G.D. y Perry, M. (2007). Variability for categorical variables. Journal of Statistics Education,
15(2), 1-17.
Loosen, F., Lioen, M. y Lacante, M. (1985). The standard deviation: Some drawbacks to an
intuitive approach. Teaching Statisctics, 7(1), 2-5.
Perry, M. y Kader, G. (2005). Variation as unalikeability. Teaching Statistics, 27(2), 58-60.
20

También podría gustarte