0% found this document useful (0 votes)
35 views12 pages

Matrix de Covarianza

This lesson explains how to use matrix methods to generate a variance-covariance matrix from a matrix of raw data.

Uploaded by

Gonzalo Saavedra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views12 pages

Matrix de Covarianza

This lesson explains how to use matrix methods to generate a variance-covariance matrix from a matrix of raw data.

Uploaded by

Gonzalo Saavedra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

http://stattrek.com/matrix-algebra/covariance-matrix.

aspx

Variance-Covariance Matrix
This lesson explains how to use matrix methods to generate a variance-covariance matrix from a
matrix of raw data.

Variance

Variance is a measure of the variability or spread in a set of data. Mathematically, it is the


average squared deviation from the mean score. We use the following formula to compute
variance.

Var(X) = Σ ( Xi - X )2 / N = Σ xi2 / N

where

N is the number of scores in a set of scores


X is the mean of the N scores.
Xi is the ith raw score in the set of scores
xi is the ith deviation score in the set of scores
Var(X) is the variance of all the scores in the set

Covariance

Covariance is a measure of the extent to which corresponding elements from two sets of
ordered data move in the same direction. We use the following formula to compute covariance.

Cov(X, Y) = Σ ( Xi - X ) ( Yi - Y ) / N = Σ xiyi / N

where

N is the number of scores in each set of data


X is the mean of the N scores in the first data set
Xi is the ithe raw score in the first set of scores
xi is the ith deviation score in the first set of scores
Y is the mean of the N scores in the second data set
Yi is the ithe raw score in the second set of scores
yi is the ith deviation score in the second set of scores
Cov(X, Y) is the covariance of corresponding scores in the two sets of data

Variance-Covariance Matrix
Variance and covariance are often displayed together in a variance-covariance matrix, (aka, a
covariance matrix). The variances appear along the diagonal and covariances appear in the off-
diagonal elements, as shown below.

..
Σ x12 / N Σ x1 x2 / N Σ x1 xc / N
.

..
Σ x2 x1 / N Σ x22 / N Σ x2 xc / N
.
V =
..
... ... ...
.

..
Σ xc x1 / N Σ xc x2 / N Σ xc2 / N
.

where

V is a c x c variance-covariance matrix
N is the number of scores in each of the c data sets
xi is a deviation score from the ith data set
Σ xi2 / N is the variance of elements from the ith data set
Σ xi xj / N is the covariance for elements from the ith and jth data sets

How to Create a Variance-Covariance Matrix

Suppose X is an n x k matrix holding ordered sets of raw data. For example, matrix X might
display the scores on k tests for n students, as shown in Problem 1.

Starting with the raw data of matrix X, you can create a variance-covariance matrix to show the
variance within each column and the covariance between columns. Here's how.

 Transform the raw scores from matrix X into deviation scores for matrix x.

x = X - 11'X ( 1 / n )

where

1 is an n x 1 column vector of ones


x is an n x k matrix of deviation scores: x11, x12, . . . , xnk
X is an n x k matrix of raw scores: X11, X12, . . . , Xnk
 Compute x'x, the k x k deviation sums of squares and cross products matrix for x.

 Then, divide each term in the deviation sums of squares and cross product matrix
by n to create the variance-covariance matrix. That is,

V = x'x ( 1 / n )

where

V is a k x k variance-covariance matrix
x'x is the deviation sums of squares and cross product matrix
n is the number of scores in each column of the original matrix X

In the next section, read Problem 1 for an example showing how to turn raw data into a
variance-covariance matrix.

Test Your Understanding of This Lesson

Problem 1

The table below displays scores on math, English, and art tests for 5 students. Note that data
from the table is represented in matrix A, where each column in the matrix shows scores on a
test and each row shows scores for a student.

6
90 90
0

Student Math English Art 9


90 30
0
1 90 60 90
6
60 60
2 90 90 30 0

3 60 60 60 6
60 90
0
4 60 60 90

3
5 30 30 30 30 30
0

A
Given the data represented in matrix A, compute the variance of each test and the covariance
between the tests.

Solution

The solution involves a three-step process.

 First, we transform the raw scores in matrix A to deviation scores in matrix a, using the
transformation formula described at how to transform raw scores to deviation scores.

a = A - 11'A ( 1 / n )

where

1 is an 5 x 1 column vector of ones


a is an 5 x 3 matrix of deviation scores: a11, a12, . . . , a53
A is an 5 x 3 matrix of raw scores: A11, A12, . . . , A53
n is the number of rows in matrix A

6 6
90 90 90 90
0 0

9 1 1 1 1 1 9
90 30 90 30
0 0
1 1 1 1 1

6 6
a = 60 60 - 1 1 1 1 1 60 60 ( 1/5 )
0 0

1 1 1 1 1
6 6
60 90 60 90
0 1 1 1 1 1 0

3 3
30 30 30 30
0 0

a = 6 - 6 = 24 0 30
90 90 66 60
0 0
24 30 -30
9 6
90 30 66 60 -6 0 0
0 0

-6 0 30
60 6 60 66 6 60
0 0

