Presentation on theme: "Economics Masters Refresher Course in Mathematics"— Presentation transcript:
1Economics Masters Refresher Course in Mathematics Lecturer: Jonathan WadsworthTeaching Assistant: Tanya WilsonAim: to refresh your maths and statistical skills, to the level needed for success in the Royal Holloway economics masters.Why do we need maths/statistics?to improve your understanding of Economics.As such everything in the course tailored to try to bring out the relevance of the techniques you will (re)learn help the analysis of Economic issues
2Economics Masters Refresher Course in Mathematics How to do it?Lectures 10-1 and classes 2:30-3:30 each day.In the afternoons and evening you will be expected to:Read the textDo the daily problem set.Prepare to present your answers to the class the next day.
3Vectors and matricesLearning objectives. By the end of this lecture you should:Understand the concept of vectors and matricesUnderstand their relationship to economicsUnderstand vector products and the basics of matrix algebraIntroductionOften interested in analysing the economic relationship between several variablesUse of vectors and matrices can make the analysis of complex linear economic relationships simpler
4Lecture 1. Vectors and matrices 1. DefinitionsVectors are a list of numbers or variables – where the order ultimately mattersE.g. a list of prices, a list of marks in a course test.(Pricelabour , Pricecapital )(25, 45, 65, 85)Since this is just a list can store the same information in different waysCan enter the list either horizontally or vertically(25, 45, 65, 85) or
5DefinitionsDimensions of a vectorIf a set of n numbers is presented horizontally it is called a row vectorwith dimensions 1 x n(so the number of rows is always the 1st number in a dimension and the number of columns is always the 2nd number)Ega = (25, 45, 65, 85) is a 1 x 4 row vectorIf a set of n numbers is presented vertically it is called a column vectorwith dimensions n x 1(Note tend to use lower case letters (a b c etc) to name vectors )
6DefinitionsSpecial Types of vectorA null vector or zero vector is a vector consisting entirely of zerose.g. (0 0 0) is a 1 x 3 null row vectorA unit vector is a vector consisting entirely of ones denoted by the letter ie.g. is a 4 x 1 unit column vector
7More definitions and some rules Adding vectorsGeneral ruleIf a = (a1, a an) and b = (b1, b bn)then a+b = (a1+ b1, a2 + b2, an + bn)e.g. (0 2 3 ) + ( 1 0 4) = (0+1, 2+0, 3+4) = (1 2 7)(same rule for addition of column vectors )Note that the result is a vector with the same dimension 1 x nNote you can only add two vectors if they have the same dimensionse.g. you cannot add (0 2 3) and (0 1) (1 x 3 & 1 x 2)Note also that sometimes adding two vectors may be mathematically ok, but economic nonsenseEg simply adding factor prices together does not give total input price
8More definitions and some rules Multiplying vectors by a number (a ‘scalar’)Let x = (x1, …,xn) and a be a scalar, then ax = (ax1, ax2,…,axn)e.g. a = 2, x = ( )ax = (2 4 6)
9More on multiplication Multiplying vectorsIn general you cannot multiply two row vectors or two column vectors togetherEg a = (1 2) b = (2 3) ?But there are some special cases where you canAnd you can often multiply a column vector by a row vector and vice versa.We’ll meet them when we do matrices
103. Vector products – a special case of vector multiplication Definition: Vector product also known as the dot product or inner productLet x = (x1, x2, …, xn), y = (y1,…,yn).The vector product is written x.y and equals x1y1 + x2y2 + …xnyn.OrNote that vector products are only possible if the vectors have the same dimensions.
113. Vector products – a special case of vector multiplication Example. Miki buys two apples and three pears from the Spar shop.Apples cost £0.50 each; pears cost £0.40 each.How much does she spend in total?Answer: This can be seen as an example of a vector productWrite the prices as a vector: p=(0.5, 0.4)Write the quantities as a vector q=(2, 3)Total Expenditure (=Price*Quantity) is the sum of expenditures on each goodfound by multiplying the first element of the first vector by the first element of the second vector and multiplying the second element of the first vector by the second element of the second vector & adding the resultsSpending = 2x x0.4 = £2.20
12Instant QuizWhat are the dimensions of the following?2. Can you add the following (if you can, provide the answer)?3. Find the dot product
13GeometryIdea: vectors can also be thought of as co-ordinates in a graph.A n x 1 vector can be a point in n –dimensional spaceE.g. x = (5 3) – which might be a consumption vector C= (x1,x2)x253x1A straight line is drawn out from the origin with definite length and definite direction is called a radius vector
14GeometryUsing this idea can give a geometric interpretation of scalar multiplication of a vector, vector addition or a “linear combination of vectors”Eg If x = (5 3) then 2x = (10 6) and the resulting radius vector will overlap the original but will be twice as longx2653x110Similarly multiplication by a negative scalar will extend a radius vector in the opposite quadrant
15GeometryAlso can think of a vector addition as generating a new radius vector between the 2 original vectorsEg If u = (1 4) and v = (3 2) then u+v = (4, 6) and the resulting radius vector will look like thisx2u+v6u412vx143Note that this forms a parallelogram with the 2 vectors as two of its sides
16Linear combinations depicted Given this can depict any linear vector sum (or difference) now called a linear combination geometricallyE.g. x = (5 3); y = (2 2) 2x+3y = (16,12)16123x25y2
17Can also think of a geometric representation of vector inner (dot) product RememberA geometric representation of this is that the dot product measures how much the 2 vectors lie in the same directionSpecial CasesIf x.y=constant then the radius vectors overlapEg x=(1 1) y =(2 2)So x.y= (1*2 + 1*2) = 4
18Can also think of a geometric representation of vector inner (dot) product RememberA geometric representation of this is that the dot product measures how much the 2 vectors lie in the same directionSpecial CasesIf x.y= 0 then the radius vectors are perpendicular (orthogonal)Y=(0,4)Eg x=(5 0) y =(0 4)So x.y= (5*0 + 0*4) = 0x ┴ yX=(5 0)
19Will return to these issues when deal with the idea of linear programming (optimising subject to an inequality rather than an equality constraint)
20Linear dependenceA group of vectors are said to be linearly dependent if (and only if) one of them can be expressed as a linear combination of the otherIf not the vectors are said to be linearly independentEqually linear dependence means that there is a linear combination of them involving non-zero scalars that produces a null vectorE.g. are linearly dependentProof. Because x=2y or x – 2y = 0But are linearly independentProof. Suppose x – ay = 0 for some a or other. In other words,Then 2 – a = 0 and also 1 – 3a = 0. So a = 2 and a = 1/3 – a contradiction
21Linear dependenceGeneralising, a group of m vectors are said to be linearly dependent if there is a linear combination of (m-1) of the vectors that yields the mth vectorFormally, the second definition:Let x1 , x2 , …xm be a set of m nx1 vectorsIf for some scalars a1, a2, …am-1a1x1 + a2x2 + … am-1 xm-1 = xmthen the group of vectors are linearly dependent,But alsoa1x1 + a2x2 + … am-1 xm-1 – xm = which is the first definitionSummary. To prove linear dependence find a linear combination that produces the null vector. If you try to find such a linear combination but instead find a contradiction then the vectors are linearly independent
22Quiz IIA group of vectors are said to be linearly independent if there is no linear combination of them that produces the null vectorare linearly independent. Prove it.3. What about ?
23Quiz answersA group of vectors are said to be linearly independent if there is no linear combination of them that produces the null vectorare linearly independent.Suppose not, so that2a + 0 = 0 and a+1 = 0 for some a, then a = 0 and a = -1 – a contradiction.Suppose not then 2a+0 = 0 and 2a+3 = 0 for some a, but then a = 0 and a = -1.5 – a contradiction3.No… x = y + 2z so x – y – 2z = 0
24RankThe rank of a group of vectors is the maximum number of them that are linearly independentare linearly independent. So the rank of this group of vectors is 2are linearly dependent, (2x=y) So the rank is 1Any two vectors in this group are independent (x=y+2z) so the rank is 2
25Vectors: Summary Definitions you should now learn: Vector, matrix, null vector, scalar, vector product, linear combination, linear dependence, linear independence, rank4 skills you should be able to do:Add two nx1 or 1xn vectorsMultiply a vector by a scalar and do the inner (dot) productDepict 2 dimensional vectors and their addition in a diagramFind if a group of vectors are linearly dependent or not.
26Matrices Introduction Recall that matrices are tables where the order of columns and rows mattersE.g. marks in a course test for each question and each studentAndyAhmadAnkaQn. 1447465Qn. 2235648Qn. 3824
27Some common types of matrices in applied economics. Storing dataInput-output TablesTransition matrices.(U = unemployed, E = employed, prob. = probability)US GDPUK GDPPRC GDP199910080112000103821220018413Per kg ironPer kg coalKg iron0.10.01Kg coal1Hours labour0.001Prob. U in 2011Prob E in 2011U in 20100.30.7E in 20100.10.9
28Can also derive matrices from economic theory Eg consider a simple demand and supply system for a good Supply: Q= P Demand: Q=10-2P Re-arranging Supply: Q – 3P = - 2 Demand: Q +2P = 10 Or in short-hand Ax = b where
29In general any system of m equations with n variables (x1, x2, In general any system of m equations with n variables (x1, x2, ...xn) Can be written in matrix form Ax = b where
30DefinitionsDimensions of a matrixare always defined by the number of rows followed by the number of columnsSois a matrix with m rows and n columns.ExampleSo A is a 2 x 5 matrix (2 rows , 5 columns)B is 5x2 matrix
31DefinitionsCan think of vectors as special cases of matricesHence a row vector is a 1 x n matrixB is a 1 by 3 row vectorSimilarly a column vector is an n x 1 matrixSo C is a 3 x 1 column vector( note the content is the same as B. This means that you can store the same information in different ways)
32DefinitionsSometimes we wish to refer to individual elements in a matrixE.g. the number in the third row, second column.We use the notation aij (or bij etc.) to indicate the appropriate elementi refers to the rowj refers to the columnExampleSo a13 = 3 and a21 = 7IfWhat is b21 ?
33DefinitionsThe null matrix or zero matrix is a matrix consisting entirely of zerosA square matrix is one where the number of rows equals the number of columns i.e. nxnEg.For a square matrix, the main (or leading) diagonal is all the elements aijwhere i = jSo in the above the main diagonal is (2 1)
34DefinitionsThe identity matrix is a square matrix consisting of zeros except for the leading diagonal which consists of 1s:We write I for the identity matrixIf we wish to identify its size (number of rows or columns) we write In
35DefinitionsA diagonal matrix is a square matrix with aik = 0 whenever i ≠ kAnd so consists of zeros everywhere except for the main diagonal which consists of non-zero numbers(so the identity matrix is a special case of a diagonal matrix since it has just ones along the main diagonal)
36Trace of a matrixis the sum of the elements on the main (leading) diagonal of any square matrix So tr(A) = = -4
37Mini quizWhat are the dimensions of A?What is a21?Is B a square matrix?What is the largest element on the main diagonal of B?What is the value of the largest element on the main diagonal of B?
38More DefinitionsThe transpose of a matrix A is obtained by by turning rows into columns and vice versaswapping aij for aji for all i and jWe write the transpose as A’ or AT ( A “prime”)A symmetric matrix is one where A’ = AA positive matrix is one where all of the elements are strictly positiveA non-negative matrix is one where all of the elements are either positive or zero
39Useful Properties of Transposes (A’)’ = AThe transpose of a transpose is the original matrix2. (A + B)’ = A’ + B’The transpose of a sum is the sum of the transposes3. (AB)’ = B’A’The transpose of a product is the product of the transposes in reverse orderEg. GivenFind (AB)’ and B’A’
40More DefinitionsA negative matrix is one where none of the elements are positiveA strictly negative matrix is one where all of the elements are strictly negativeC is strictly positive and symmetric; B is negative; A is neither positive nor negative.
41Some rulesAdding matricesadd each element from the corresponding place in the matrices.i.e. if A and B are m x n matrices, then A+B is the m x n matrix wherecij= aij+bij for i = 1,..,m and j = 1,…,n.You can only add two matrices if they have the same dimensions.e.g. you cannot add A and B
42Matrix Multiplication Multiplying by a scalarWhen you multiply by a scalar (e.g. 3, 23.1 or -2), then you multiply each element of the matrix by that scalarExample 1: what is 4A ifExample 2: what is xB if
43Matrix Multiplication In general multiplication of 2 or more matrices has some special rulesThe first rule is that the order of multiplication matters.In general AxB (or AB) is not the same as BA(so this is very different to multiplying numbers where the order doesn’t matter – e.g. 3x4 = 4x3 = 12 )Asides:Addition, multiplication, matrix multiplication etc. are examples of operatorsAn operator is said to be commutative if x operator y = y operator xfor any x and y (the order of multiplication does not matter)Addition is commutative: x+y = y+x; multiplication is commutative; subtraction is not commutative (2-1 ≠ 1-2)Matrix multiplication is commutative but matrix multiplication is not
44Multiplying two matrices 2. The second rule is that you can only multiply two matrices if they are conformableTwo matrices are conformable if the number of columns for the first matrix is the same as the number of rows for the second matrixIf the matrices are not conformable they cannot be multiplied.Example 1: does AB exist?Answer: A is a 2x4 matrix. B is a 3x3.So A has 4 columns and B has 3 rows.Therefore AB does not exist. A and B are not conformable.
45Multiplying two matrices Example 2: does AB exist?Answer: A is a 2x5 matrix. B is a 5x2. So A has 5 columns and B has 5 rows. A and B are conformable.Therefore AB exists.How to find it?
46Multiplying two matrices Finding ABA and B are conformable. So C = AB exists and will be a 2 x 2 matrix(no. of rows of A by no. Columns of B)To calculate it:To get the first element on the first row of C take the first row of A and multiply each element in turn against its corresponding element in the first column of B. Add the result.Example: c11 = (4x4) + (-1x-1) + (3x3) + (3x3) + (0x1) = 35To get the remaining elements in the first row: repeat this procedure with the first row of A multiplying each column of B in turn.
47Multiplying two matrices So top left hand element isAnd top right hand element is
48Multiplying two matrices ......and so on to give
49Multiplying two matrices - formally Suppose A is an mxn matrix and and B is an nxr matrix with typical elements aik and bkj respectivelythen AB =C where element cij is :Note that the result is an mxr matrix
50Another exampleExample 2: calculate ABFirst we note that A is 1x4 and B is 4x2so C=AB exists and is a 1x2 matrixThe first element c11 = (1)(1)+(0)(2)+(2)(1)+(0)(0)= 3The second element c12 = (1)(0)+(0)(0)+(2)(3)+(0)(1)= 6So C = (3 6)
51Quiz.Can you multiply the following matrices? If so, what is the dimension of the result?BABCAA’A’ACC
53Multiplying square matrices by the identity matrix Recall:A square matrix has the same number of rows and columns – it’s nxnThe identity matrix is a square matrix with 1s in the leading diagonal and 0s everywhere else.E.g.
54The usefulness of the identity matrix is similar to that of the number 1 in number algebra Since IA = AI = A- if multiply a matrix by the identity matrix the product is the original matrixEg(leave it to you to show AI=A)
55A general result for square matrices If A is a square matrix then IA = AI = ANB. This only applies to square matrices
56This result can be useful sometimes to help solve matrix algebra Since if AI = AThenAIB = (AI) B = A (BI) = ABThe inclusion of the identity matrix does not affect the matrix product result (since like multiplying by “1”(will see example of this in econometrics EC5040)Also note thatAn identity matrix squared is equal itselfAny matrix with this property AA = AIs said to be idempotent
57Inverses for (square) matrices Idea:In standard multiplication every number has an inverse(except maybe zero unless you count infinity)The inverse of 3 is 1/3; the inverse of 27 is 1/27, the inverse of -1.1 = -1/1.1Also a number times its inverse equals 1: x(1/x) = 1and the inverse times the number equals 1: (1/x)x = 1and the inverse of the inverse is the original number 1/(1/x) = x
58Inverses for (square) matrices The rules for the inverse of a matrix are similar (but not identical)If A is an nxn matrix then the inverse of A, written A-1 , is an nxn matrix such that:AA-1 = IA-1A = INotes:This means that A is the inverse of A-1But...A-1 may not always exist
59An Inverse matrix example Suppose andThenSo given AA-1=I it must be that in this case B=A-1
60In general need to introduce some more terminology before can invert a matrix Only square matrices can be inverted.Not all square matrices can be inverted howeverA matrix that can be inverted is said to be nonsingular(so squareness is a necessary but not sufficient condition to invert)3. The sufficient condition is that the columns (or rows since it is square) be linearly dependent- think of this as being separate equations so the equations must be independent (n equations and n unknowns) if a solution is to be found
61Eg So that the 1st row of A is twice that of the 2nd row and there is linear dependence One equation is redundant (no extra information) and the system reduces to a single equation with 2 unknowns So no unique solution for x1 and x2 exists
62Rank of a matrixThe idea of vector rank can be easily extended to a matrix The rank of a matrix is the maximum number of linearly independent rows or columns If the matrix is square the maximum number of independent rows must be the same as the maximum number of independent columns If the matrix is not square then the rank is equal to the smaller of the maximum number of rows or columns, ρ<=min(rows, cols) If a matrix of order n is also of rank n, the matrix is said to be of full rank Important: Only full rank matrices can be inverted Matrix ranks are closely linked to the concept of determinants
63DeterminantsLet A be an nxn matrix then the determinant of A is a unique number (scalar), defined as:(1)Notes: In each term there are three components:(-1)1+ja1jDet(A1j)What does this mean?Start with a 2 x 2 matrixwhich gives a single number (scalar) as the answer – as do all determinantsCan you see how this relates to equation (1) ?
64DeterminantsEgWhat is the determinant ofSo matrices that are not full rank – have linear dependent rows/columns - have zero determinants (will come back to this) and are singular
65Determinants.The determinant of a matrix is defined iterativelyAn nxn is calculated as the sum of terms involving the determinants of nx(n-1)x(n-1) (ie n!) matricesEach (n-1)x(n-1) matrix determinant is the sum of terms involving n-1 determinants of (n-2)x(n-2) matrices and so onSince we know how to calculate the determinant of a 2x2 matrix we can always use this definition to find the determinant of an nxn matrixIn practice we shall not go above 3x3 matrices (unless using a computer program) but we need to know the general formula for an inverse
66General properties of determinants If B = A’, then det. B = det. AIf B is constructed from A by swapping two rows, then det. B = -det. AIf B is constructed from A by swapping two columns, then det. B = -det. AIf B is constructed from A by multiplying one row (or column) by a constant, c, then det. B = c det. AIf B is constructed from A by adding a multiple of one row to another, then det. B = det. B
67Determinants of triangular matrices Are examples of – respectively – an upper triangular and a lower triangular matrix(zeros below or above the main diagonal)The determinant of either an upper or lower triangular matrix is equal tothe product of the elements on the main diagonalEg det.A = 1(24-0) - 2(0) + 3(0) = 24 = 1*4*6
68DeterminantsFor a 3 x 3 matrix, usingQuestion: What is the determinant of
69Method 1: Laplace expansion of an n x n matrix. Can generalise this rule for the determinant of any n by n matrixAs part of this method, you need to know the following:Minor MCo-factor C(which are also essential to invert a matrix)
70nxn Matrix inversion - minors There is a minor Mij for each element aij in the square matrix.To find it construct a new matrix by deleting the row i and deleting the column j.Then find the determinant of what’s leftE.g. M11Example M12123A=456789123Delete row and column456789
71N xn matrix inversion: Co-factor and adjoint matrices The cofactor is Cij is a minor with a pre-assigned algebraic sign given to itFor each element aij, work out the minorThen multiply it by (-1)i+jIn simpler language: if i+j is even then Cij = MijIf i+j is odd, then Cij = -MijThe co-factor matrix is justThe adjoint matrix is C’ – i.e. the transpose of C.
72Co-factor, adjoint matrices and the inverse matrix The inverse matrix, A-1 is justSoi) find the determinant– if it is non-zero, the matrix is non-singular so its inverse existsii) Find the cofactors of all the elements of A and arrange them in the cofactor matrixiii) Transpose this matrix to get the adjoint matrixiv) Divide the adjoint matrix by the determinant to get the inverse
73Example 1 (2 x 2 matrix)If find A-1Use the formulaFirst find the determinantwhich is non-zero so can continueNow find matrix of cofactors, which in the 2 x 2 case is a set of 1 X 1 determinants
74Example 1 (2 x 2 matrix)Now transpose the matrix of cofactors to get the adjoint matrixNow using the formula abovewhich is non-zero so can continuethenNB. Always check that the answer is right by looking if AA-1 = I
79Some more jargonThe term is called the determinant of A, often written det.(A). Vertical lines surrounding the original matrix entries also means ‘determinant of A’.The matrix part of the solution is called the ‘adjoint of A’ written adj. A. The elements of the adj.A are called co-factors. So,
802x2 Matrix Inversion Quiz SupposeWhat is det. A?What is A-1What is det. B?Can you find B-1
81Summary 11 Definitions you should now memorise: Matrix dimensions, null matrix, identity matrix, transpose, symmetric matrix, square matrix, leading diagonal, nonnegative, positive, nonpositive, and negative matrices.5 skills you should be able to do:Add two nxm matricesMultiply a matrix by a scalarTranspose a matrix.Identify the element aij in any matrixUnderstand and have practised matrix multiplication
82For home study: Method - the Gaussian approach. In a row operation multiples of one row are added or subtracted from multiples of another row to produce a new matrix.Example: transform A by replacing row 1 by the sum of row 1 and row 2:A row operation can be represented by matrix multiplication. A’ = BA where
83Method 2: the Gaussian method. Suppose, by a series of m row operations we transform A into I, the identity matrix.Let Bi indicate the series of matrices in this sequence of m row operations:BmBm-1…B1A = I.Let C = BmBm-1…B1 so that CA = I.It follows that, by the definition of the inverse that C = A-1.Since C = CI we can find C by taking the row operations conducted on A and conducting them in parallel on I.Method. Begin with the extended matrix [A I]:Carry out row operations on the extended matrix until it has the form [I C]C = A-1
84QuizUse the Gaussian method to find the inverse and check it works.
855. An odd example.In Cafeland there are only two goods: x1 = latte, x2 = muffin.Peculiarly, it is not possible to buy and sell the goods separately.Instead the following combinations are availablex: Latte lover : x1 = 2, x2 = 1.y: Muffintopia: x1 = 0, x2 = 3.Any fraction of these combinations can be bought and soldJoan wishes to own and consume exactly one latte and one muffin. Can she buy to achieve her goal?Answer:She buys 1/2 of latte lover combo and 1/6 of muffintopia combo.This mix of vectors is called a linear combination.More formally, if x and y are n x 1 vectors and a and b are scalars,ax + by is a linear combination.Joan’s purchase is (1/2)x + (1/6)y
86The example againIn Cafeland there are only two goods: x1 = latte, x2 = muffin.Peculiarly, it is not possible to buy and sell the goods separately.Instead the following combinations are availablex: Latte lover : x1 = 2, x2 = 1.y: Muffintopia: x1 = 0, x2 = 3.Any fraction of these combinations can be bought and soldCan Joan construct any combination of latte and muffin out of x and y?Any combination: So formally, is there an a and a b such that:Or
87The example again I.e. two equations in two unknowns: x1 = 2a and x2 = a+3bOr0.5x1 = aand sox2 = a + 3b = 0.5x1 + 3b orx2 –0.5x1= 3b orb = (x2 -0.5x1)/3For instance if x1 = 1 and x2 = 1, then a = 0.5 and b = 1/6
8810. Vector SpaceThe set of vectors generated by the various linear combinations of 2 vectors is called a 2-dimensional vector spaceConsider a space with n dimensionsIt follows that a single nx1 vector is a point in that spaceA group of nx1 vectors is said to form a basis for the space if any point in that space can be represented as a linear combination of the vectors in the group.In the example, formed a basis for 2 dimensional space.These vectors are also said to span 2 dimensional spaceIn other words if a group of vectors form a basis for an n-dimensional space that’s the same as saying that they span the n-dimensional space.