Introductory Econometrics: Installing and Using The Monte Carlo Simulation Excel Add-In
Introductory Econometrics: Installing and Using The Monte Carlo Simulation Excel Add-In
Introductory Econometrics: Installing and Using The Monte Carlo Simulation Excel Add-In
Software for
Introductory Econometrics
By
Humberto Barreto and Frank M. Howland
[email protected] and [email protected]
(765) 658-4531 and (765) 361-6317
WARNING:
This software was written and designed for teaching purposes. It has been tested
on several examples but not on a wide variety of data sets. For mission-critical
projects, always check the results with full-fledged statistical programs.
The Monte Carlo Simulation add-in is MCSim.xla (on the CD-ROM or zipped archive, it is in
BasicTools\ExcelAdd-In\MCSim).
333120056.doc
Page 1 of 12
333120056.doc
Page 2 of 12
With the Add-In Manager dialog box up, the instructions for all versions of Excel are the same.
B) Installing and Loading the MCSim.xla file
If the Monte Carlo Simulation add-in is not listed in the Add-Ins scroll box (as in the example
above), click the Browse (or Select) button, navigate to the MCSim.xla file on the CD-ROM or
network drive, select it, and click OK.
Mac Note: Some versions of
OfficeX report Unable to Copy
add-in to the Add-ins folder.
This is a bug. The add-in really
is there. Simply quit Excel, then
restart it, return to the Add-In
Manager, and continue following
the instructions.
Click OK if you are asked to write the MCSim.xla file to the Addins (or Library) folder. The
Add-In Manager dialog box will now list the Monte Carlo Simulation add-in.
The Add-In Manager lists all of the installed add-ins, and those with checkmarks are also loaded.
Microsoft offers the following advice, To conserve memory, unload add-ins you do not use
often. Unloading an add-in removes its features and commands from Microsoft Excel, but the
add-in program remains on your computer, and so you can easily load it again. [Microsoft Excel
Help, add-ins, overview]
333120056.doc
Page 3 of 12
Make sure to select the check box next to the Monte Carlo Simulation add-in and click OK.
Excel will load the MCSim.xla file and notify you of successful installation with the following
message:
333120056.doc
Page 4 of 12
Notice that the spreadsheet can have cells that depend on other cells. Cell A3 uses an IF
statement based on the random draw resulting from cell A1, =IF(A1>0.5,1,0). Thus, A3s
value will be either 1 or 0, as determined by the value of A1. The Monte Carlo Simulation addin can be used on cell A3 even though it does not have a random number in its formula because
A3 is based on A1.
To run a Monte Carlo simulation, simply click on the Tools
menu item and select the MCSim item to access a dialog box
that controls the simulation.
The active cell (the last cell clicked by the user) appears by
default in the Select a cell box. If this is not the cell you want
to use, simply click in the Select a cell box and click on the
desired cell.
The Choose RNG option enables you to use either Excels builtin random number generating function RAND or Barreto
Howlands RANDOM algorithm (packaged with this add-in).
If you select the All RANDOM option, every occurrence of
RAND will be replaced by RANDOM.
To run a Monte Carlo simulation of two cells, click in the Select
a second cell box and then click on a cell in the worksheet.
Click Proceed to run the simulation. Use the Progress Bar to gauge how long it will take to
finish the simulation. You may use other programs while the simulation is running, but doing so
may slow Excel down. You can always hit the Escape (ESC) key (on the top left corner of most
keyboards) to kill the simulation. Click End when prompted. The add-in runs faster if no other
Excel workbooks are open.
On Macintosh computers, hit the Command (clover) and equals sign keys simulataneously instead of the F9 key.
On PCs, CTRL-= will also recalculate cells in the workbook.
333120056.doc
Page 5 of 12
Click here
to make the
dialog box
collapse so
you can see
the sheet.
Excel recalculates your worksheet for as many repetitions as indicated and stores the value of the
cell (or both cells) after each calculation. The results are then presented in a new worksheet in
your workbook.
Histogram bins
include the left
endpoint but not
the right.
The new spreadsheet in your workbook is aliveyou can change the scale, title, and legends on
the graphs, change labels and colors on the cells in the spreadsheets, and add descriptive
information as needed. The data underlying the graph are available by scrolling right.
You can run as many Monte Carlo simulations as you want by simply returning to your original
worksheet and executing Tools: MCSim. Delete unwanted results by simply deleting the sheet.
333120056.doc
Page 6 of 12
333120056.doc
Page 7 of 12
333120056.doc
Page 8 of 12
Source: [Random.xls]CorrelatedRVs.
The BiVarNormal output was created by using =BiVarNormal(0, 1, 0, 2, 0.9) in columns A and B
of rows 45 to 54.
The MultiVarNormal output has the formula,
=MultivarNormal(3,$E$39:$G$41,$H$39:$H$41,$I$39:$I$41), in each row.
333120056.doc
Page 9 of 12
Clicking on the cell to be analyzed is better than typing it in because you might make a mistake
entering the address. If you enter, for example, =$A$, you will obtain
The add-in checks to make sure the cell you selected for analysis changes when the sheet is
recalculated. If not (e.g., the cell address is valid and cell A1 contains the formula, =5), you
will get
Finally, if you check the Record All Selected Cells option and have selected more than 256 cells
to record or ask for more than 65,535 repetitions, there will not be enough room on the sheet.
The maximum size of an Excel spreadsheet is 2^16, or 65,536, rows by 2^8, or 256, columns.
Thus, the add-in will display a warning like this one:
These limitations no longer apply to Excel 2007 and greater. With the latest
version of the MCSim add-in and Excel 2007 or greater, you may track as
many cells and run as many repetitions as your computer memory allows.
333120056.doc
Page 10 of 12
In addition to removing limitations on repetitions and tracking cells, two options have been
incorporated:
1) Check the Delete Previous MCSim sheet option to delete the previous, unwanted MCSim
results. This prevents sheet proliferation.
2) The Set Seed input box allows you enter a number that is used as a starting value for the
random number generator. This enables replication of simulations.
This option can be used only with our user-defined RANDOM() function. It cannot be
used with Excels RAND() function. The seed value is used as the first lagged value and
zero is used as the second lagged value. In addition, the first value in an array of 25
possible values is used as a multiplicative coefficient. The bottom line is that the random
numbers produced are much less random and this option should be used only for testing
and teaching.
Because the set seed option requires RANDOM(), it automatically replaces all instances
of RAND() on your sheet with RANDOM(). To change back to RAND(), simply choose
the All RAND option and clear the Set Seed input box.
Clear the Set Seed input box to get the maximum performance out of the
RANDOM() function.
Finally, this version of the add-in remembers your choicesit populates the input fields with
your previous choices, except for the required selected cell, which continues to be the active (last
selected) cell.
333120056.doc
Page 11 of 12
THIS VERSION
The latest MCSim.xla version is 28 May 2009.
To check the date of your installed add-in, execute Office buttonExcel OptionsAdd-Ins or
(Tools: Add-ins, in older versions) and then highlight the add-in. The date is displayed at the
bottom.
To install this add-in for the first time, please follow the instructions starting on the first page of
this document.
To install over a previous version that is already installed, please see
InstallingAddinOverPreviousVersion.doc for detailed instructions.
In brief, to install over a previous version, quit Excel and simply drag this new version into the
Excel Add-ins folder. If you do not know where this folder is, search for mcsim.xla and then
drag the new version over the old one. Of course, you will want to accept rewriting over the
previous version.
333120056.doc
Frank Howland
Wabash College
[email protected]
(765) 3616317
Page 12 of 12