|
Introduction
The usefulness of graphs in the development of theoretical models and the display of empirical data is well established. The advent of modern spreadsheets like Microsoft Excel has greatly facilitated the use of such graphs. To take full advantage of spreadsheets’ potential requires going beyond what is provided “off the shelf.” The material below shows ways to use Microsoft Excel to develop and work with economic models. The focus is on theoretical models, but many of the techniques could be applied to displaying and analyzing empirical data.
Analytical graphs
used in economic analysis usually fall into one of the categories
below.
Almost all of the graphs that follow are X/Y plots, but the other types
of plots are useful on occasion. (Excel refers to "charts." We use
"graph," "chart," and "plot" as interchangeable.
|
||||
|
Developing
the data
|
||||
For
most purposes, the solid
line graph (the one selected at the right)
gives the best results. Data points can be indicated if desired.
Changing the way graphs are represented is discussed below. Selecting
"smoothed lines" rather than "lines" can improve appearance
for nonlinear functions, but can also result in peculiar behavior for
some
lines. This dialog box and a few other displays below are cropped to
save space.A
simple graph. The figure immediately below
shows the graph that follows from simply
clicking on the selection at the right. Beside the graph are the data
that generate it. These data come from the following equations
We repeat: Graphing is much
simpler when the inverse demand and supply curves are used.
![]() This graph's appearance can be improved. Consider each of the following concerns:
The
first four of
these points involves changing the graph. The fifth
involves changing the data range and will be addressed separately.
Using
Chart Options.
To access "Chart Options," either right-click on
the chart or select "Chart/Chart Options" from the menu. (To activate
the Chart menu, click anywhere on the chart.)Click on the Titles tab. In the Chart title window, type "$ per unit" and in the Value (X) axis window, type "Quantity." (We appropriate the title for use as the Y axis label because on occasion the dedicated "Value (Y) axis" label can truncate the label.) Also, we prefer the horizontal display that this use of the chart title provides. Click on the Gridlines tab and remove the check that results in the horizontal gridlines. The resulting graph is at the right. Some more adjustments are indicated. The remaining changes are made directly in the graph by liberally using the right-click key.
The resulting
graph is below. The graph now has less clutter, allowing the
demand
and supply curves to appear more distinctly.
A bit of lost space at the right could have been regained by setting the X data range from 0 to 60 (or 50). Setting data ranges will be discussed below. Also,
the equilibrium
could have been moved closer to
the center.
In this example, we selected the data range or quantity and then
posited functions
for demand and supply that would result in equilibrium over that range.Below, we show how to make the data range depend on the equilibrium value and indicate some advantages of that approach. Before moving to more substantive material, consider a bit more formatting. The graph in Figure 7 contains the same content as the one in Figure 4, but is more readable and a bit more informative. The changes are achieved as follows:
.
|
||||
|
|
||||
|
Critical
Values and Data Range Selection
The example above depicts a
demand and supply curve. It does not
directly address equilibrium, disequilibrium, or the effects of change.
All of these require attention to specific values of the variables in
question. The section addresses three sets of issues related to these
concerns: how to depict critical values, how to allow change to occur,
and how to adjust the data set to accommodate the preceding two
concerns.
We begin by representing the equilibrium value for quantity and price. The added variable "For showing P & Q" consists of a series of "=if" statements like this one: =IF(B5<=D$19,D$20,-99999). The first entry is in Cell D5 and equals the equilibrium price if Q is less than or equal to the equilibrium quantity. Otherwise, a large negative number is returned. Note that the reference to quantity (B5) is relative--that is, the next cell down refers to C5. In contrast, the references to D19 and D20 (equilibrium values of Q and P) are absolute. (Actually, mixed, since the row reference is fixed, but the column reference is relative.) ![]() |
||||
One
change must be made for
these data to be graphed. The Y-axis must not be allowed to display
large negative values. The Format Axis menu selection allows scale to
be
set. The dialog box is at the right. "Auto" is turned off for the
minimum value, and a value of zero is inserted.The X axis is formatted in an
identical fashion.
Briefly consider how the other
tabs in the Format Axis dialog box might be used:
This selection of range option
can be useful for other purposes, in
particular to focus on a range of values that are of particular
interest.
|
||||
|
Curve
Shifters, Critical Values, and the Data Range
The figure below replicates
the one above with one exception. The user is now given a way to shift
the demand curve. As with the case above, the dotted line intended to
show the equilibrium P, Q pair does not work quite right.
![]() Consider the failure of the reference line to "drop" at the equilibrium quantity. The reason for this failure is clear. The equilibrium value is between 35 and 40. Q = 35, is the largest value for which the "if" statement is true, so the reference line drops at Q = 35 rather than at the equilibrium Q (37.14286), a value that is not in the data table.. Before repairing this problem, consider a couple of other changes in the sheet. First, the user may now specify the P-intercept for the demand curve. Adding this change requires changing the way variables are created. The inverse demand curve is now defined as Q = =$D$22-5*B5, where $D$22 is the cell containing the P-intercept, and B5 is the quantity for this row. Also, the cells containing the equilibrium quantity and the equilibrium price are adapted to allow for P-intercept to change. Data range selection. The
difficulty involved in displaying the equilibrium value is easily
repaired. Set one of the
values in the Demand Price column equal to the equilibrium price and
then create other values in relationship to these values. The table at
the right
shows the formulas that are used to create the relevant data set.The cell with "=D18" contains two "flags." The one in the left corner warns this cell's formula is unlike those adjacent to it. The one in the right corner indicates the presence of a comment. See Comments We now
extend the analysis in three directions, to:
Making room for the additional
information can cause the screen display
to become quite cluttered. According, we move the data to be graphed
off the screen, placing it in Columns AA and following. Doing so can
require some lost time in moving between the graph and the data. To
facilitate this movement back and forth, we add one more topic:
|
||||
|
User
Selection of Values.
Users may be allowed to select values in any of a number of ways. We
describe these three:
The easiest option, of course,
is simply to let the user insert a value
into a designated cell (P-intercept on the demand curve, for example).
This could have the drawback of having values entered that result in
nonsensical solutions (for example, P-intercept on the demand curve
below that of the supply curve, resulting in an "equilibrium" of a
negative quantity). We do not use this option. Rather, we use a scroll
bar to designate values over which the demand intercept can range, and
a valid list for choices of prices that users may specify.
Clicking
on
the forms menu
allows selection of a scroll bar. Once the bar is placed on the screen,
it can be reoriented and re-sized. Right-click on the bar, and then
click on a handle to re-size or reorient it. Then it can be assigned to
a cell and
it defines the range of values that the user can place into the cell. In this case, the minimum value for the P-intercept is 100 (higher than the Supply P-intercept of 20), and the maximum value is 400. Clicking on the scroll bar changes the P-intercept in increments of $50. The format control on the right accomplishes this result. In
some cases, the values that users may select need to be less than 1.
Suppose that Cell D4 contains an elasticity (stated as a positive
number). To allow elasticity values between, say 0.1 and 2.5, specify
some other cell (say Cell Z1) as the "Cell link" and then put a
formula in cell D4. In the present hypothetical case, format Cell Z1 as
follows: Minimum value = 10, Maximum value = 250, Incremental change =
10. Then place "= Z1/100" in Cell D4. If you prefer to state elasticity
as a negative number, then "= -Z10" becomes the formula in Cell D4.Sometimes, the better way to provide the user a set of values from which to choose is to create a list of valid values and make that list available. The list may be part of the data table, or it may be specially created for the task at hand. In this case we created a table. If a cell refers to a list of valid data, users may not insert values, but must select one from the list. To create such a list, click on the cell and select menu option "Data/Validation." The
figure at the right
shows the dialog box
for a list of valid data, which appear in Cells AC20:AC30. This list is
created as follows: AC20 contains the minimum valid price (where QS
= 0), AC30 contains the maximum valid price (where QD
= 0), and the remaining cells contain values in equal increments
between the two. Clicking on the "Input Message" tab allows adding a
title for the list of legal values and for providing a brief
description of that list.
|
||||
The
cell in which
this list appears now contains the value $160.00. A
comment has been entered in order to call attention
to the cell. Clicking on the cell causes a list of values to drop down.
It also causes a title (Price) and a message (Click on the down arrow
and select a price from this list. The note under "Price" appears next
to the cell with $160.00 in it; we moved the note to the position shown
in order to keep all information visible.) This figure shows the graph and
related material that results from a
choice of P-intercept and price level. One
aspect of this figure warrants attention. Three values are now
indicated
by reference lines: the equilibrium quantity (and price), and the
quantities demanded and supplied at the user-specified price.
To
ensure
that the reference lines work properly, the Quantity data are
reconfigured slightly. See the table at the right. The first flagged
entry (Q = 28 in this case) is
the minimum of the range D9:D11 (Equilibrium Q, QDS
at selected P, and QS at selected P). The
entry in the flagged cell contains "=min(d9:d11)." The second of the
three flagged cells (Q = 40 here) contains =median(d9:d11" and the
third flagged cell contains "=max(d9:d11." Other cells are filled in
with formulas like this one for the cell immediately after the median
value: "=AA15+(AA$18-AA$15)/3." Dealing with more than three critical
values would require logical (=if) statements.The
table at the right contains part of the data used to draw the graph.
Including all of the
data (specifically that required to draw the reference lines, in this
example) would make the screen unduly cluttered. In many cases, moving
the data entirely off screen improves the presentation. We typically
move data to columns AA and following. Doing so creates a problem,
however, in that one often wishes to quickly compare graph and table.
This can be facilitated for the creation of ways to allow rapid
movement among points on the sheet (or among sheets).
Navigation can be facilitated by the use of either macros or links. Links have a couple of advantages over macros. First, they are simpler to implement. In addition, one can place a comment in a cell in which the link is embedded, thus providing the user with an indication of what to do and what will result from clicking on the link. Creating
a navigational link is
described here. An alternative approach is to use buttons and to assign
navigational macros to the buttons. See Macros
In
Cell Z4, just to the left of the data, we insert a link to Cell A1.
Its display says "View Graph." The dialog box is at the right. To
invoke the dialog box, click on the cell and select Hyperlink. A similar
link is placed
in Cells B12:C12 (which have been merged). This link takes the user to
the table of data. Another link returns to the menu sheet. See Links
|
||||
|
The figure above shows how a user
can be allowed to select the height of the inverse
demand curve. It shows the demand curve for the selected P-intercept.
It does not, however, allow comparison of two demand curves. Below, we
show how a user can shift a demand curve
via a change in a variable affecting demand and how the new demand
curve compares to the initial one.
The
figure at the right applies the
techniques developed above to show how to allow a
shifting demand curve. One issue remains before we consider other types of graphs. In this example, using linear demand and supply curves makes finding the equilibrium values of Q and P easy. Once those values are in hand, setting up the data range is straightforward. Suppose, however, that the demand curve is nonlinear (e. g., constant elasticity demand curve). In that case, finding the equilibrium values via analytical techniques is not easy and might not be possible. Fortunately, Excel's Solver tool allows a numerical approach to finding a very close approximation to the equilibrium values. The figure just below shows a graph in which Solver has been used to analyze a market in which the demand curve is of the constant elasticity sort. See Solver The
figure at the right shows a constant elasticity demand curve coupled
with a linear supply curve. Obtaining the equilibrium values becomes
problematic because setting the equation for the inverse demand curve
equal to that for the inverse supply curve does not result in an
generally-solvable equation. We invoke Solver at this point, having
Solver find the quantity at which the absolute difference between the
demand price and the supply price is minimized. The figure at the right
shows the results. An excerpt from the Solver dialog box appear below.
Note that in this case no constraint is imposed (other than an implicit
restriction that the value in Cell $D$12 be non-negative).
The
graph at the right
shows two demand
curves. Users may have changed PY and/or income. The parameters are set
in the preceding sheet
and are copied to this one. See Copying
& Moving SheetsSolver must be run twice (once in each of the two sheets) to show the two equilibria. |
||||
|
Line and Area Graphs The
scatter plot graph offers
great flexibility and can be used to
illustrate many, perhaps most, of the principles of economics. In some
cases, however,
the scatter plot will not do. It cannot directly show area, though
areas can be described by reference to the graph, and it cannot be
extended to three dimensions. This section develops line and area
graphs. The following section extends the analysis to three dimensions.
The figure here shows a graph of the effect of an excise tax. Relevant
areas
show up distinctly in that graph.
At
first pass, this graph looks
much like the one in the worksheet
"CleanedUp" except for the areas. Adding area charts requires a
complete revision of the chart types, however.. Before considering
that, however,
note that the graph contains two types of graphs. The first four are
Area
charts, and the last three are Line charts (which look like the graphs
drawn earlier). For now, focus on the area charts. With the area charts
appearing as they do, we can easily see the following:
It is not necessary to have
"Supply Area" and "Supply" separately, as
is done above (likewise, for "Demand"). Not doing so, however, can add
strange looking lines to the graph. If "Supply Area" had a border made
up of the dark dashed line segments that denote Supply, then this
border would appear at the right-hand side of the graph.
Achieving
the areas, as noted
above, requires substantial revision of
the sheet. First, the new variables were added. Once they were added,
the "Chart Type" menu was opened and the graph type indicated in Figure
22 was selected. This selection cause a problem, however, because Area chart and X/Y (Scatter) charts cannot be combined. They handle the X axis differently. The X/Y chart treats the X values as numbers, while the Area and Line charts take the X values to be integers (1, 2, 3, ...). Figure 23 shows this is done. In the present example, the values that appear on the X axis are in cells B5:B17. The values in these cells must be of equal interval length, unlike the values in X/Y (Scatter) charts. Line charts treat the
variables the same way. Accordingly, all
variables that had been graphed as X/Y charts in previous graphs are
now
converted to line
charts.
Having the X-axis values appear at equal intervals causes a problem regarding data entry. If a single critical value is to determine the data range, then the data must be entered so that the intervals are a constant fraction of that critical value. If two critical values are used to determine the data, then the intervals between all data points must be a constant fraction of the difference between the two data points. In general, more than two critical values cannot be accommodated (unlike X/Y plots, which can accommodate any number of such values). In the current example, we avoided this issue altogether. Rather than dealing with critical values, we specified the values of the tax in increments of $35, so that the change in Q is always 5 units. (The slope of the excess demand curve is -7 and the data are entered in increments of 5; hence, the $35 increment.) In the next section, which examines three-dimensional graphs, we use the critical values of X and Y as the points around which to build the data. |
||||
Three
Dimensions
Dealing with three-dimensional
graphs is much like dealing with
area or line graphs. The material below illustrates the use of 3-D
graphs by showing how to set up a data set
and graph a "utility hill."
As
with other chart types,
begin
with the "Chart Type" dialog box. Select as indicated at the right. The
usual options regarding legends and axis labels are available. In the present case, we wish to maximize utility subject to a budget constraint. A familiar Cobb-Douglas utility function is used for the illustration. The figures below contains the requisite information. We set PY ≡ 1, so that Spending = PX*X + Y. The Solver dialog box, which indicates that the problem is to select X and Y values that maximize utility subject to Spending = Income.
![]() |
||||
| A final point
relative to developing 3-D graphs involves the formulas. Figure 28
shows the first 3 values of X and Y. As stated above X & Y are
created by
beginning at zero and adding 1/10 of the critical values. Note the use
of relative and absolute cell references. In the formulas for utility, all references to the function parameter α (Cell C10) are absolute. Regarding X, the row is absolute (always row 3), and the column is relative. With Y, these reverse: column references are absolute (all Y values are in Column E) and X references are relative. ![]() |
||||
|
Buttons An alternative to using links is to create macros and assign buttons to execute them. To
insert a button, click on the button icon and then click on a location
for the button. The button can be re-sized, text can be added and
edited, and the button can be assigned to the macro. Copying and Moving Sheets To
copy or move a sheet,
right-click on the tab at the bottom of the sheet. Then move the cursor
to the name of the sheet which the copied or moved sheet is to precede.
To move the sheet, click "OK"; to copy the sheet, click "Create a copy" and then "OK." Cell Protection Excel can protect specified cells from accidental changes. Having critical cells protected is a good way to prevent having to reconstruct models. The following way of selecting a subset of cells to protect while allow change in other cells (e. g., to allow curve shifting) is the following. It appears, along with others, at the following site: http://reviews.cnet.com/5208-6130-0.html?forum ID=7&thread ID=28596&message ID=323651. By default, all Excel worksheet cells have locked definitions associated to them. This function will take effect only if the worksheet has been protected, and it covers all cells in the protected worksheet or workbook. If you want to protect only specific cells, such as those with formulas, you would first need to unlock all the cells on the worksheet, lock the cells that you want to protect, and protect the worksheet. Steps:
![]()
Data Validation One way to constrain the input that a user can provide to the spreadsheet is to create a list of valid data. These data should be chosen in a way that best serves the purpose of the workbook being used and which will not lead to analytically meaningless values (e. g. negative quantities). For an example of data validation see the text on this subject. Links Links within the workbook can facilitate movement, allowing quick comparison of information in graphs with that in tables, or information in various sheets. Links may be established in either of two ways:
Any series of steps that are to be repeated may be recorded as a macro. The macro can be associated with a "button." Buttons can be added to the workbook by opening the "Forms" menu under "View/Toolbars." Once created a button can be re-sized and moved. The name of the button can be changed by right-clicking on the button and selecting "Edit Text." A macro may be assigned to (activated by) a button; right-click on the button, select "Assign Macro," and select the appropriate macro from the list of recorded macros.
Return to text Number format For most purposes using one of the first three options works well for displaying economic data. We often select "Number" and specify 3 decimal places for quantities and "Currency" with either 0 or 2 decimal places for prices and costs. In
one important case, however, selecting "Custom" can be of value.
This is when an equation results in negative numbers, but negative
numbers make no economic sense. For display purposes, it is easy to
make negative numbers disappear. In the case above, positive numbers
appear in the form $1.23 (zero as $0.00) and negative numbers do not
appear. Adding a second semicolon (as in the entry above the
highlighted one) would cause zero values to disappear.The negative numbers are still visible to Excel, however, and will appear in graphs unless the data range for the relevant axis has been defined so as to exclude them. For more details enter "custom number format" in the "Type a question for help" box in a spreadsheet. For an example in which custom formatting is used to hide negative values, see Index of Excel Modules at http://www.idbsu.edu/econ/lreynol/web/excel_index.htm. Return to text Solver The Solver tool in Excel can be used to determine the value at which an equilibrium occurs, or the values of a set of goods that maximizes utility (among many other uses). In the former case, the Solver problem is an unrestricted one--find the quantity at which the absolute vertical difference between the demand curve and the supply curve is minimized. In the second case, maximization is subject to the income constraint. Knowing the optimal value(s) of variable(s) is useful in graphing, because the data range can be constructed in a way that includes the relevant value(s). Approximation without Solver. On occasion, Solver might not be the best way to approximate the optimal (or equilibrium) value of a variable. One might not wish to take the time to introduce the user to Solver. A rather tedious routine can yield an approximately correct solution, but it does not result
in
the correct solution being part of the data range. We illustrate with
the demand/supply example. Follow these steps, as illustrated in the
figure at the right:
Source Data The
Source Data dialog box (right-click on the graph or click on the graph
and select Chart/Source Data from the menu) allows for a number of
changes. The variable name can be changed here, over-riding the name in
the spreadsheet. Variables can be removed from the graph, or added to
it. (It' probably easier to add variables by clicking on the graph and
then on Chart/Add Data.) Also, variable ranges can be changed. Suppose
that it would improve the graph if the first two observations for
demand were deleted (this is especially likely to be helpful when
inverse functions are being graphed). Change the X-Values from
$AA7:$AA19 to $AA9:$AA19. Do
the same for the Y-Values. Failing to change both will shift the
demand curve. If the demand curve had been entered with Price as the independent variable and Quantity Demanded and Quantity Supplied as the dependent variables, Source Data could be used to invert the curves. This is much more tedious and subject to error, however, than initially specifying inverse demand and supply curves. It does happen occasionally that switching the axis as indicated here cannot be avoided. Return to text Topics covered For an excellent set of macroeconomic material (and a good example of the use of Visual Basic) see the following site:http://www.wabash.edu/EconMacro/home.htm. For a larger set of material that we have
developed see [to be added later]. Most of the material at this site
involves microeconomic topics. Also
included is a set of international trade material. Visual Basic
|
||||