Lecture 3

advertisement
SESSION 3 - SPREADSHEETS 1: BASIC SKILLS
LINEAR & NON-LINEAR FUNCTIONS, GRAPHS AND SIMULTANEOUS
EQUATIONS (EXCEL)
Before we start this week’s class, please look at the details of the Group
project
3.1 Introduction
Spreadsheets are a very powerful tool with a host of applications to
economics and they are very widely used in business. You may well already
be an experienced user of Excel. If you are not, then you should aim to be by
the end of this module. The way to achieve this is to practise a lot. You
should find that with a little thought you can create numerical examples of
your own which will help you understand more thoroughly the economics you
are learning.
This session covers basic skills in Excel and will include some examples of
how spreadsheets can be used to handle simple problems in economics.
By the end of this session you should be able to apply Excel to the analysis of
linear and non-linear functions and to see how these skills can be applied to
textbook models of demand and cost functions.
3.2 Linear functions
I will be assuming that you are already familiar with how to create a linear
function of the type y = ax + b in Excel.
I will concentrate on using linear functions to represent economic
relationships such as demand curves and consumption functions. When
using spreadsheets to explore demand models in particular it is important to
think in terms of what you want graphs to look like so that you make sure to
get the values for the horizontal axis in the correct position relative to the
vertical axis.
You have to think, for example, in terms of the price at which a level of
demand is forthcoming (p=p(x)) rather than the more conventional formulation
in which quantity demanded depends on price (x=x(p)).
Demo 3.1
A demand curve relates the quantity demanded x to its price p.
Assume that we want to draw a graph of the linear demand curve given as:
x = 50 - 5p
In order to plot a demand curve looking like a textbook demand curve we will
want price on the vertical axis and quantity on the horizontal axis. The first
step is to rewrite demand so that we have price (for the vertical, or y, axis) as
a function of quantity (for the horizontal, or x, axis). With minimal
rearrangement we can get:
p = 10 - (x/5)
We know that x = 50 when p is zero, so we can now set up a table from which
to generate the graph. In column A put values of x running from 0 to 50,
making sure to put appropriate labels at the top of columns A and B. In
column B put the formula for p. If x = 0 is in cell A4, then in cell B4 type the
formula =10-(A4/5). Copy the formula down the column. You should have
something that looks like this
In a similar manner we can construct a supply curve that relates the quantity
supplied (x) to its price (p). For example suppose the supply curve is given as:
x = 5p - 10
Applying the same framework used for the construction of the demand curve
you should generate a supply curve which looks something like this .
If we treat the demand and supply curves together then we have a set of
simultaneous equations and by putting the two schedules together we can
determine the equilibrium (market-clearing) price and quantity. You should
generate something like this
Demo 3.2
Drawing graphs of budget constraints (e.g. Worked Example 2.22 in Bradley
and Patton at www.wiley.co.uk/bradley2ed is another natural application of
linear functions in Excel.
A consumer has a budget of 100 to allocate between two goods. Drinks cost 2
and CD's cost 5. In textbook format the constraint could be written as: 100=2x
+ 5y where x represents the number of drinks and y refers to CD's.
A graph of this budget constraint uses the quantities of each of the goods as
the axes. We will put the number of drinks (x) on the horizontal axis and the
number of CD's (y) on the vertical axis. To plot a graph of this constraint we
need first to limit ourselves to the case where the budget is fully used, i.e. to
100 = 2x + 5y. Then we need to rearrange it so that the quantity of CD's is on
the left of the equation and everything else is on the right. This will give us an
expression of the form y = f(x), namely y = 20 - 2x/5. We now have the
information in a format that can be put straight into Excel. The values for x
(running from 0 to 50 since that's the range of drinks quantities to be
considered) go into column A. Column B documents corresponding values for
CD's by using the formula =20- (2*A4)/5, or whatever cell is appropriate for
the first value of x, copied down the column.
The result should look something like this
3.3 Non-linear functions
It is important also to become familiar with how to represent non-linear
functions in Excel. The basic technique is the use of the ^ operator to raise the
value in a cell to a power: For example =A3^3 evaluates the cube of the value
in cell A3. This technique applies not only to quadratic and cubic functions but
also, more generally, to polynomial functions. Examples include quadratic
cost functions in which cost depends both on output and the square of output.
Demo 3.3
For an example containing formulae for quadratic and cubic cost functions:
click here
TC = a + bx + cx2 or TC = a + bx + cx2 + dx3
Demo 3.4
In rather similar vein here is an example of production function in which the
level of output depends on the square root of the volume of labour inputs:
click here
X = aL1/2
Demo 3.5
In a more sophisticated variant a 'production function' relates the level of
output to the level of two inputs, usually capital and labour, as in this example
in which the level of output depends (in a non-linear way) on the volume of
labour and capital inputs: click here
Cobb-Douglas production function:
y  ALa K b
Another very important class of non-linear functions widely used in economics
is the logarithm. Here we will demonstrate how to take logs (using =Ln(..)) and
how to take anti-logs (using =exp(..)).
Demo 3.6
For an example of the calculation of the natural log and the log to base 10 of x
click here. Taking logarithms is a way of linearising a relationship, which is
important when we look at regression analysis later in the term. By plotting the
series with and without logarithms, you can appreciate how this is achieved.
An important application of logs in economics is to represent exponential
functions, particularly production functions and utility functions. For example,
the production function in demo 3.5 can be transformed into an equation that
is linear in logarithms, namely log (y) = log(A) + a*log (L) + b*log(K). This
makes it much easier to incorporate non-linear formulations in simple models.
3.4 Matrices
Excel can be used to invert matrices and find the determinant (of a square
matrix), as well as find solutions to systems of equations. i.e. To find the
determinant of a matrix you need to use the command: mdeterm. The easiest
way is to type the command in including the array or data cells where the
relevant values are for the matrix., i.e. = mdeterm: (A1:C3):
14
12
4
10
6
3
Answer
is -2
7
7
2
To invert a matrix requires the use of the Minverse command. An example of
both commands is here. This approach can also be used to solve
simultaneous equations, Given a system of equations such as:
3x+y =7
x-y+3z =10
y-2z =-5
We can express this system in matrix form as: Ax = b, where x is a 3 x 1
column vector whose elements are the variables x, y and z. b is a 3 x 1
column vector whose elements are the constants 7, 10 and -5. A is a 3 x 3
matrix whose elements are the coefficients of the x, y and z values in the
equations. We can find the solution of x = A-1b. We can use Excel to find the
inverse of A for us. This involves:
1) Type the coefficients into a 3 x 3 block of cells
i.e. A2 to C4
A
B
C
A matrix of coefficients
3
1
0
1
-1
3
D
E
b(vector of
constants)
7
10
F
0
1
Inverse of A
1
-2
-2
6
-1
3
-2
-5
-3
9
4
Solution
2 (=x)
1 (=y)
3 (=z)
2) Go to A7 and select a block A7 to C9 (as above). Then go to Function
Wizard (Insert – Function – Math & Trig) Then select Minverse. Put
A2: C4 into the place for the array. Then press F2 key and finally ctrl +
shift + -enter. The elements of the inverse matrix should appear as
above. (See sheet 2 in the earlier example)
3) To produce the values for x, y and z you need to multiply the vector of
constants by this inverse. Go to E7 and select E7:E9. Call up the
Function Wizard as above but choose Mmult. Enter cells A7:C9 for the
first array and E2:E4 for the second array. Then again press F2 key
and then ctrl + shift + enter.
3.5 Graphics
Economics makes a lot of use of graphics both for theoretical purposes and
also for exploring empirical data. This section explores the capacity of Excel
to graph linear and non-linear functions.
Demo 3.1 above created a simple worksheet containing data on price and
quantity demanded. To create an XY Scatterplot type of graph from that
worksheet, highlight the data in the table. Then select Insert Chart and go
through the various stages to assign labels and so on to get a line graph of B
against A. The result should look like the Charts page in each spreadsheet:
click here for the demand schedule, here for the supply schedule and here
for the combined plot)
For an illustration of a graph showing the budget constraint from demo 3.2,
click here and look at the Chart page.
For an illustration of a graph showing the quadratic and cubic functions from
demo 3.3, click here and look at the Charts.
For an illustration of a graph showing the values of the function from demo
3.4, click here and look at the Chart.
References
For an introduction to Excel see Judge ch. 2.2. For a simple application to
economics see chapter 3.3
In Bradley and Patton Essential Mathematics for Economics and Business
(the text used for the Maths unit taken by non-A-level Maths students) section
1.8 gives an introduction. Section 2.8 applies Excel to linear functions and
section 3.5 applies it to simultaneous equations.
Link to Class Exercise 3
Download