6 6
60 90 66 60
0 0 -36 -30 -30

3 6
30 30 66 60
0 0

 Then, to find the deviation score sums of squares matrix, we compute a'a, as shown
below.

24 0 30 252
1800 900
- 0
24 24 -6 -36 24 30 -30
6
180
a' a = -6 0 0 = 1800 0
0 30 0 0 -30 0

-6 0 30
30 -30 0 30 -30 360
900 0
-36 -30 -30 0

 And finally, to create the variance-covariance matrix, we divide each element in the
deviation sum of squares matrix by n, as shown below.

2520/5 1800/5 900/5


504 360 180

V = a' a / n 1800/5 1800/5 0/5


= 360 360 0
=
3600/
900/5 0/5 180 0 720
5

We can interpret the variance and covariance statistics in matrix V to understand how the
various test scores vary and covary.

 Shown in red along the diagonal, we see the variance of scores for each test. The art test
has the biggest variance (720); and the English test, the smallest (360). So we can say
that art test scores are more variable than English test scores.

 The covariance is displayed in black in the off-diagonal elements of matrix V.


 The covariance between math and English is positive (360), and the covariance
between math and art is positive (180). This means the scores tend to covary in
a positive way. As scores on math go up, scores on art and English also tend to
go up; and vice versa.

 The covariance between English and art, however, is zero. This means there
tends to be no predictable relationship between the movement of English and
art scores.

If the covariance between any tests had been negative, it would have meant that the test scores
on those tests tend to move in opposite directions. That is, students with relatively high scores
on the first test would tend to have relatively low scores on the second test.

< Previous lesson Next lesson >

Matrix Algebra

Traduccion

Matrix de Varianza-covarianza
Esta lección explica cómo utilizar métodos matriciales para generar una matriz de varianza-
covarianza de una matriz de datos en bruto.

Desacuerdo

Varianza es una medida de la variabilidad o la propagación en un conjunto de datos.


Matemáticamente, es la desviación media cuadrada de la media de puntuación. Nosotros
usamos la siguiente fórmula para calcular la varianza.

Var ( X ) = Σ ( X i - X ) 2 / N = Σ x i
2
/N

donde
N es el número de puntuaciones en un conjunto de partituras X es la media de
las Npuntuaciones. X i es la i ª puntaje bruto en el conjunto de partituras x i es la i ª puntuación
de la desviación en el conjunto de puntuaciones Var ( X ) es la varianza de todas las
puntuaciones obtenidas en el conjunto

Covarianza

Covarianza es una medida de la medida en que los elementos correspondientes de dos


conjuntos de datos ordenados se mueven en la misma dirección. Nosotros usamos la siguiente
fórmula para calcular la covarianza.

Cov ( X , Y ) = Σ ( X i - X ) ( Y i - Y ) / N = Σ x i y i / N

donde

N es el número de puntuaciones en cada conjunto de datos X es la media de las N puntajes en


el primer conjunto de datos X i es la i el puntaje bruto en el primer conjunto de partituras x i es
la i ª puntuación de la desviación en el primer set de las puntuaciones Y es la media de
los N resultados en el segundo conjunto de datos Y i es la i el puntaje bruto en el segundo
conjunto de puntuaciones y i es la i ª puntuación de la desviación en el segundo conjunto de
puntuaciones Cov ( X , Y ) es la covarianza de las puntuaciones correspondientes en los dos
conjuntos de datos

Varianza-covarianza Matrix

Varianza y covarianza se muestran a menudo juntos en una varianza-covarianza de matriz , (aka,


una matriz de covarianza). Las variaciones aparecen a lo largo de la diagonal y covarianzas
aparecen en los elementos fuera de la diagonal, como se muestra a continuación.

V = Σx 1 x 2/ Σx 1 x c/
Σx 1
2
/N ...
N N

Σx 2 x 1/ Σx 2 x c/
Σx 2
2
/N ...
N N

... ... ... ...


Σx c x 1/ Σx c x 2/
... Σx c
2
/N
N N

donde

V es un c x c matriz de varianza-covarianza

N es el número de puntuaciones en cada una de las c conjuntos de datos x i es una puntuación


de la desviación del ith de datos conjunto Σ x i
2
/ N es la variación de los elementos de la i ª
datos conjunto Σ x i xi j / N es la covarianza para los elementos de la i ª y j º conjuntos de datos

Cómo crear una varianza-covarianza Matrix

Supongamos que X es un n x k matriz sostiene conjuntos ordenados de datos en bruto. Por


ejemplo, la matriz X puede mostrar las puntuaciones en k pruebas de n estudiantes, como se
muestra en el problema 1 .

A partir de los datos brutos de la matriz X , puede crear una matriz de varianza-covarianza para
mostrar la varianza dentro de cada columna y la covarianza entre columnas. He aquí cómo.

 Transformar los puntajes brutos de la matriz X en puntuaciones de la desviación de la


matriz x.

x = X - 1 1 ' X (1 / n)

donde

1 es un n x 1 columna vector de unos x es un n x k matriz


