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!5"# and (765) "6#6"#7
WARNING:
$h%s software was wr%tten and des%&ned for tea'h%n& (ur(oses. )t has been tested
on se*eral e+am(les but not on a w%de *ar%ety of data sets. For m%ss%on'r%t%'al
(ro,e'ts- always 'he'k the results w%th fullfled&ed stat%st%'al (ro&rams.
The Monte Carlo Simulation add-in is MCSim.xla (on the CD-ROM or zipped archie! it is in
"asicTools#Excel$dd-In#MCSim%.
./0.1S2 1F $H)S 314/M25$
$h%s do'ument des'r%bes how to %nstall and use the 2+'el add%n M4s%m.+la %n order to run a
Monte 4arlo s%mulat%on from an 2+'el workbook.
)5S$677)58 653 7163)58
M%'rosoft offers the follow%n& des'r%(t%on of an 2+'el add%n9
6dd%ns are (ro&rams that add o(t%onal 'ommands and features to M%'rosoft
2+'el. Before you 'an use an add%n- you must %nstall %t on your 'om(uter and
then load %t %n M%'rosoft 2+'el. 6dd%ns (:.+la f%les) are %nstalled by default %n the
7%brary folder %n the M%'rosoft 2+'el folder. 7oad%n& an add%n makes the feature
a*a%lable %n M%'rosoft 2+'el and adds any asso'%ated 'ommands to the
a((ro(r%ate menus. ;M%'rosoft 2+'el Hel(- add%ns- o*er*%ew<
$hus- to install an add%n %s to ha*e an add%n f%le (:.+la) %n the 7%brary folder of your hard dr%*e.
$o load %t- you must 'om(lete an add%t%onal ste( us%n& the 6dd)n Mana&er. Fortunately- you
need to do th%s only on'e.
=!>!""?7!.do' .a&e # of #=
Ste( #9 )nstall%n& the M4S%m.+la f%le
)f you are a''ess%n& the M4S%m.+la add%n from a 4301M- (la'e the 43 %n your 'om(uter. )f
a''ess%n& from a network ser*er- make sure you 'an read from the a((ro(r%ate network dr%*e.
)f you do not ha*e 4301M or network a''ess to the M4S%m.+la add%n- download %t by *%s%t%n&
@www.wabash.eduAe'onometr%'sB. 3ownload the M4S%m.+la f%le d%re'tly to the a((ro(r%ate
add%ns folder on your hard dr%*e (usually- 49A.ro&ram F%lesAM%'rosoft1ff%'eA1ff%'eA7%brary) or
mo*e %t there after download%n& to your hard dr%*e.
Ste( =9 7oad%n& $he M4S%m.+la add%n
A) Getting the Add-In Manager
Excel &''( and )reater
1n'e the M4S%m.+la f%le %s a''ess%ble- laun'h 2+'el and use the 6dd)n Mana&er to load the
Monte 4arlo S%mulat%on add%n. F%rst- o(en the 6dd)n Mana&er by 'l%'k%n& the 1ff%'e button
(%n the to( left 'orner)- then 2+'el 1(t%ons- then 6dd%ns (as shown h%&hl%&hted below) and-
f%nally- 'l%'k%n& 8o (near the bottom)9
=!>!""?7!.do' .a&e = of #=
Excel *++( to &'',
1n'e the M4S%m.+la f%le %s a''ess%ble- laun'h 2+'el and use the 6dd)n
Mana&er to load the Monte 4arlo S%mulat%on add%n. F%rst- o(en the
6dd)n Mana&er by 'l%'k%n& on the $ools menu %tem and sele't%n& 6dd
)ns.
C%th the 6dd)n Mana&er d%alo& bo+ u(- the %nstru't%ons for all *ers%ons of 2+'el are the same.
B) Installing and Loading the MCSim.xla file
)f the Monte 4arlo S%mulat%on add%n %s not l%sted %n the 6dd)ns s'roll bo+ (as %n the e+am(le
abo*e)- 'l%'k the Browse (or Sele't) button- na*%&ate to the M4S%m.+la f%le on the 4301M or
network dr%*e- sele't %t- and 'l%'k 1D.
4l%'k 1D %f you are asked to wr%te the M4S%m.+la f%le to the 6dd%ns (or 7%brary) folder. $he
6dd)n Mana&er d%alo& bo+ w%ll now l%st the Monte 4arlo S%mulat%on add%n.
$he 6dd)n Mana&er l%sts all of the %nstalled add%ns- and those w%th 'he'kmarks are also loaded.
M%'rosoft offers the follow%n& ad*%'e- E$o 'onser*e memory- unload add%ns you do not use
often. /nload%n& an add%n remo*es %ts features and 'ommands from M%'rosoft 2+'el- but the
add%n (ro&ram rema%ns on your 'om(uter- and so you 'an eas%ly load %t a&a%n.F ;M%'rosoft 2+'el
Hel(- add%ns- o*er*%ew<
=!>!""?7!.do' .a&e " of #=
Ma' 5ote9 Some *ers%ons of
1ff%'eG re(ort E/nable to 4o(y
add%n to the 6dd%ns folder.F
$h%s %s a bu&. $he add%n really
%s there. S%m(ly -uit Excel- then
restart %t- return to the 6dd)n
Mana&er- and 'ont%nue follow%n&
the %nstru't%ons.
Make sure to select the check ox next to the Monte Carlo Simulation add-in and click !"#
2+'el w%ll load the M4S%m.+la f%le and not%fy you of su''essful %nstallat%on w%th the follow%n&
messa&e9
=!>!""?7!.do' .a&e ! of #=
/S)58 $H2 M4S)M.G76 633)510)8)567H20S)159
/s%n& the Monte 4arlo S%mulat%on add%n %s easy. Iou need a s(readsheet w%th at least one 'ell
that uses a random number formula. 4ell 6# has formula EJ0653()FK thus- when the sheet %s
re'al'ulated (by h%tt%n& the F> key
#
)- the *alue of the 'ell (the number d%s(layed) w%ll 'han&e.
5ot%'e that the s(readsheet 'an ha*e 'ells that de(end on other 'ells. 4ell 6" uses an )F
statement based on the random draw result%n& from 'ell 6#- EJ)F(6#B?.5-#-?)F. $hus- 6"Ls
*alue w%ll be e%ther # or ?- as determ%ned by the *alue of 6#. $he Monte 4arlo S%mulat%on add
%n 'an be used on 'ell 6" e*en thou&h %t does not ha*e a random number %n %ts formula be'ause
6" %s based on 6#.
$o run a Monte 4arlo s%mulat%on- s%m(ly 'l%'k on the $ools
menu %tem and sele't the M4S%m %tem to a''ess a d%alo& bo+
that 'ontrols the s%mulat%on.
$he a't%*e 'ell (the last 'ell 'l%'ked by the user) a((ears by
default %n the Sele't a 'ell bo+. )f th%s %s not the 'ell you want
to use- s%m(ly 'l%'k %n the Sele't a 'ell bo+ and 'l%'k on the
des%red 'ell.
$he 4hoose 058 o(t%on enables you to use e%ther 2+'elLs bu%lt
%n random number &enerat%n& fun't%on 0653 or BarretoM
HowlandLs 06531M al&or%thm ((a'ka&ed w%th th%s add%n).
)f you sele't the 6ll 06531M o(t%on- e*ery o''urren'e of
0653 w%ll be re(la'ed by 06531M.
$o run a Monte 4arlo s%mulat%on of two 'ells- 'l%'k %n the Sele't
a se'ond 'ell bo+ and then 'l%'k on a 'ell %n the worksheet.
4l%'k .ro'eed to run the s%mulat%on. /se the .ro&ress Bar to &au&e how lon& %t w%ll take to
f%n%sh the s%mulat%on. Iou may use other (ro&rams wh%le the s%mulat%on %s runn%n&- but do%n& so
may slow 2+'el down. Iou 'an always h%t the 2s'a(e (2S4) key (on the to( left 'orner of most
keyboards) to k%ll the s%mulat%on. 4l%'k 2nd when (rom(ted. $he add%n runs faster %f no other
2+'el workbooks are o(en.
#
1n Ma'%ntosh 'om(uters- h%t the 4ommand ('lo*er) and eNuals s%&n keys s%mulataneously %nstead of the F> key.
1n .4s- 4$07J w%ll also re'al'ulate 'ells %n the workbook.
=!>!""?7!.do' .a&e 5 of #=
6fter h%tt%n& F>
4l%'k here
to make the
d%alo& bo+
'olla(se so
you 'an see
the sheet.
2+'el re'al'ulates your worksheet for as many re(et%t%ons as %nd%'ated and stores the *alue of the
'ell (or both 'ells) after ea'h 'al'ulat%on. $he results are then (resented %n a new worksheet %n
your workbook.
$he new s(readsheet %n your workbook %s al%*eOyou 'an 'han&e the s'ale- t%tle- and le&ends on
the &ra(hs- 'han&e labels and 'olors on the 'ells %n the s(readsheets- and add des'r%(t%*e
%nformat%on as needed. $he data underly%n& the &ra(h are a*a%lable by s'roll%n& r%&ht.
Iou 'an run as many Monte 4arlo s%mulat%ons as you want by s%m(ly return%n& to your or%&%nal
worksheet and e+e'ut%n& $ools9 M4S%m. 3elete unwanted results by s%m(ly delet%n& the sheet.
=!>!""?7!.do' .a&e 6 of #=
H%sto&ram b%ns
%n'lude the left
end(o%nt but not
the r%&ht.
$he 0e'al'ulate the 2nt%re Corkbook 1(t%on
)f you ha*e a 'om(l%'ated data &enerat%on (ro'ess that s(ans se*eral sheets %n a workbook- be
sure to 'hoose the o(t%on to 0e'al'ulate the 2nt%re Corkbook. $h%s for'es a re'al'ulat%on of all
of the sheets %n the workbook- %nstead of ,ust the a't%*e sheet. Iou 'an tra'k 'ells %n other sheets
by 'olle't%n& all of the 'ells to be tra'ked on a s%n&le sheet.
)f your model %s %m(lemented %n a s%n&le sheet- you need not 'he'k th%s o(t%on. 2+'el w%ll
re'al'ulate only the s%n&le sheet you are work%n& on. $h%s sa*es t%me %n runn%n& the Monte 4arlo
s%mulat%on %f you ha*e many formulas %n other sheets %n the workbook s%n'e 2+'el does not
re'al'ulate those formulas.
$est%n& has shown that- for s%m(le workbooks (w%th few formulas %n other sheets)- re'al'ulat%n&
the ent%re workbook %s faster than re'al'ulat%n& a s%n&le sheet.
$he 0e'ord 6ll Sele'ted 4ells 1(t%on
Iou m%&ht want to tra'k more than two 'ells or see all of the s%mulat%on results (%nstead of ,ust
the f%rst #??). $he Monte 4arlo s%mulat%on add%n allows you to tra'k u( to =56 *ar%ables
(%n'lud%n& one or two you sele'ted for h%sto&ram d%s(lay) and see results for u( to 65-???
re(et%t%ons.
$o take ad*anta&e of th%s- you must $irst sele't the 'ells you want to re'ord (us%n& the 4$07 key-
as usual- to sele't non'ont%&uous 'ells)- then e+e'ute $ools9 M4S%m and- f%nally- 'he'k the
0e'ord 6ll Sele'ted 4ells o(t%on. By 'he'k%n& the 0e'ord 6ll Sele'ted 4ells o(t%on- the add%n
w%ll tra'k all 'ells that were sele'ted .e/ore you e+e'uted $ools9 M4S%m and brou&ht u( the
Monte 4arlo S%mulat%on d%alo& bo+. $he add%n %nserts a new worksheet %n your workbook and
shows 677 of the *alues &enerated by the Monte 4arlo s%mulat%on. Iou 'an use th%s %nformat%on
to sort the results %n order to f%nd (er'ent%les (e.&.- to a((ro+%mate the 'han'es of *alues fall%n& %n
a (art%'ular %nter*al) and to tra'k more than ,ust one or two 'ells.
$he results &enerated by the 0e'ord 6ll Sele'ted 4ells o(t%on are %n ErawF form. Iou w%ll need
to 'om(ute a*era&es- S3s- and draw h%sto&rams on your own. Iou 'an see the full set of
s%mulat%on results for any 'ell (%n'lud%n& one that was 'hosen as a tra'ked 'ell) by s%m(ly
sele't%n& that 'ell .e/ore e+e'ut%n& $ools9 M4S%m.
$o (ra't%'e us%n& th%s o(t%on- sele't 'ells 6# and 6" (w%th 6#Ls formula EJ0653()F and 6"Ls
formula EJ)F(6#B?.5-#-?)F) by 'l%'k%n& on 'ell 6# and then hold%n& down the 4$07 key wh%le
'l%'k%n& on 'ell 6". 5e+t- e+e'ute $ools9 M4S%m. Make one of the tra'k%n& 'ells 6# and the
other 6". Make sure to 'he'k the 0e'ord 6ll Sele'ted 4ells o(t%on. 4l%'k .ro'eed.
$he Monte 4arlo s%mulat%on add%n %nserts two sheets %n your workbook. 1ne re(orts summary
stat%st%'s and draws a su(er%m(osed h%sto&ram- the other s%m(ly l%sts all of the s%mulat%on results
for both *ar%ables. Iou 'an 'onf%rm that the a*era&e- S3- ma+- and m%n are the same by
'om(ut%n& these stat%st%'s %n your M40aw sheet.
=!>!""?7!.do' .a&e 7 of #=
$he 1ut(ut to 2+%st%n& Sheet 1(t%on
)f you are do%n& re(eated s%mulat%ons and ha*e set u( 'al'ulat%ons based on the s%mulat%on
results- you may want to out(ut the results to an e+%st%n& M4S%m sheet rather than 'reat%n& a new
sheet ea'h t%me a Monte 4arlo %s run. 4he'k the 1ut(ut to 2+%st%n& M4S%m Sheet o(t%on to do
th%s. )nstead of 'reat%n& a new M4S%m sheet- out(ut %s (la'ed %n the usual way (%.e.- f%rst #?? %n
'olumn B- summary stat%st%'s %n ran&e P59P8 ;and 75978 %f two 'ells are tra'ked<- and a
h%sto&ram) %n a (re*%ously 'reated M4S%m sheet.
Be 'areful %n us%n& th%s o(t%on be'ause e+%st%n& s%mulat%on results are o*erwr%tten and 'annot be
re'o*ered. Iou 'an 'o(y the e+%st%n& M4S%m sheet (2d%t9 Mo*e or 4o(y SheetQ) %f you want to
(reser*e results from a (re*%ous s%mulat%on.
6dd%t%onal Fun't%ons
$he M4S%m.+la add%n %s (a'ka&ed w%th two array fun't%ons for draw%n& 'orrelated- normal
random *ar%ables9
JB%Har5ormal(mean#- S3#- mean=- S3=- rho)
JMult%*ar5ormal(n*ars- 'orr0an&e- means0an&e- S3s0an&e)
6lthou&h we do not use these fun't%ons %n the %ntrodu'tory te+t- they are essent%al for ad*an'ed
work.
Ce br%efly des'r%be these fun't%ons and re'ommend that the %nterested reader &o to the
CorrelatedR0s sheet %n 0andom.+ls (%n the Bas%' $ools folder) for more do'umentat%on.
For the B%Har5ormal fun't%on- sele't a hor%Rontal (a%r of 'ells (e.&.- 6# and B#)- then enter the
fun't%on %n the formula bar. For e+am(le- JB%Har5ormal(?-#-?-#?-?.>). .ress 4$07SH)F$
25$20 to enter the array fun't%on. $he *alues %n the two 'ells refle't the means- S3s- and
'orrelat%on 'oeff%'%ent you reNuested. $he (re'%se order of the ar&uments %n the fun't%on %s as
follows9 (Mean f%rst *ar%able- S3 f%rst *ar%able- Mean se'ond *ar%able- S3 se'ond *ar%able-
4orrelat%on 'oeff%'%ent). Iou 'an sele't the two 'ells and dra& them down to 'reate a data set of
'orrelated- normal random *ar%ables.
$he Mult%Har5ormal fun't%on enables 'reat%on of de*%ates drawn from a mult%*ar%ate (" or more
random de*%ates) normal d%str%but%on w%th &%*en means and S3s and a matr%+ of 'orrelat%on
'oeff%'%ents. ($he u((er l%m%t for a s%n&le sheet %s =56 'orrelated normals- but the fun't%on
o(erates slowly w%th many 'orrelated random *ar%ables and we are not sure how well the
4holesky de'om(os%t%on works w%th lar&e 'orrelat%on matr%'es.) $he 0an&e %n(uts %n the
fun't%on are 'ell ran&es (su'h as- 4"925) where a((ro(r%ate %nformat%on has been entered.
Iou 'an use the Monte 4arlo s%mulat%on add%n to 'onf%rm that the *ar%ables are o(erat%n& as
e+(e'ted.
=!>!""?7!.do' .a&e 8 of #=
Sour'e9 ;0andom.+ls<4orrelated0Hs.
$he B%Har5ormal out(ut was 'reated by us%n& JB%Har5ormal(?- #- ?- =- ?.>) %n 'olumns 6 and B
of rows !5 to 5!.
$he Mult%Har5ormal out(ut has the formula-
JMult%*ar5ormal("-S2S">9S8S!#-SHS">9SHS!#-S)S">9S)S!#)- %n ea'h row.
=!>!""?7!.do' .a&e > of #=
20010S 653 $01/B72SH11$)58
$he Monte 4arlo S%mulat%on add%n has a few s%m(le error 'he'ks.
)t w%ll 'om(la%n %f you attem(t to do a Monte 4arlo analys%s of a 'ell that %s not a formula9
4l%'k%n& on the 'ell to be analyRed %s better than ty(%n& %t %n be'ause you m%&ht make a m%stake
enter%n& the address. )f you enter- for e+am(le- EJS6S-F you w%ll obta%n
$he add%n 'he'ks to make sure the 'ell you sele'ted for analys%s 'han&es when the sheet %s
re'al'ulated. )f not (e.&.- the 'ell address %s *al%d and 'ell 6# 'onta%ns the formula- EJ5F)- you
w%ll &et
F%nally- %f you 'he'k the 0e'ord 6ll Sele'ted 4ells o(t%on and ha*e sele'ted more than =56 'ells
to re'ord or ask for more than 65-5"5 re(et%t%ons- there w%ll not be enou&h room on the sheet.
$he ma+%mum s%Re of an 2+'el s(readsheet %s =T#6- or 65-5"6- rows by =T8- or =56- 'olumns.
$hus- the add%n w%ll d%s(lay a warn%n& l%ke th%s one9
These limitations no longer apply to Exel !""# and greater. $ith the latest
%ersion of the MCSim add-in and Exel !""# or greater& yo' may tra( as
many ells and r'n as many repetitions as yo'r omp'ter memory allo)s.
=!>!""?7!.do' .a&e #? of #=
!* MA+ !"", -E.SI/0 /1 T2E M/0TE CA.L/ SIM3LATI/0 A44-I0
)n add%t%on to remo*%n& l%m%tat%ons on re(et%t%ons and tra'k%n& 'ells- two o(t%ons ha*e been
%n'or(orated9
#) 4he'k the 3elete .re*%ous M4S%m sheet o(t%on to delete the (re*%ous- unwanted M4S%m
results. $h%s (re*ents sheet (rol%ferat%on.
=) $he Set Seed %n(ut bo+ allows you enter a number that %s used as a start%n& *alue for the
random number &enerator. $h%s enables re(l%'at%on of s%mulat%ons.
$h%s o(t%on 'an be used only w%th our userdef%ned 06531M() fun't%on. )t 'annot be
used w%th 2+'elLs 0653() fun't%on. $he seed *alue %s used as the f%rst la&&ed *alue and
Rero %s used as the se'ond la&&ed *alue. )n add%t%on- the f%rst *alue %n an array of =5
(oss%ble *alues %s used as a mult%(l%'at%*e 'oeff%'%ent. $he bottom l%ne %s that the random
numbers (rodu'ed are mu'h less random and th%s o(t%on should be used only for test%n&
and tea'h%n&.
Be'ause the set seed o(t%on reNu%res 06531M()- %t automat%'ally re(la'es all %nstan'es
of 0653() on your sheet w%th 06531M(). $o 'han&e ba'k to 0653()- s%m(ly 'hoose
the 6ll 0653 o(t%on and 'lear the Set Seed %n(ut bo+.
Clear the Set Seed inp't 5ox to get the maxim'm performane o't of the
.A04/M6) f'ntion.
F%nally- th%s *ers%on of the add%n EremembersF your 'ho%'esO%t (o(ulates the %n(ut f%elds w%th
your (re*%ous 'ho%'es- e+'e(t for the reNu%red sele'ted 'ell- wh%'h 'ont%nues to be the a't%*e (last
sele'ted) 'ell.
=!>!""?7!.do' .a&e ## of #=
$H)S H20S)15
$he latest M4S%m.+la *ers%on %s =8 May =??>.
$o 'he'k the date of your %nstalled add%n- e+e'ute 1ff%'e button2+'el 1(t%ons6dd)ns or
($ools9 6dd%ns- %n older *ers%ons) and then h%&hl%&ht the add%n. $he date %s d%s(layed at the
bottom.
$o %nstall th%s add%n for the f%rst t%me- (lease follow the %nstru't%ons start%n& on the f%rst (a&e of
th%s do'ument.
$o %nstall o*er a (re*%ous *ers%on that %s already %nstalled- (lease see
)nstall%n&6dd%n1*er.re*%ousHers%on.do' for deta%led %nstru't%ons.
)n br%ef- to %nstall o*er a (re*%ous *ers%on- Nu%t 2+'el and s%m(ly dra& th%s new *ers%on %nto the
2+'el 6dd%ns folder. )f you do not know where th%s folder %s- sear'h for Em's%m.+laF and then
dra& the new *ers%on o*er the old one. 1f 'ourse- you w%ll want to a''e(t rewr%t%n& o*er the
(re*%ous *ers%on.
633)$)1567 H27. 653 F223B64D9
)f someth%n& &oes wron& %n the %nstallat%on or load%n& (ro'ess- an une+(e'ted error kee(s
re'urr%n&- or you ha*e other (roblems- (lease 'onta't us. Ce are %nterested %n your 'omments-
su&&est%ons- or 'r%t%'%sms of the M4S%m.+la software.
www.wabash.eduAe'onometr%'s
Humberto Barreto
Cabash 4olle&e
[email protected]
(765) 658!5"#
Frank Howland
Cabash 4olle&e
[email protected]
(765) "6#M6"#7
=!>!""?7!.do' .a&e #= of #=