1st Lesson Econometrics
1st Lesson Econometrics
1st Lesson Econometrics
státním rozpočtem ČR a rozpočtem hlavního města Prahy. Praha & EU: Investujeme do vaší budoucnosti
Department of Economics
Subject: Econometrics
1st LESSON:
Operations with a Matrix;
Regression and Correlation
2011 ©
Introduction
In this document you can found the examples which are related with 1st econometric lesson.
The content is shown below. Every subchapter has one example which is solved. Other
exercises are for practising, solution is in the end of the main chapters.
Content
1 OPERATIONS WITH A MATRIX.................................................................................... 2
1.1 Addition and scalar multiplication ................................................................................... 2
1.2 Matrix multiplication – Size of a Matrix......................................................................... 3
1.3 Matrix multiplication....................................................................................................... 3
1.4 Rank of a Matrix ............................................................................................................. 5
1.5 Determinant of a Matrix.................................................................................................. 6
1.6 Inverse of a Matrix .......................................................................................................... 8
1.7 Transposition of a Matrix................................................................................................ 9
1.8 Results of practising exercises ...................................................................................... 11
2 REGRESSION AND CORRELATION........................................................................... 14
2.1 Simple Linear Regression ............................................................................................. 14
2.2 Correlation analysis....................................................................................................... 16
2.3 Practising exercises ....................................................................................................... 17
2.4 Results of practising exercises ...................................................................................... 19
1
1 Operations with a Matrix
1.1 Addition and scalar multiplication
Solved Example:
2 4 8 2
2 ⋅ 3 1 + 4 13
5 10 − 2 − 13
2 4 8 2 4 8 8 2 12 10
2 ⋅ 3 1 + 4
13 = 6 2 + 4 13 = 10 15
5 10 − 2 − 13 10 20 − 2 − 13 8 7
Practising Exercises:
i)
5 10 5 5 10 5
4⋅ − 3⋅
8 2 1 8 2 1
ii)
3 6 1 6 8
− 5⋅ + ⋅
8 4 2 7 10
iii)
1 3
2 4
10 ⋅ + 5 ⋅ 5 5
7 11 1 2
iv)
3 2 4 36 24 6 21 4 8
5 10 3 + 1 ⋅ 12 48 78 − 1 ⋅ 8 3 10
6 2
12 5 3 6 36 12 40 6 18
2
1.2 Matrix multiplication – Size of a Matrix
A matrix has m rows and n columns. The size of the matrix is [m x n].
The rule for matrix multiplication is follows: Two matrices can be multiplied only when the
number of columns in the first matrix equals the number of rows in the second matrix. In
other words n in the first matrix has to be equal m in the second matrix.
Solved Example:
We have two matrices, the A with size [3x2] and the B with size [2x4]. Can we multiply these
matrices, what size will have the final matrix?
A = [3x2] B = [2x4] A*B = ?
Yes, we can multiply these matrices, because first matrix has 2 columns and second matrix
has 2 rows. After multiplication we gained the matrix with size [3x4].
Practising Exercises:
C = [3x1] D = [1x5] E = [1x2] F = [1x3] H = [4x1]
2 3 5 6 2 1 2 * 6 + 3 * 3 + 5 * 1 2 * 2 + 3 * 7 + 5 * 4 2 * 1 + 3 * 2 + 5 * 2
A * B = 4 1 2 * 3 7 2 = 4 * 6 + 1* 3 + 2 *1 4 * 2 + 1* 7 + 2 * 4 4 *1 + 1* 2 + 2 * 2 =
5 3 1 1 4 2 5 * 6 + 3 * 3 + 1*1 5 * 2 + 3 * 7 + 1* 4 5 *1 + 3 * 2 + 1* 2
3
Practising Exercises:
i)
2 3 5 6 2 1
A = 4 1 2 B = 3 7 2 B* A = ?
5 3 1 1 4 2
ii)
1 4 5 3
C= D= C*D = ? D *C = ?
5 7 2 1
iii)
1 3 9 4 7 1
E = 5 2 1 F = 3 2 3 E*F = ? F *E = ?
6 3 4 1 1 2
iv)
3 8
G = [5 2 − 1] H = − 2 5 G*H = ? H *G = ?
4 1
v)
2 3
− 1 5 2
I = 1 2 J = I *J =? J *I = ?
4 − 5 3 1 4
4
1.4 Rank of a Matrix
The rank of a matrix is the maximum number of linearly independent row vectors of the
matrix, which is the same as the maximum number of linearly independent column vectors.
Solved Example:
Task: Determine the rank of a matrix.
1 2 4 2
− 2 1 − 2 − 2
A= h( A) = ?
1 4 6 3
3 6 10 2
1 2 4 2 *2 1 2 24 1 2 4 2 *(-3)
− 2 1 − 2 − 2 (+) 0 5 2
6 0 5 6 2
(-)
∼ ∼
1 4 6 3 1 4 36 0 − 2 − 2 − 1
3 6 10 2 3 6 10 2 3 6 10 2
1 2 4 2 1 2 4 2 1 2 4 2
0 5 6 2 *2 0 5 6 2 0 5 6 2
∼ ∼ ∼
0 − 2 − 2 − 1 *5 0 0 2 − 1 0 0 2 − 1
(+)
0 0 − 2 − 4 0 0 − 2 − 4 0 0 0 − 5
Conclusion: h( A) = 4
Practising Exercises:
i)
2 6 10
B = − 4 − 6 − 10
h( B ) = ?
− 1 − 2 − 3
ii)
2 2 8
C = 4 2 − 6 h(C ) = ?
− 2 0 14
iii)
1 2 3 4
− 2 3 5 0
D= h( D) = ?
− 3 1 2 − 4
4 − 6 − 10 0
5
iv)
2 4 8 2
− 1 − 1 2 1
E= h( E ) = ?
2 6 0 4
2 8 12 5
v)
1 3 2 1 5
− 2 − 2 4 3 − 4
F = 1 2 −2 1 1 h( F ) = ?
−1 1 6 4 1
3 5 0 8 19
det( A) = (2 * 9) − (3 * 5) = 18 − 15 = 3
8 3 5 8 3
B = 2 1 1 2 1
6 2 4 6 2
det( B ) = 70 − 70 = 0
Note:
If a matrix´s determinant is equal to zero, then the matrix is singular (degenerate).
If a matrix´s determinant is not equal to zero, then the matrix is invertible (nonsingular).
Only for invertible matrix it is possible to express an inverse of matrix.
6
Practising Exercises:
i)
4 2
C= det(C ) = ?
8 4
ii)
25 5
D= det( D) = ?
3 2
iii)
1 3 − 1
E = 4 2 5 det( E ) = ?
4 5 5
iv)
1 4 2
F = − 1 3 5 det( F ) = ?
3 1 2
7
1.6 Inverse of a Matrix
Solved Example:
1 4 1
A = 1 2 2 A −1 = ?
0 2 1
1 4 1 1 0 0 1 4 1 1 0 0 1 4 1 1 0 0
(-)
1 2 2 0 1 0 ∼ 0 2 − 1 1 − 1 0 ∼ 0 2 − 1 1 − 1 0 ∼
0 2 1 0 0 1 0 2 1 0 0 1 (-) 0 0 − 2 1 − 1 − 1 /(-2)
1 4 1 1 0 0 1 4 1 1 0 0
0 2 − 1 1 −1 0 ∼ 0 2 0 1 / 2 − 1 / 2 1 / 2 /(2) ∼
0 0 1 − 1 / 2 1 / 2 1 / 2 (+) 0 0 1 − 1 / 2 1 / 2 1 / 2
1 4 1 1 0 0 1 4 0 3 / 2 − 1 / 2 − 1 / 2
0 1 0 1 / 4 − 1 / 4 1 / 4 (-) ∼ 0 1 0 1 / 4 − 1 / 4 1 / 4 *(-4) ∼
0 0 1 − 1 / 2 1 / 2 1 / 2 0 0 1 − 1 / 2 1 / 2 1 / 2
1 0 0 1 / 2 1 / 2 − 3 / 2
0 1 0 1 / 4 − 1 / 4 1 / 4
0 0 1 − 1 / 2 1 / 2 1 / 2
Verification:
A * A−1 = Ι
8
Practising Exercises:
i)
2 4
B= B −1 = ?
− 1 3
ii)
1 − 3 3
C = − 1 1 0 C −1 = ?
0 1 1
iii)
1 0 1
D = 2 1 0 D −1 = ?
0 − 1 1
iv)
1 3 0
E = − 3 1 2 E −1 = ?
0 0 1
v)
2 1 1
F = 0 2 1 F −1 = ?
− 2 1 1
1 7 − 2
AT = 4 3 8
5 6 9
9
Practising Exercises:
i)
2 3 5 − 5
B = 8 2 − 3 3 BT = ?
1 4 9 11
ii)
2 3 1 5
− 5 7 − 9 6
C= CT = ?
4 8 11 7
10 12 13 2
iii)
1 4 2
D = 4 3 5 DT = ?
2 5 7
10
1.8 Results of practising exercises
1.1 Addition and scalar multiplication
i)
− 10 34 11
5 20 − 17
ii)
− 12 − 26
− 36.5 − 15
iii)
we cannot solve this example, matrices do not have same size
iv)
− 1.5 4 1
3 16.5 11
− 7 8 − 4
ii)
13 7 20 41
C*D = D *C =
39 22 7 15
iii)
22 22 28 45 29 47
E * F = 27 40 13 F * E = 31 22 41
37 52 23 18 11 18
iv)
G * H = [7 49]
H *G = ∅
11
We cannot multiply these matrices, because the rule for matrix multiplication is not fulfilled.
v)
7 13 16
I * J = 5 7 10
− 19 15 − 12
J *I =∅
We cannot multiply these matrices, because the rule for matrix multiplication is not fulfilled.
ii) h(C ) = 2
iii) h( D) = 2
iv) h( E ) = 4
v) h( F ) = 4
ii) det( D) = 35
iv) det( F ) = 49
ii)
− 0.2 − 1.2 0.6
C −1
= − 0.2 − 0.2 0.6
0.2 0.2 0.4
iii)
− 1 1 1
D = 2 − 1 − 2
−1
2 − 1 − 1
12
iv)
0.1 − 0.3 0.6
E −1 = 0.3 0.1 − 0.2
0 0 1
v)
0.25 0 − 0.25
F −1
= − 0.5 1 − 0.5
1 −1 1
ii)
2 − 5 4 10
3 7 8 12
C =
T
1 − 9 11 13
5 6 7 2
iii)
1 4 2
D = 4 3 5
T
2 5 7
13
2 Regression and Correlation
Example:
Final consumption expenditure of household on foodstuff in milliard CZK and nominal wage
in thousand CZK are shown in the table below. Derive a simple linear regression function
between these variables.
Solving:
The simple linear regression function is: y = a + bx , where a is the intercept and b is the slope.
The method least squares are used to fit the regression equation. For simple regression it is
possible to use the following two formulas:
n ∑ x i y i − ∑ xi ∑ y i xy − x ⋅ y
b= =
n∑ x − (∑ xi )
2
2
i x2 − x 2
a = y −b⋅x
where:
n
∑x
i =1
i
x is the arithmetic mean of variable x, i.e. x =
n
14
n
∑y
i =1
i
y is the arithmetic mean of variable y, i.e. y =
n
n
∑x y
i =1
i i
xy is the arithmetic mean of product of variables x and y, i.e. xy =
n
2
n
∑ xi
x is the arithmetic mean of power on two, i.e. x = i =1
2 2
n
n
∑x
i =1
2
i
x 2 is the arithmetic mean of x square, i.e. x 2 =
n
Calculations:
y x xy x2
2000 191.95 13.219 2 537.44 174.74
2001 206.41 14.378 2 967.78 206.73
2002 203.78 15.524 3 163.42 240.99
2003 203.32 16.430 3 340.47 269.94
2004 211.99 17.466 3 702.67 305.06
2005 213.95 18.344 3 924.66 336.50
2006 222.12 19.546 4 341.48 382.05
2007 241.50 20.957 5 061.20 439.20
2008 272.66 22.592 6 160.00 510.40
2009 262.11 23.344 6 118.79 544.94
Sum 2 229.79 181.800 41 317.90 3 410.55
Mean 222.98 18.180 4 131.79 341.06
Interpretation: If the nominal wage increases by 1 thousand CZK, then the final
consumption expenditure of household on foodstuff will increase by 7.395 milliard CZK.
15
2.2 Correlation analysis
A correlation coefficient indicates how much are two variables associated. The Pearson
correlation coefficient takes values <-1; 1> The correlation is +1 in the case of a perfect
positive (increasing) linear relationship, -1 in the case of a perfect negative (decreasing) linear
relationship. If the correlation coefficient is equal to zero, there isn’t linear dependence
between the variables.
Example:
Consider the solved example from chapter 2.1 Simple Linear Regression. Compute
correlation coefficient between variables final consumption expenditure and nominal wage.
Solving:
The formula for computing the correlation coefficient is given by:
xy − x ⋅ y s xy
ryx = =
( )(
x2 − x 2 y2 − y 2 )
sx sy
A lot of statistics from the formula above were computed in the case of linear regression.
We know that:
x = 18.180 y = 222.98 xy = 4 131.79 x 2 = 18.1082 = 330.51 x 2 = 341.06
16
Calculations:
2 2
y x xy x y
2000 191.95 13.219 2 537.44 174.74 36 846
2001 206.41 14.378 2 967.78 206.73 42 606
2002 203.78 15.524 3 163.42 240.99 41 525
2003 203.32 16.430 3 340.47 269.94 41 337
2004 211.99 17.466 3 702.67 305.06 44 941
2005 213.95 18.344 3 924.66 336.50 45 774
2006 222.12 19.546 4 341.48 382.05 49 336
2007 241.50 20.957 5 061.20 439.20 58 324
2008 272.66 22.592 6 160.00 510.40 74 345
2009 262.11 23.344 6 118.79 544.94 68 704
Sum 2 229.79 181.800 41 317.90 3 410.55 503 736.83
Mean 222.98 18.180 4 131.79 341.06 50 373.68
17
ii)
Evaluate the effect of total investment for environmental protection on the carbon monoxide
(CO) reduction. Use the simple regression function. It is true, that growth of investment leads
to reduction of polluting matter and how large is this change? The necessary data are in the
next table. Also compute the correlation coefficient.
Carbon
Total investment for
monoxide (CO)
environmental protection
in thousand tons
in milliard CZK
per year
2000 539 21.399
2001 539 19.892
2002 517 14.919
2003 529 19.383
2004 509 20.208
2005 491 18.248
2006 481 22.470
2007 435 19.900
2008 445 20.327
iii)
Evaluate a correlation between final expenditure of households on higher education and
number of students at universities. Also create a simple linear model where final expenditure
will be depended on number of students. The time series of final expenditure is in million
CZK and number of students is in thousands.
18
2.4 Results of practising exercises
i)
y ... Unemployment rate in %
x ... GDP per capita in thousand CZK
Interpretation: If the GDP per capita at current prices increases by 1 thousand CZK, then the
unemployment rate will decrease by 0.0085 %.
ii)
y ... CO in tons per year
x ... Total investment for environmental protection in milliard CZK
19
iii)
y ... The final expenditure on higher education in million CZK
x ... Number of students at universities in thousands
ryx = 0.961
Author:
Ing. Petra Bubáková, CULS, FEM, Department of Economics
Note:
This material has not undergone editorial or language editing. If you found some mistakes,
don’t hesitate to contact me by e-mail: bubakova@pef.czu.cz
20