de desviación puntuaciones: x 11 ,x 12 ,. . . , x nk X es un n x k matriz
de primas puntuaciones: X 11 ,X 12 ,. . . , X nk

 Calcular x ' x , los k x k sumas de desviación de plazas y cruz matriz productos para x .

 Luego, dividir cada término de la suma de la desviación de plazas y matriz de producto


en profundidad de n para crear la matriz de varianza-covarianza. Es decir,

V = x ' x (1 / n)
donde

V es un k x k varianza-covarianza de matriz x ' x es la suma de la desviación de plazas y


cruz matriz de producto n es el número de puntuaciones en cada columna de la matriz
originalX

En la siguiente sección, lea Problema 1 para un ejemplo que muestra cómo convertir los datos
en bruto en una matriz de varianza-covarianza.

Pon a prueba tu comprensión de esta lección

Problema 1

La siguiente tabla muestra las puntuaciones en matemáticas, Inglés, y pruebas de arte para 5
estudiantes. Tenga en cuenta que los datos de la tabla se representa en la matriz A , donde cada
columna de la matriz muestra las puntuaciones en una prueba y cada fila muestra las
calificaciones para un estudiante.

6
90 90
0

Estudiante Matemáticas Inglés Arte 9


90 30
0
1 90 60 90
6
60 60
2 90 90 30 0

3 60 60 60 6
60 90
0
4 60 60 90

3
5 30 30 30 30 30
0

La

Teniendo en cuenta los datos representados en la matriz A , calcular la varianza de cada prueba
y la covarianza entre las pruebas.

Solución

La solución implica un proceso de tres pasos.


 En primer lugar, transformamos las primas puntuaciones en la matriz A a la
desviación puntajes en la matriz una , utilizando la fórmula de transformación descrita
en la manera de transformar los puntajes brutos de puntuaciones de la desviación .

un = A - 1 1 ' Un (1 / n)

donde

1 es un 5 x 1 columna vector de las una es un 5 x 3 matriz


de desviación puntuaciones: un 11 , un 12 ,. . . , un 53 A es una 5 x 3 matriz
de primas puntuaciones: A 11 ,A 12 ,. . . , A 53 nes el número de filas de la matriz A

6 6
90 90 90 90
0 0

9 1 1 1 1 1 9
90 30 90 30
0 0
1 1 1 1 1

6 6
un = 60 60 - 1 1 1 1 1 60 60 (1/5)
0 0

1 1 1 1 1
6 6
60 90 60 90
0 1 1 1 1 1 0

3 3
30 30 30 30
0 0

un = 6 - 6 = 24 0 30
90 90 66 60
0 0
24 30 -30
9 6
90 30 66 60 -6 0 0
0 0

-6 0 30
6 6
60 60 66 60
0 0
-36 -30 -30

6 6
60 90 66 60
0 0

30 3 30 66 6 60
0 0

 Luego, buscar las sumas de puntuación de la desviación de la matriz cuadrados,


calculamosuna ' una , como se muestra a continuación.

24 0 30 252
1800 900
- 0
24 24 -6 -36 24 30 -30
6
180
un ' un = -6 0 0 = 1800 0
0 30 0 0 -30 0

-6 0 30
30 -30 0 30 -30 360
900 0
-36 -30 -30 0

 Y, por último, para crear la matriz de varianza-covarianza, dividimos cada elemento de la


suma desviación de matriz cuadrados por n , como se muestra a continuación.

2520/5 1800/5 900/5


504 360 180

V = a ' un / n 1800/5 1800/5 0/5


= 360 360 0
=
3600/
900/5 0/5 180 0 720
5

Podemos interpretar las estadísticas de varianza y covarianza de matriz V para entender cómo
los diferentes resultados de las pruebas varían y covary.

 Se muestra en rojo a lo largo de la diagonal, vemos la varianza de las puntuaciones de


cada prueba. La prueba de arte tiene la mayor varianza (720); y la prueba de Inglés, el
más pequeño (360). Así que podemos decir que los resultados de las pruebas de arte
son más variables que las puntuaciones de la prueba de inglés.

 La covarianza se muestra en negro en los elementos fuera de la diagonal de la matriz V .

 La covarianza entre las matemáticas y Inglés es positivo (360), y la covarianza


entre las matemáticas y el arte es positivo (180). Esto significa que los
resultados tienden a covariar de una manera positiva. Como las puntuaciones
en matemáticas suben, las puntuaciones en el arte y Inglés también tienden a
subir; y viceversa.
 La covarianza entre Inglés y el arte, sin embargo, es cero. Esto significa tiende a
haber ninguna relación predecible entre el movimiento de las puntuaciones de
arte Inglés y.

Si la covarianza entre las pruebas había sido negativo, habría significado que los resultados de
las pruebas sobre esas pruebas tienden a moverse en direcciones opuestas. Es decir, los
estudiantes con puntuaciones relativamente altas en la primera prueba tenderían a tener
puntajes relativamente bajos en la segunda prueba.

<Anterior lección Siguiente lección>

Álgebra matricial

You might also like