computational methods in macro1

Upload: cadeau01

Post on 03-Jun-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Computational Methods in Macro1

    1/152

    Methodsforsolvingnonlinear,

    rationalexpectationsbusinesscyclemodels

    A1dayworskhop fortheBathBristolExeterDoctoralTrainingCentre,byTonyYates

    UniversityofBristol+CentreforMacroeconomics

    21May

    21

    14

  • 8/12/2019 Computational Methods in Macro1

    2/152

    1.

    Introduction:

    milestonesin

    history,purpose,curriculumforself

    study,plan

    for

    today

  • 8/12/2019 Computational Methods in Macro1

    3/152

    Purpose

    WorkofSamuelson,Bewley,Brock,Lucas,

    Kydland,Prescott

    and

    others

    Emphasisandlaterdominanceofmicrofounded,oftenrationalexpectationsmodelsinmacro

    Appliesto

    models

    of

    growth

    as

    much

    as

    business

    cycles.

    Recentcolonisationoffinance,development,

    politicaleconomy.

    Alsorichmicroliteraturetoo[eg Pakes...]

  • 8/12/2019 Computational Methods in Macro1

    4/152

    Purpose(2)

    Dominantparadigmhasgeneratednew

    industriesin

    applied

    econometrics

    Methodsforestimatingmodels

    Searchforfactstoconfrontwithmodels

    Purposeistobeginaprocessofgivingyou

    accesstothesevastliteratures

  • 8/12/2019 Computational Methods in Macro1

    5/152

    Someofthegreatdebatesemploying

    computationalmethods

    for

    macro

    Causesofbusinesscycles. Weretheyrealornot?

    The

    great

    inflation,

    great

    moderation,

    great

    contractions. Thecostsofbusinesscycles.

    Optimalmonetaryandfiscalpolicy,incinstitutionaldesign.

    Causeofandoptimalresponsetochangesinconsumption

    andwealth

    distribution

    Financeasasourceandpropagatorofbusinesscycles,andofmisallocation

    Labourmarketinstitutions(eg benefits),welfareandthe

    businesscycle

    R&Dandgrowth; financeandgrowth

  • 8/12/2019 Computational Methods in Macro1

    6/152

    Applicationsofrecursive,numerical

    methods

    IO: optimalentryexit,pricing.

    Labour:

    searchproblems

    when

    decision

    is

    acceptreject.

    DP^2: optimalgovernmentunemploymentcompensationpolicywhenagentssolveanaccept

    reject

    search

    problem

    in

    the

    labour

    market.

    Monetarypolicyandthezerobound[Imworking

    onthis

    now].

    Optimalredistributivetaxationwithaggregateandidiosyncraticuncertainty

  • 8/12/2019 Computational Methods in Macro1

    7/152

    Plan=f(speed) Quasilinear,perfectforesightmethod. [DSGEatzerolowerbound]

    Nonlinear,perfectforesightusingNewtonRaphson [deterministicRBC]

    Parameterisedexpectations[stochasticRBC]

    AprojectionmethoddeployingChebyshev polynomical functionapproximation. [DeterministicRBC]

    Dynamicprogramming

    with

    value

    and

    policy

    function

    iteration

    [DeterministicandstochasticRBC]

    DynamicprogrammingusingcollocationandChebyshevPolynomials[DeterministicRBC]

    HeterogeneousagentmethodsusingKrusselSmith[DeterministicRBC]

    DP^2 someremarksonly.

  • 8/12/2019 Computational Methods in Macro1

    8/152

    Thevehicle:

    RBC

    model

    (Initially)representativeagent,consumption

    savingsinvestment

    output

    problem,

    stochastic,

    neutraltechnologicalprogress.

    Usefulbuildingblockformany,moremodernand

    realisticapplications

    in

    growth,

    finance,

    monetaryeconomics.

    Manynumericalmethodstextbooksexplainusing

    this

    as

    an

    example. Buttorepeat:methodsmuchmorewidely

    applicable.

  • 8/12/2019 Computational Methods in Macro1

    9/152

    Minimaltoolsforappliedmacro

    theory

    Dynamicoptimisation tosolvetheproblemsof

    thefirms

    and

    consumers

    in

    your

    model

    Functionapproximationusingsumsofpolynomials

    Numericaloptimisation

    Matrixalgebra

    Numericalderivatives,numericalintegrals

    Markovchains

    Dynamicprogramming

  • 8/12/2019 Computational Methods in Macro1

    10/152

    Desirableforappliedmacro,minimal

    fortheoretical

    macro

    Realanalysis studyofexistenceand

    convergencetheorems

    on

    which

    dp and

    fa rely

    MostminormodificationsofRBCmodelswillbe

    suchthatrequiredconditionsmet.

    Manymajormodificationseg heterogeneousagents leaveyouinterritorywherethereisno

    possibilityofprovingexistenceoruniqueness,so

    youhavetorelyonexperimentation,homotopy.

  • 8/12/2019 Computational Methods in Macro1

    11/152

    Notcovering

    today:

    Peturbation methodsforsolvingRBC/DSGE

    models Thoughwearedeployingsimilarideatosolve

    rootfinding problemsournonlinearmodelposes

    Noweasy[maybetooeasy!]todothisinDynare,

    softwarewritten

    for

    use

    in

    Matlab.

    Thesearelocalmethods. Adequateunless: Largeshocks

    Occasionally

    binding

    constraints

    or

    other

    things

    inducingkinksinpolicyfunctions

    Choicesetforagentsdiscontinuous

  • 8/12/2019 Computational Methods in Macro1

    12/152

    Goodresources

    Stokey andLucas(1989) regularityconditions,

    convergence

    theorems

    for

    tools

    to

    work. Judd(1993) excellentdiscussionofnumerical

    methodsforNLDSGEmodels

    Heer andMaussner (2005) greathowtobook,including

    some

    good

    details

    on

    tools

    Adda andCooper(2003) niceexplanationsofdynamicprogramming,simulatedmethodof

    moments.

    Aread

    in

    the

    bath

    tour

    of

    macro.

    MirandaandFackler (2002) includespowerfultoolboxofcode.

  • 8/12/2019 Computational Methods in Macro1

    13/152

    Goodresources

    (2)

    Wouter denHaans lecturenoteson

    projectionmethods,

    +many

    others

    DenHaan andMarcet (1990)on

    parameterisedexpectationsmethodis

    excellentandverytransparent.

    Wouter denHaan manuscriptonPEA

    Christiano andFisher

    (2000)on

    unity

    of

    PEA

    andprojectionmethods.

  • 8/12/2019 Computational Methods in Macro1

    14/152

    Software

    Pencilandpaperindispensible,butinsufficient!

    Matlab,Gauss,

    Python

    for

    development,

    computation,simulation

    LowerlevellanguagelikeFortran,C++for

    computationallyintensivetasks

    Mathematica,Maplefordebuggingpenciland

    paper

    calculation

    of

    derivatives

    [perhaps

    integratedintoyourMatlab orotherprograms]

  • 8/12/2019 Computational Methods in Macro1

    15/152

    Companioncurriculumonempirical

    macro

    Timeserieseconometrics; VARs,random

    processes,

    Markov

    processes,

    ergodicity Kalman Filter

    Filtering. Dualitywithoptimallinearregulator.

    Computingthelikelihoodof[thess formofa]

    DSGE/RBCmodel

    MarkovChainMonteCarlomethods Characterisingnumericallyposteriordensities

    Particlefiltering

    Forwhenyoudonthaveanalyticalexpressionsforthelikelihood

  • 8/12/2019 Computational Methods in Macro1

    16/152

    2.

    Piecewiselinear,

    perfect

    foresightsolutionofanonlinearRE

    NK

    model[TakenfromBrendon,Paustian and

    Yates,Thepitfallsofspeedlimit

    interestrate

    rules

    at

    the

    ZLB.]

  • 8/12/2019 Computational Methods in Macro1

    17/152

    Warmup: piecewiselinearREE

    solutionmethod

    Perfectforesight,nonlinearREE

    Jung,Teranishi and

    Watanabe

    (2005),

    Eggertson andWoodford(2003)

    Policy

    rules

    in

    NK

    model

    with

    the

    zero

    lower

    boundtointerestrates

    GuessperiodatwhichZLBbinds;solve

    resultant,2part

    linear

    RE

    system,

    verify

    whetherwehaveanREE

  • 8/12/2019 Computational Methods in Macro1

    18/152

    AnalmostlinearNewKeynesianRE

    model

    t 11

    ytEtt1

    y

    t

    Ety

    t1

    1

    RtEt

    t1

    Rt max

    ty

    y

    ty

    y

    ty

    t1 ,RL

  • 8/12/2019 Computational Methods in Macro1

    19/152

    WhyZLB

    is

    of

    interest

    RatesattheZLBinJapanfor20years,andin

    UK,US

    for

    3.5

    years

    Woodfordsforwardguidancepolicycopied

    (?)bycentralbanksisoptimalpolicyatthe

    ZLB

    Fiscalmultiplier,andbenefitsoffiscalpolicy,

    heavilydependent

    on

    ZLB

    Otherapplicationsofpiecewiselineartoo.

  • 8/12/2019 Computational Methods in Macro1

    20/152

  • 8/12/2019 Computational Methods in Macro1

    21/152

    Calibrationof

    simple

    NK

    model

    elasticity of intertemporal substitution 1

    discount rate 0.99

    Calvo hazard parameter 0.67

    inverse Frisch elasticity of labour supply 2

    weight on inflation in policy rule 1.5

    y weight on output in policy rule 0

    y weight on change in output in p.r. 2

    t max

    ty

    y

    ty

    y

    ty

    t1,RL

  • 8/12/2019 Computational Methods in Macro1

    22/152

    Solutionalgorithm

    t

    y tRt

    a1

    a2

    a3

    y t1 , t 1

    1.GuessZLBbindsatt=0,butnotthereafter.

    2.

    Conventional

    RE

    solvers

    giveus:

    3.Nowsolveforinitial

    period,substitutingout

    expectationsusing

    2.:

    0 k

    y

    0 a1y

    0

    y 0 a2

    y 0

    1

    RL a1y 0

    4. Giveninitialvalues,use2.tosolve

    recursivelyfort=1onwards...

    R0shadow RLRt

    shadow

    RL, t 1

    5. Verify:

  • 8/12/2019 Computational Methods in Macro1

    23/152

  • 8/12/2019 Computational Methods in Macro1

    24/152

  • 8/12/2019 Computational Methods in Macro1

    25/152

    Dynamicsunder

    self

    fulfilling

    recession

    5 10 15 20

    -0.04

    -0.03

    -0.02

    -0.01

    Output

    5 10 15 20

    -0.04

    -0.03

    -0.02

    -0.01

    Inflation

    5 10 15 20

    -0.04

    -0.03

    -0.02

    -0.01

    Labour

    5 10 15 20-10

    -8

    -6

    -4

    -2

    x 10-3 Poli cy Rate

    Self-fulfilling crisis: a simple New Keynesian model

    Inflationandoutput>4%

    fromss

    RatesattheZLB

  • 8/12/2019 Computational Methods in Macro1

    26/152

    Realrate

    under

    self

    fulfilling

    recession

    2 4 6 8 10 12 14 16 18 20

    2

    4

    6

    8

    10

    12

    14

    16

    18x 10

    -3

    The real interest rate during the crisis episode

    Realrate

    high

    in

    period

    2,

    sustainingforecastoflow

    inflationandoutput.

  • 8/12/2019 Computational Methods in Macro1

    27/152

    Generallessons

    Solvingnonlinearproblemsbyrecastingasa

    setof

    linear

    problem

    solving

    steps.

    Guessandverify.

    NB:

    this

    algorithm

    is

    a

    stepping

    stone

    to

    solvingforoptimalpolicyatthezlb.

  • 8/12/2019 Computational Methods in Macro1

    28/152

    Whyperfect

    foresight?

    Hopelesslyunrealistic?

    Maybe

    ok

    for

    some

    questions,

    eg transition

    fromoneSStoanother,inresponseto

    preannouncedpolicy.

    Usefulbenchmark.

    Steppingstonetolearningothermethods.

    Steppingstone

    to

    coding

    other

    methods,

    once

    theyarelearned.

  • 8/12/2019 Computational Methods in Macro1

    29/152

    3.Solving

    aperfect

    foresight,

    finite

    horizonversionofthegrowthmodel

    using

    Newton

    Raphson methods

  • 8/12/2019 Computational Methods in Macro1

    30/152

    Afinite

    horizon

    yeoman

    farmer

    model

    UC0 , . . .CT t0

    T

    Ct

    1/

    , , 1

    fKt Kt, 0, 1

    Kt1 Ct fKt,

    0 Ct,

    0 Kt1 , t 0, . . .T

    Example1.1.1,Heer andMaussner,p9.

  • 8/12/2019 Computational Methods in Macro1

    31/152

    FONCsfor

    the

    yeoman

    farmer

    model

    Kt1 Kt Ct, t 0,1...T

    CtCt1

    1

    Kt11 1, t 0,1...T 1

    Eulerequationdoesnot

    holdfor

    period

    T;

    no

    intertemporal choicehere,

    justeateverything.

    Ct Kt Kt1

    Kt Kt1

    Kt1 Kt2

    1

    Kt11 1

    Kt1

    Kt2Kt

    Kt1

    1

    Kt11 0

    UsebudgetconstrainttosuboutforCtermsinEulerequation.

  • 8/12/2019 Computational Methods in Macro1

    32/152

    TheTdimensionalnonlinearequation

    system

    K1 K2

    K0 K1

    1

    K11 0,

    K2 K3

    K1 K2

    1

    K21 0,. .

    KT

    KT1 KT

    1KT

    1 0

    Thisis asetofTnonlinearequationsinTunknowns,whichwe

    aregoingtosolveusingamodifiedNewtonRaphson method,

    usefulinmanymany contexts.

    Thisalso,likeourwarmupexample,convertssolofnonlinear

    equationintosequentialsolvingoflinearapproximations.

  • 8/12/2019 Computational Methods in Macro1

    33/152

    Unidimensional

    Newton

    Raphson

    ,s. t.fx 0

    g0 x fx 0 fx 0 xx 0

    1 , s. t.g0 x 1 0

    1 x 0 fx0

    fx0

    Thisisourultimategoal,

    formalised

    Weapproximateflinearlyaround

    someinitialpointx_0,usingfirst2

    termsof

    Taylors

    theorem.

    Thenwesolveforthex_1that

    makestheapproximantg(x_1)=0

  • 8/12/2019 Computational Methods in Macro1

    34/152

    Theiterative,unidimension NR

    method

    s1 x s fxs

    fxs

    Ifwe

    iterate

    on

    this

    equation,

    then

    the

    estimatesslowlyconvergeontherootsof

    theoriginalsystem.

    Cangetproblemthatnewguesseslie

    outsidethe

    domain

    of

    the

    function,

    so

    we

    modifybyplacingboundsonthe

    allowableguesses.

  • 8/12/2019 Computational Methods in Macro1

    35/152

    Graphicalillustrationofuni

    dimensionalNewton

    Raphson

    Source: Heer andMaussner,Chapter8: tools

  • 8/12/2019 Computational Methods in Macro1

    36/152

    Multidimensional

    Newton

    Raphson

    0

    0

    . . .

    0

    f1 x 1 , . . .x n

    f2 x 1 , . . .x n

    . . .

    fnx 1 , . . .x n

    0 fx

    f1 K1

    K2K0

    K1

    1

    K11 0 K3 0.K4 . . . 0.KT

    f2 . . .

    . . .

    fnT 0 K1 0 K2 . . . KT

    KT1 KT

    1

    KT1

    Definingthematrix

    function

    f

    via

    matrix

    representationofour

    systemofequations

    Inour

    deterministic

    yeomanfarmer

    model,the

    fs

    willlooklike

    this

    Defining the Jacobian and populating

  • 8/12/2019 Computational Methods in Macro1

    37/152

    DefiningtheJacobian,andpopulating

    it

    using

    the

    deterministic

    yeoman

    farmereg

    Jx

    f11 f2

    1 . . . fn1

    f12 f2

    2 . . . fn2

    . . . . . . . . . . . .

    f1n f2

    n . . . fnn

    ,wherefji

    fix

    dxj

    Ratherthanaderivative,

    wenow

    work

    with

    aJacobian,amatrixof

    partialderivatives.

    f11

    df1

    dx 1 df1

    dK1 d

    dK1

    K1 K2

    K0 K1

    1

    K11

    K1 K2 11K0

    K1 2 1K1 K2 K1

    1 1K12

    f2

    1

    K0

    K

    111

    K

    1

    K

    2

    . . .

    fn1 0,n 3. . .T

    Definingthefirstrow mostentriesintheJacobian matrixwillbezeros.

  • 8/12/2019 Computational Methods in Macro1

    38/152

    Fromlinearapproximationtoour

    system,to

    iterative

    approx to

    the

    roots

    gx fx0 Jx0 dx,dx xx0

    x1 x0Jx0 1 fx

    0

    xs1 xsJxs1 fx

    s

    Linearapproximationto

    themultivariatesystem

    Solutiontog(x)=0at

    the

    point

    x_0

    Solutiontog(x_s+1)=0

    atthepointx_s; and

    iterationsonthis

    convergeglobally

    on

    thesolutionx_*tothe

    nonlinearsystem,with

    somemodifications.

  • 8/12/2019 Computational Methods in Macro1

    39/152

    General,multivariate,modifiedNR

    algorithm

    1. Initialise: choose x0 x,x, i 0

    2. (i) ComputeJxi,

    2. (ii) solvefxi Jx

    ix

    i1x i 0

    2. (iii) ifxi1 x,x,choose 0, 1, s.t. xi1 xix i1xi x,x

    2. (iv) set xi1 xi1

    3. check convergence:stop if fxi1

    , else set i i 1and go to 2

    Modificationchecksifnewguesslieswithindomainoffunction.

    NotethisisHMalgorithm8.5.1,edition1.

  • 8/12/2019 Computational Methods in Macro1

    40/152

    Remarks Manysolutionmethodsboildowntosolving

    nonlinearoptimisation

    problems

    like

    this

    Manyalternativemethodsandrefinements.

    Notesimilaritieswithbefore; converting

    problemofsolvingnonlinearproblemintoone

    offindingeverbettersolutionstothelinear

    approximationsto

    the

    nonlinear

    problem.

  • 8/12/2019 Computational Methods in Macro1

    41/152

    Alternative

    methods

    and

    refinements

    Usingnumericalderivativesbasedon

    differences,in

    this

    NR

    method

    Usingasecantmethodexplicitlybasedondifferences.

    Stochasticmodificiations to

    prevent

    getting

    stuckatalocal. [simulatedannealing]

    Manyprecodedfunctionstouse,butithelps

    toknow

    basic

    method

    to

    be

    able

    to

    use

    them

    effectively

  • 8/12/2019 Computational Methods in Macro1

    42/152

    PS

    on

    perfect

    foresight

    and

    NR Weusedthismethodinourpaperonthezero

    boundtoo.

    Insteadoflinearising theNKmodel,andthenworkingwiththezeroboundusingaguess

    andverify

    method

    Formulatefull,nonlinearNKmodel,includingZLB,solvingsysteminvolvingfinitenumberof

    periods,one

    equation

    for

    each

    period,

    as

    you

    justsawfortheRBCmodel.

  • 8/12/2019 Computational Methods in Macro1

    43/152

    WhatabouttheinfinitehorizonRBC

    model?

    Samemethodcanbeusedtosolveinfinite

    horizonmethod,

    on

    assumption

    that

    we

    get

    veryclosetosteadystateinsomefinite

    numberofperiods.

  • 8/12/2019 Computational Methods in Macro1

    44/152

    N li f f d

  • 8/12/2019 Computational Methods in Macro1

    45/152

    Nonlinearsystemforforward

    iteration

    0 K1

    K2K0

    K1K11

    0 K2

    K3K1

    K2K2

    1

    . . .

    0 KT

    K

    KT1 KT

    KT1

    Nowwe

    have

    log

    utility,

    and

    discounting,soslightdifferenceinRHS.

    NotebeforefinalKwas0; now

    K_star=steadystate

    ThisisTequationsinTunknowns.

    K_0isgiven.

    Iterationsneeded:

    if

    K_T

    too

    far

    from

    ss,thenneedtolengthenT.

  • 8/12/2019 Computational Methods in Macro1

    46/152

    4.

    Solvingthe

    growth

    model

    using

    theparameterisedexpectations

    algorithm

    S l i RBC d l i

  • 8/12/2019 Computational Methods in Macro1

    47/152

    SolvingRBCmodelusing

    parameterisedexpectations

    DenHaan andMarcet (1989)

    Analogywith

    learning,

    connection

    with

    Marcets

    workwithSargent onpropertiesoflearning

    algorithms

    Lotsof

    problems

    with

    it,

    not

    that

    widely

    used

    now

    Butverysimpletoconceiveandprogram,

    illustratesthe

    problem

    nicely,

    and

    an

    introduction

    intogeneralclassofprojectionmethods

  • 8/12/2019 Computational Methods in Macro1

    48/152

    The

    RBC

    or

    growth

    model

    c t,ktt0

    max Ett0

    tct

    1 1

    1

    subject to :

    ctkt1 ztkt 1kt

    lnzt lnzt1 et,et N0, 1

    ct ckt,zt,kt1 kkt,ztSolutionisapairoffunctionslinkingthechoicevariables(consumption

    andcapitalforusetomorrow)tothestatevariables[shockz,andcapital

    today]

  • 8/12/2019 Computational Methods in Macro1

    49/152

    ct

    Etct1

    kt11 1

    ctkt1 ztkt 1kt

    SolutionhastosatisfytheEulerequation[inmorecomplexmodels,

    thefull

    set

    of

    FONCs]

    and

    the

    resource

    constraint.

    Inthespecialcaseoflogutility[gamma=1]andfulldepreciation

    [delta=1],thesesolutionscanbecalculatedanalyticallyandare

    knowntobe:

    ct 1ztkt,kt1 ztkt

    Choosing the approximant:

  • 8/12/2019 Computational Methods in Macro1

    50/152

    Choosingtheapproximant:

    expectationsin

    the

    Euler

    equation

    gkt,zt ea1 ln kta 2 lnzt

    ct

    Etct1

    kt11

    1

    WeapproximatetheconditionalexpectationontheRHSofthe

    Eulerequationabovewithapolynomialinthestatevariables.

    NB1. maybedesirabletousehigherorderpolynomial

    2.maybeachoiceaboutwhichfunctiontoapproximate[as

    here],ormorethanonefunctionyouhavetoapproximate.Eg may

    bemore

    than

    one

    agent

    forming

    expectations!

  • 8/12/2019 Computational Methods in Macro1

    51/152

    PEA

    algorithm

    1. Draw a long sequence of values for shockse tto generate the exogenous technology shock process z t. (Long100,000?)

    2. Choose a starting value fora1 ,a2and a starting value fork0 , perhaps the steady state.

    3. Simulate the model by:

    3.1 computingc0

    ea 1ln k0a 2lnz0

    3.2 solving fork1from the resource constraint, thus: k1 z0k0 1k0c0

    3.3. push time forward one period and return to 3.1

    4. Compute residuals by:4.1 for each t, lettingc t

    true ct1

    kt11 1,ct

    app ea1ln kta2lnzt

    4.1Rt cttrue c t

    app

    5. Updatea1 ,a2by choosing them to mint0

    T

    R2 [nonlinear least squares]

    6. Check convergence. If converged, stop, else return to 3.

  • 8/12/2019 Computational Methods in Macro1

    52/152

  • 8/12/2019 Computational Methods in Macro1

    53/152

    Problems

    with

    PEA Multicollinearity whenyoutrytogetmore

    accurateapproximationsbyincludinghigherordertermsinthepolynomial.

    Eg: Thesquareoftheshockiscorrelatedwiththeshockitself.

    Solutionaccurate

    only

    close

    to

    steady

    state,

    since

    simulationslivemostlythere.

    Potentialforinstabilityintheupdatingalgorithm

    Analogywith

    intertemporal learning

    models,

    and

    projectionfacilitiesforsolvingtheproblem.

  • 8/12/2019 Computational Methods in Macro1

    54/152

    Resolving

    PEA

    convergence

    problems

    Homotopy: usesolutionstoproblemsyoucan

    solveto

    inform

    starting

    values

    to

    problems

    youhaventyetsolved

    Projectionfacilitiesanddampedupdating:

    slowdown

    updating

    process

    in

    PEA

    algorithm.

    PEA step with a projection facility or

  • 8/12/2019 Computational Methods in Macro1

    55/152

    PEAstepwithaprojectionfacility,or

    dampedupdating

    5. 1 : a1j1p

    ,a2,j1p

    arg mint0

    T

    R2

    5. 2 : a i,j1 ai,j 1ai,j1p

    Tradeoff:

    Tooslowupdatingrisksgettingstuckawayfromthesolution.

    Too

    fast

    updating

    risks

    inducing

    instability

    in

    the

    algorithm

    and

    not

    findingthesolution.

    Example of (not very useful) homotopy

  • 8/12/2019 Computational Methods in Macro1

    56/152

    Exampleof(notveryuseful)homotopy

    algorithm

    f, fObjective: solve

    RBCmodel

    definedby

    Initialise parameters:

    RBC parameters0 1,0 1

    PEA parameters:

    i) solve model analytically, givingc t0 zt,kt,kt10 zt,ktii) simulate model giving sequencesc0 ,k0

    iii) initialise values ofa10 anda2

    0 in c t

    ea 1 ln kta 2 lnzt that minimise the gap between ctsimulated in ii) andc t

    Counter: set i 1

    Main loop:1. Set i, i i1 , i1 f,f0 ,0

    5. Solve forc t1 zt,kt,kt1

    1 zt,ktusing PEA, initialising (a1 ,a2 a1i1 anda2

    i1 , saving on convergencea1i ,a2

    i

    6. If (, f,f, set i i 1and go to 1, else you are done.

  • 8/12/2019 Computational Methods in Macro1

    57/152

  • 8/12/2019 Computational Methods in Macro1

    58/152

    Remarks Analogybetweenintratemporalprocessof

    iterativealgorithm

    to

    find

    best

    approximate

    expectationsfunction

    andintertemporallearningwithagents

    updatingexpectations

    functions

    as

    data

    becomesavailableeachperiod.

    Similarity

    not

    just

    superficial;

    maths

    of

    convergenceorlackofithasconnections.

    Inter and intra temporal learning

  • 8/12/2019 Computational Methods in Macro1

    59/152

    Interandintratemporallearning

    analogy Consumersstartwithanexpectationsfunction.

    Take

    decisions.

    Datarealised.

    Agentscomputesurprise. Newfunction

    updatedas

    function

    of

    surprise,

    and

    imprecision

    inestimates.

    Gaindampsupdating.

    Undersomeconditions,convergestoREE.

  • 8/12/2019 Computational Methods in Macro1

    60/152

    5.

    Solving

    RBC

    model

    using

    collocation,andChebyshev

    polynomials

  • 8/12/2019 Computational Methods in Macro1

    61/152

    Overview

    of

    this

    section Preliminaryonapproximationusing

    Chebyshev polynomials SolvingRBCmodelsusingCheb Polysto

    approximatetheexpectationsfunction.

    Iteratingon

    the

    Bellman

    Equation

    using

    Cheb

    Polystoapproximatethevaluefunction.

  • 8/12/2019 Computational Methods in Macro1

    62/152

    5.1Function

    approximation

    and

    Chebyshev polynomials

  • 8/12/2019 Computational Methods in Macro1

    63/152

    Intro

    remarks Functionapproximationisatechniquewidely

    encounteredintheory,econometrics,numerical

    analysis. Weencountereditalreadyinusinglinear

    approximationsinNewtonRaphson tofindroots

    of

    nonlinear

    equation

    system. Regressionisfunctionapproximation.

    Fourierseriesapproximationusedtocomputethespectrum.

    Here: wewillapproximatetheexpectationsfunctioninconsumersFOC.

    Typicalfunctionapproximation

  • 8/12/2019 Computational Methods in Macro1

    64/152

    yp pp

    problem,and

    solution

    x Ca,b

    fx

    i1

    n

    i ix

    0 x,1 x, . . .

    x fx

    i

    1

    i ix, ix xi

    x fx 0 1x 2x

    2 . . .pxp

    Wewanttoapproximatesomefwhichis

    continuousoverthea,b interval

    Wedoitbytakingsomeweighted

    combinationofbasisfunctions,eg afamilyof

    polynomials

    Forexample,wecanrepresentany

    continuousfunctionEXACTLYwith

    thisinfinite

    sum

    of

    polynomials

    Whichinpracticemeansusingthe

    firstpterms.

  • 8/12/2019 Computational Methods in Macro1

    65/152

    Chebyshev Polynomials

    Tix cosiarccosx

    Ti1 x 2xTixTi1 x

    T0 x cos0.arccosx 1

    T1 x cos1.arccosx x

    T2 x 2xT1 xT0 x 2x2

    1T3 x 2xT2 xT1 x 4x 3 3x

    GeneralexpressionfortheC.P.oforderi.

    Theycanbedefinedrecursively.

    HerearethefirstfourCPs.

    Graph of 1st 3 Chebyshev polynomials

  • 8/12/2019 Computational Methods in Macro1

    66/152

    Graphof1st 3Chebyshev polynomials

    Source: Heer+Maussner,ch 8,p434

  • 8/12/2019 Computational Methods in Macro1

    67/152

    Domains

    of

    the

    CP

    and

    your

    f(x)

    Xz 2zba

    a bba

    ,z a,b

    Zx x1ba2

    a,x 1, 1

    CPsonlydefinedon1,1. X(z)

    convertsvaluesdefinedona,b

    intovalues

    defined

    on

    1,1.

    Z(x)doesthereverse.

    fx : a,b

    gx fZx :1, 1

    z; i0

    n

    iTiXzThiswillbeourapproximating

    function.

    TheCPswilltakeasaninput

    transformationsoftheoriginal

    pointsinourfunction.

    Digression: derivingtheEuler

    equation in the deterministic RBC

  • 8/12/2019 Computational Methods in Macro1

    68/152

    equationinthedeterministicRBC

    model

    maxc0,c1...

    U t0

    tc t1

    11 , 0, 1, 0

    subject tokt1 c t kt 1kt, 0, 1

    0 ct

    0 kt1k0given

    Nonlogarithic preferences,andthepresenceofonlypartial

    depreciation,will

    make

    an

    analytical

    solution

    impossible.

    ButasafirststepwehavetoderivetheEulerequationanyway;

    thoughthatstillleavesthetaskofsolvingforc(k),thepolicyfunction.

    Forminganddifferentiatingthe

  • 8/12/2019 Computational Methods in Macro1

    69/152

    Lagrangian inthe

    RBC

    model

    Lagrangian fortheconsumers

    problem.

    dL

    dct 0 t1

    ct

    1 t

    0 tct t

    ct

    t

    Whichwedifferentiatewrt

    todaysconsumption

    andtomorrowscapital

    L t0

    t c

    t

    1

    1

    1 tkt1 c tkt 1kt

  • 8/12/2019 Computational Methods in Macro1

    70/152

    Solving for the steady state for capital

  • 8/12/2019 Computational Methods in Macro1

    71/152

    Solvingforthesteadystateforcapital

    0 k1 1 c

    c

    1

    1 k1 1/

    k1 1

    1

    k1 11

    k1

    11

    k

    11

    1

    1

    StartwiththeEulerequation.

    Dropthe

    time

    subscripts,

    since

    in

    thesteadystateallvariablesare

    constant.

    Thensolveforkstarintermsof

    themodels

    primitive

    parameters.

    Thisvalueisgoingtohelpus

    definegoodboundsforcapital

    whensolvingthedynamicRBC

    model.

    Bounding the state space

  • 8/12/2019 Computational Methods in Macro1

    72/152

    Boundingthestatespace

    X k,k

    k 1. 5k,k 0. 5k

    Setboundsexperimentally,bracketingthesteadystatesolutionfor

    capital.

    The residual function

  • 8/12/2019 Computational Methods in Macro1

    73/152

    Theresidualfunction

    minkk

    R,k

    2

    dk

    Likeallprojectionmethods,westartwiththe

    objectiveofminimisingtheintegralofa

    residualfunction,evaluatedacrossthestatespace,asafunctionoftheparams that

    definetheapproximatingfunction.

    S kk

    2L

    l1

    LR,k

    kl

    2 1kl

    2

    Thek_tilde_ls aremappedintok_up,k_down.

    Thisintegralisgoingtobeapproximatedusingasum,evaluatedatpoints

    correspondingtothezerosoftheChebyshev Polynomial. Anexampleof

    quadrature,

    a

    form

    of

    numerical

    integration.

    Remarks

  • 8/12/2019 Computational Methods in Macro1

    74/152

    Remarks

    NotethereareTWOapproximationsgoingon.

    Weare

    approximating

    the

    policy

    function

    c(k)

    usingChebyshev polynomials

    And,inordertofindthebestsuch

    approximation. weareapproximatingtheintegraloftheresidual

    functiondefinedoverthecapitalspacewitha

    sum,using

    quadrature.

    Computingtheresidualfunctionfor

  • 8/12/2019 Computational Methods in Macro1

    75/152

    somearbitary k_0

    R,k0

    c 1c 0

    1 k11 1

    Ideaisthatifwehavegotthegammasrightintheapproximating

    function,ie ifwehaveagoodapproximationtothepolicyfunction.

    thentheEulerEquationshouldbeclosetoholding. Ifitdoesthenthe

    LHS=0.

    Butthenweneedanalgorithmforcomputingc_hat_0,c_hat_1and

    k_1.

    Computing the residual function

  • 8/12/2019 Computational Methods in Macro1

    76/152

    Computingtheresidualfunction

    R,k0 c 1

    c 0

    1k1

    1 1

    1.computec 0

    c,k0

    2.computek1 k0 1k0c 0

    3.computec 1

    c,k1

    c,k0 j0p jTjkk0

    TheEEbasedresidual

    function

    we

    are

    trying

    to

    compute.

    Givenc_hat_0(k_0),wegetk_1

    fromtheresourceconstraint.

    Thenweevaluatec_hat_1(k_1).

    UsingtheCPformulahere.Wherek_tilde(k_0)mapsthe

    latterintothe1,1intervalover

    whichtheCPisdefined.

    Not quite done!

  • 8/12/2019 Computational Methods in Macro1

    77/152

    Notquitedone!

    Wehavetominimisethatapproximateintegralof

    the[functionofthe]residualfunction,overthe

    capitalspace.

    .Usingsomeminimisationroutine!

    Wehave

    seen

    elements

    of

    how

    to

    do

    this

    when

    weusedNRmethodstofindthezeros ofa

    nonlinearequationsystem.

    Canwrite

    afunction

    that

    computes

    the

    sum,

    then

    usefminsearch,orcsminwel tominimiseit.

    Remarks

  • 8/12/2019 Computational Methods in Macro1

    78/152

    e a s

    Theoutputofthisprocedureisafunctionthat

    specifies

    what

    cis,

    given

    some

    inherited

    level

    ofk.

    Rememberthiswasthedeterministicgrowth

    model.

    Ifwewantshocks,wethenhaveatwo

    dimensionalstatespace,andneedtodoCPin

    twodimensions.

  • 8/12/2019 Computational Methods in Macro1

    79/152

    6.Intro

    to

    dynamic

    programming,

    valueandpolicyfunctioniteration

    Sargent+L: Imperialismofrecursive

  • 8/12/2019 Computational Methods in Macro1

    80/152

    methods DPveryuseful.

    Detailsof

    conditions

    under

    which

    its

    lessons

    hold,

    andnumericalmethodstooperationaliseitwork,

    arehard. Avoidedhere.

    Implementationin

    simple

    settings

    easy!

    Essentialifeg agentschoicesarediscontinuous,

    whenLagrangian methodsbreakdown.

    [accept/reject,enter

    or

    not,

    exit

    or

    not,

    bus

    or

    train]

    OverviewofDynamicProgramming

  • 8/12/2019 Computational Methods in Macro1

    81/152

    section 1.Deterministic,finiteelementdynamic

    programming. 2. Stochasic,finiteelementDP

    3. Continuousstatemethodsusing

    collocation.

    Alongtheway: MarkovChainapproximations

    to

    continuous

    random

    processes. FewwordsaboutDP^2

  • 8/12/2019 Computational Methods in Macro1

    82/152

    6.1

    Dynamicprogramming:

    generalsetting

    Generalsetting

  • 8/12/2019 Computational Methods in Macro1

    83/152

    Chooseut t0 to

    maxt0

    trx t,u t

    s.t.x t1 gx t,ut;x 0 Rn given

    Chooseasequenceofcontrol

    settings(u),

    such

    that

    adiscountedsumofreturns (r)is

    maximised,subjecttolawof

    motionforthestate(x)

    Wecouldbethinkingofaconsumer,orafirm,[and!/]oralarge

    agentlikeapolicymakersettingpolicysubjecttolawsofmotion

    generatedbythesolutionstothesmallagentsproblem

    [aggregated].

    MusingsonhandV

  • 8/12/2019 Computational Methods in Macro1

    84/152

    ut hx t

    x t1 gx t,ut

    Vx 0 maxu ss0 t0

    trx t,u t

    Dynamicprogramming

    turns

    problem

    into

    searchforV[valuefunction]andh[policy

    function]suchthatifweiterateonthese2

    equations thetermonRHSofRHSis

    maximised.

    maxurx,u Vx, x gx,u

    IfweknewV,wecouldcompute

    theRHSfordifferentusand

    thereforefind

    h.

    Ofcourse,wedont.

    TheBellmanequation

  • 8/12/2019 Computational Methods in Macro1

    85/152

    Vx maxurx,u Vgx,u

    Vx rx,hx Vgx,hx

    V(todaysstate)andV(tomorrows)arelinkedbytheBellman

    Equationabove. Remembergisthetransitionlawthat

    producestomorrowsstatefromtoday.

    Thepolicyfunctionhisafunctionthatsatisfiesthemax

    operater above,in

    which

    case

    if

    we

    substitute

    in

    for

    u,

    we

    cangetridofthemaxoperator.

    Cakeeatingproblem

  • 8/12/2019 Computational Methods in Macro1

    86/152

    Canthaveyourcakeandeatit. Rather,cant

    eat

    your

    cake

    and

    have

    it! HowquicklyshouldIeatmycake,giventhatit

    rots,thatIdontwanttogohungry,but

    tomorrowmay

    never

    come.

    BellmanEquation: supposethatfrom

    tomorrow,Ihaveanoptimalcakeeatingplan.

    Howmuch

    should

    Ieat

    now?

    Contractionmappingyieldedby

  • 8/12/2019 Computational Methods in Macro1

    87/152

    [iterationson]

    the

    Bellman

    equation

    Vj1 maxurx,uVjx

    Undersomeconditions,startingfromanyguessofV_0,evenV_0=zeros,

    iteratingontheBellmanequationwillconvergetogivethevalue

    function. Thisiscalledvaluefunctioniteration. Asabiproductofthe

    maxon

    the

    RHS

    it

    produces

    the

    policy

    function

    h.

    AswewillseewecanalsoiterateonthePolicyfunction. Policyfunction

    iteration.

  • 8/12/2019 Computational Methods in Macro1

    88/152

    6.2

    Deterministic,analytical

    DP

    inthegrowthmodel

    DeterministicVFIinanRBCmodelwe

    l l i ll

  • 8/12/2019 Computational Methods in Macro1

    89/152

    cansolve

    analytically

    max

    t0

    tuc

    s.t. ctkt1 yt1kt

    yt fkt

    k0given

    u lnc

    1

    yt Ak

    Deterministic:

    noteno

    expectations

    term,andnorandomproductivity

    proess.

    CobbDouglasproduction.

    Logutility.

    Fulldepreciationofcapitalk.

    DeterministicVFIintheRBCmodel

  • 8/12/2019 Computational Methods in Macro1

    90/152

    V0 k 0,k

    V1 k maxc,k lnc . 0

    ck Ak

    V1 k lnAk lnA lnk

    WestartwithanyoldguessatV,

    V_0

    WeplugitintotheBellman

    Equation.

    AstheBEinstructs,wemaximiseit

    wrt tochoice

    variables

    c,k

    Thisgivesusanewguessatthe

    valuefunctionV_1. [Nowquite

    differentfromV_0.

    Werepeattheprocessoverand

    overuntilconvergence.

    2nd iterationontheBellmanEquation

  • 8/12/2019 Computational Methods in Macro1

    91/152

    V2k maxc,k

    lnc lnA lnk

    maxc,k lnAk

    k

    lnA

    lnk

    1Ak k

    k 0

    Ak k 1

    k

    Ak k1 1

    k Ak

    1 1

    Ak

    1

    c Ak Ak

    1

    c Ak

    1

    WehavesubstitutedinourV_1

    guess.

    Nowwehavetomaximisethis

    expressionwrt c,k

    Evaluatedatthesemaximised

    values,we

    have

    our

    next

    guess

    at

    thevaluefunction,V_2

    Asabiproduct,wehavetheguess

    atthepolicyfunctions(expressions

    forcand

    k

    in

    terms

    of

    k

    Completingthe2nd iterationonthe

    B ll E ti

  • 8/12/2019 Computational Methods in Macro1

    92/152

    BellmanEquation

    V2 k ln Ak

    1 lnA ln

    Ak

    1

    ln A1

    lnA ln A

    1 1 lnk

    ThisisourV_2guessoncewehavecompletedthe

    maximisation,[hence

    no

    max

    operator

    now,

    since

    this

    is

    done!].

    NotethatitisquitedifferentfromV_1

    Inacomputer

    program,

    we

    would

    use

    the

    difference

    betweeneachiterationsguesstodecidewhetherwe

    shouldkeepgoingornot.

    A3rd iteration?!

  • 8/12/2019 Computational Methods in Macro1

    93/152

    V3 k maxc,k

    lnc V2 k

    maxc,k

    lnAk k ln A1

    lnA ln A1

    1 lnk

    Continuing,we

    would

    :

    differentiatewrt k,

    solve

    for

    c,

    k

    that

    maximise;

    pluginthemaximisedvalues,toproduceV_3. ThensubstituteintheBE

    againtogetanexpressionforV_4.Andsoon.

    Finalexpressionforvalueandpolicy

    functions

  • 8/12/2019 Computational Methods in Macro1

    94/152

    functions

    Vk 11 lnA1 1

    lnA 1

    lnk

    ck 1Ak

    kk Ak

    Wewouldneedininitely manyiterationstoconverge,butuseofthealgebra

    ofgeometric

    series

    that

    emerge

    can

    produce

    these

    expressions.

    ThereisalsoaguessandverifywaytosolveforV,butdoingitthisway

    illustratessomeoftheaspectsofnumericaliterationsontheBE.

    RemarksonVFI

  • 8/12/2019 Computational Methods in Macro1

    95/152

    Onlyhaveconvergenceundercertainconditions. [SeeStokey andLucas].

    Caniterateonthepolicyfunctioninstead,undermorerestrictiveconditions.

    Can

    use

    combination

    of

    the

    two

    to

    speed

    computation.

    Ingeneralwonthaveanalyticalexpressions

    forderivatives

    we

    used

    at

    each

    step

    [and

    of

    coursenoanalyticalexpressionsforV,c,k]

  • 8/12/2019 Computational Methods in Macro1

    96/152

    6.3

    Policyfunction

    iteration

  • 8/12/2019 Computational Methods in Macro1

    97/152

  • 8/12/2019 Computational Methods in Macro1

    98/152

  • 8/12/2019 Computational Methods in Macro1

    99/152

    6.4 Numerical,deterministic

    dynamicprogramming

    in

    the

    growth

    model

  • 8/12/2019 Computational Methods in Macro1

    100/152

    Alooptocomputethefirstnew

    iterationontheBellmanEquationin

    Matlab or similar

  • 8/12/2019 Computational Methods in Macro1

    101/152

    Matlab orsimilar

    V1 ki maxucj V0 kj1.set k k1 kl y Akl

    2.evaluateucj V0 kjfor each possiblecj,kj

    3.choose highest [in this casec Ak,k 0], assign this number toV1 1

    4.go back to1.and repeat for next value ofk,k2 kl 1/dku kl. . .

    Subsequentloopsarethesame withexceptionthatoncewehave

    dispensed

    with

    V=0the

    V

    is

    going

    to

    influence

    the

    search

    for

    the

    maximising

    valuesofk,c.

    Andwewillkeepgoinguntilwehavemeasuredanddecidedon

    convergence.

    Stoppingcriterionforavaluefunction

    iteration loop

  • 8/12/2019 Computational Methods in Macro1

    102/152

    iterationloop

    stop ifmaxVdiff

    VkVk1

    Aftereachnewiteration,wewillcomparetheoldandnewVselementby

    element,and

    compute

    the

    maximum

    difference,

    and

    stop

    provided

    the

    absolutevalueofthisdifferenceislessthanaprespecifiedtolerancevalue.

    Thisisdonebyusingawhileabs(max(vdiff))

  • 8/12/2019 Computational Methods in Macro1

    103/152

    Themaximisationstepcanbeverytimeconsuming. Computerhastoenumerateand

    checkeach

    candidate

    Value

    for

    each

    policy

    choice.

    Convergencegreatlyspeededupbygoodstarting

    values.

    Orevenmissingoutthemaxstep.[Accelerator].

    Syntaxofloopscanbeimportant:vectorising

    RemarksonnumericalDP

  • 8/12/2019 Computational Methods in Macro1

    104/152

    Alternativestoppingcriteriaiswhenthepolicy

    functions[vector(inourexample)ofpointers]

    doesnotchange.

    Thatis,ifyouarentinterestedinVitself.

    Simulatingthe

    model

    just

    requires

    the

    pointers.

    Theeg weworkedoutallowsustotrace

    trajectoryfrominitialk,tosteadystate.

  • 8/12/2019 Computational Methods in Macro1

    105/152

    6.5

    Stochasticdynamic

    programminginthegrowthmodel

    Stochasticdynamicprogramming

  • 8/12/2019 Computational Methods in Macro1

    106/152

    Sofarwehaveassumedtherearenoshocks.

    SowecantsolveandsimulatetheclassicRBC

    model,drivenbytechnologyshocks.

    Todothiswehavetoenlargethestatespace

    toinclude

    adimension

    for

    the

    shocks.

    SoourV=V(k,A)

    Finiteelementapproximationofacontinuous

    randomprocessusingMarkovchains.

    DigressiononMarkovchains

  • 8/12/2019 Computational Methods in Macro1

    107/152

    Someeconomiccontextsbestdescribedwith

    finiteelementrandomprocesses[regimes?]

    Continuousrandomprocesseswell

    approximatedbyMarkovchains[Tauchen

    (1986)]

    Markovchains

  • 8/12/2019 Computational Methods in Macro1

    108/152

    robx t1 |x t,x t1 , . . .x tk probx t1 |x t Markovproperty

    0

    Z

    P

    3objectsneededtodefineaMarkovchain. Initial

    probabilties; vectorstoringpossiblevaluesforthe

    chain; matrixdefiningtransitionprobabilities

    0 Pk Computingprobabilitiesatt+k

    Ergodic,orstationarydistributionofa

    Markov chain

  • 8/12/2019 Computational Methods in Macro1

    109/152

    k k1

    P

    P IP 0

    p ij 0i,j

    p ijk 0i,j;Pk P P. . . .P [ktimes], somek 1

    Wecaniterateonthisequationto

    findthestationarydistribution

    ..whichhappenstosolvethis

    equation.

    Suchadistributionexists,andisindependentofpi_0ifeitherof

    thesetwoconditionsholds. Basicallyrequirescantrandomlyget

    stuckinoneofthestates.

    DefiningaMarkovchainfor

    technology

  • 8/12/2019 Computational Methods in Macro1

    110/152

    gy

    2

    1

    0. 5

    P

    0. 3 0. 3 0. 4

    0. 8 0. 1 0. 1

    0.2 0.75 0.05

    0 0.1,0.1.0.8

    Technologycantakethree values:

    high,mediumandlow.

    Prob ofgoingfromhightolowis0.4;

    Prob ofstaying

    in

    medium

    if

    you

    start

    in

    mediumis0.1.

    Theinitialperiodprobabilitiesofhigh,

    mediumandlow.

  • 8/12/2019 Computational Methods in Macro1

    111/152

    StochasticversionoftheBellman

    equation

  • 8/12/2019 Computational Methods in Macro1

    112/152

    qVj1 maxurx,uEVj

    x |x

    Vj1 k,A maxc,k lnc EVjk,A |A

    Vj1 k,Am maxc,k lnc i1

    3

    pmiVjk,A i

    |Am

    Ourgeneralcasemodifiedto

    includeshocks.

    OurRBCcasewithshocks.

    Expandingthe

    expectations

    operator

    in

    our

    caseofadiscretestateMarkovchainusedto

    approximatetheshocks.

    Thenewtwodimensionalvalue

    functionwithrandom,3state

    technology

  • 8/12/2019 Computational Methods in Macro1

    113/152

    gy

    V0 k,A

    V0 k kl,A A1 V0 k k

    l,A A2 V0 k kl,A A3

    . . . . . . . . .

    . . . . . . . . .

    . . . . . . . . .

    V0 k ku ,A A1 V0 k k

    u ,A A2 V0 k ku ,A A3

    Valuefunctionisnowamatrixstoringvaluescorrespondingtoinherited

    outcomesforkfromk_l tok_h,andineachofthesecases,forinherited

    productivitylevels

    from

    A(high=1_

    to

    A(low=3).

    FillingoneelementoftheBellman

    Equationwitha3stateMarkovchain

    for technology

  • 8/12/2019 Computational Methods in Macro1

    114/152

    gy

    Vj1 kl,A3 maxc,k

    lnc 0. 2Vjk

    ,A

    A1|A A3 0.75Vjk,A A2|A A3

    0.05Vjk,A A3|A A3

    RemarksonapproximatingAR(1)for

    technology with a Markov chain Before you implement your value function iteration

  • 8/12/2019 Computational Methods in Macro1

    115/152

    Beforeyouimplementyourvaluefunctioniteration,

    youwillhavetoapproximatetechnologywiththeMC.

    Originalmethod

    due

    to

    Tauchen (1986).

    Themorestates,themoreaccuratetheapproximation.

    Inthelimit,theapproximantcanbemadeequaltothe

    continuous

    counterpart. But,withmoreelements,themoretimeconsuming

    willbetheVFIforagivencapitalgridsize.

    Or,toholdcomputingtimeconstant,youwillhavetomake

    do

    with

    acoarser

    grid

    for

    capital.

    6.6Dynamicprogrammingsquared

    P li k d i i ti l l t

  • 8/12/2019 Computational Methods in Macro1

    116/152

    Policymakerdevisingoptimalunemployment

    compensation; agentssolvingaccept/reject

    searchproblem.

    Nestedvaluefunctions. EachagentsVFisa

    functionoftheothers.

    Theseproblemscanbesolved. LQexamplesof

    optimalpolicyinoptimisingRBC/NKmodels.

    Solved

    iteratively.

    Guess

    VF

    for

    one

    agent;

    iterateontheotheragentsBE. Thenswap.

  • 8/12/2019 Computational Methods in Macro1

    117/152

    6.6Solvinggrowthmodelusing

    Chebyshev collocationto

    solve

    the

    Bellmanequation.

    Basicstrategy

    A i t k [i thi l ]

  • 8/12/2019 Computational Methods in Macro1

    118/152

    Approximateunknown[inthiscasevalue]

    functionwithfinitecombinationofnknown

    basisfunctions,

    coefficients

    on

    which

    to

    be

    determined

    Requirethis

    approximant

    to

    satisfy

    the

    functionalequation[inthiscasetheBellman

    Equation]atnprescribedpointsofthe

    domain,known

    as

    the

    collocation

    nodes.

    Functionalequationsandcollocation:

    remarks

  • 8/12/2019 Computational Methods in Macro1

    119/152

    Vk,a maxk uc EVk,a

    Thisisafunctionalequation.Regularequationproblem givesusaknownfunction,anasksustofind

    avalue

    such

    that

    some

    condition

    is

    met,

    eg find

    x,

    such

    that

    f(x)=0

    Afunctionalequationproblemasksustofindanunknownfunction

    [hereV(.)]suchthatsomeconditionismet[herethecondition

    stipulatedintheBellmanEquation]

    Collocationhereconvertsfunctionalequationproblemintoaregular

    equationproblem.

    Fromthefunctionalequationtothe

    collocationequation

  • 8/12/2019 Computational Methods in Macro1

    120/152

    Vk j1

    n

    cjjk

    ApproximateVwiththeweightedsumofChebyshev Polynomials

    Then

    substitute

    in

    on

    both

    sides

    of

    the

    Bellman

    Equation.

    Nowwehavethecollocationequation,aregularbutnonlinearequationsystem.

    j1

    n

    cjjki maxk uk E

    j1

    ncjjk

    , i 1. . .n

    Thecollocationequation

  • 8/12/2019 Computational Methods in Macro1

    121/152

    c vc,

    ij jki

    v ic maxkK

    uki,k Ej1

    n

    cjj,kik

    Collocationequation

    Collocationmatrix

    Conditionalvaluefunction

    ataparticular

    capital

    value

    k_i

    2waystosolvethecollocation

    equation1

  • 8/12/2019 Computational Methods in Macro1

    122/152

    c 1vc

    cs1 1vcs

    cvc 0,

    cs1 cs v cs1 cs vcs

    Writeinfixedpointform,theniterate

    Or,poseasarootfindingproblem,andupdateusingNewtonsmethod.

    Herev()istheJacobian ofthevaluefunctionataparticularvaluefork

    NBthisisasystem,notjustoneequation. Oneeq foreverynode.

  • 8/12/2019 Computational Methods in Macro1

    123/152

    7.

    Heterogeneousagents

    Whyheterogeneousagentmodels

    Some RBC like models have borrowers and

  • 8/12/2019 Computational Methods in Macro1

    124/152

    SomeRBClikemodelshaveborrowersand

    lenders,consumersandentrepreneurs.

    Butmaynotbeenoughforsomeproblems.

    Cantstudydynamicsofincomeandwealth

    distribution,nor

    their

    impacts.

    Existenceofrepresentativeagentrulesout

    interestingproblemslikebehaviourviz

    uninsurableidiosyncratic

    risk.

    Heterogeneitystepbystep

    Startwithnoaggregateuncertainty,but

  • 8/12/2019 Computational Methods in Macro1

    125/152

    gg g y,uninsurableidiosyncraticrisk.

    Basicmethod

    is

    to

    takeaggregatepricesasgiven

    solveagentsdecisionproblemusingstochasticDP

    Simulateindividual

    Cs

    to

    get

    distribution

    Computeaggregatequantities

    Checktoseeifmarketclearedatassumedprices; if

    not,

    find

    price

    that

    does

    clear

    market,

    then

    repeat.

    Moveontoaggregateuncertainty.

    Choices

    Checkingmarketclearing.

  • 8/12/2019 Computational Methods in Macro1

    126/152

    g g

    Solvingindividualagentsdecisionproblem

    [wehave

    seen

    some

    of

    these]

    FiniteelementDP?

    ContinuousstateDPviacollocation?

    Computingthestationarydistributionofassetholdings

    Montecarlo simulation

    Approximatingdistributionfunction.

    Historyofmethods[tobecompleted]

    Huggett (1993)Pureexchangeeconomy;

  • 8/12/2019 Computational Methods in Macro1

    127/152

    gg ( ) g y;endowments,noproduction,noaggregate

    uncertainty.

    Idiosyncraticendowment

    risk.

    Aiyagari (1994)

    Krussell Smith(1998); aggregateuncertainty.Means

    of

    distributions

    are

    sufficient

    statistics.

    Earlyresultsonexistenceanduniquenessforsimplecases. Generallynotavailableforlater,more

    realistic

    models.

    Interestingrecentpapers

    Heathcote et al (2009); Guvenen. Surveys.

  • 8/12/2019 Computational Methods in Macro1

    128/152

    Heathcote etal(2009); Guvenen. Surveys.

    MackayandReiss(2012).Countercyclicaltax

    policyinstickypricehetagentmodel.

    Reiter (2006)Computationofhetagentmodel

    usingfunction

    approximation

    to

    model

    the

    distribution.

    Ahetagentmodel

  • 8/12/2019 Computational Methods in Macro1

    129/152

    maxE0 t0

    tuct

    uct ct

    1

    1, 0

    w tif e

    btif u

    | probt1 |t

    Pu.u Pue

    Peu Pee

    Agentsmaximisediscountedstreamof

    utilityfrom

    consumption

    Wagesifemployed,benefitsifnot.

    Employmentstatusis

    exogenous,and

    Markov,withknown

    transitionlaw

  • 8/12/2019 Computational Methods in Macro1

    130/152

    at1 1 1rtat1w tct, e 1 1rtatbtct, u

    Statecontingent

    budget

    constraint.

    Return

    on

    assets

    and

    wages

    taxed

    atratetau.

    Eulerequationforconsumption.

    u c t

    Etu

    ct1 11rt1

    Firmsandproduction

    Competitivefirmsowned

  • 8/12/2019 Computational Methods in Macro1

    131/152

    Yt FKt,Nt KtNt

    1, 0. 1

    rt NtKt

    1

    w t 1 KtNt

    byhouseholds,maximise

    profits,subjecttothis

    technology.

    Inequilibrium,

    factors

    are

    paid

    their

    marginalproducts

  • 8/12/2019 Computational Methods in Macro1

    132/152

    Objectscomprisingstaionary eqm

  • 8/12/2019 Computational Methods in Macro1

    133/152

    V,a,c,a,a ,a

    fe,a,fu,a

    w, r

    K,N,T,B

    Valueandpolicyfunctionsforagents

    Timeinvariantdensityfunctionsforemploymentstatus

    Constantfactor

    prices

    wages

    and

    interest

    rates

    Constantcapital,labourinput,taxesandbenefits

    Suchthat..

    Aggregatequantitiesobtainedby

    summing

    across

    agents

  • 8/12/2019 Computational Methods in Macro1

    134/152

    K e,u

    amin

    af,ada

    N amin

    fe,ada

    C e,u

    amin

    c,af,ada

    T wNrK

    B 1 Nb

  • 8/12/2019 Computational Methods in Macro1

    135/152

    Basicstylisedstepstocomputethe

    stationary

    distribution Computationofindividualpolicyfunctions,

  • 8/12/2019 Computational Methods in Macro1

    136/152

    givenaggregateqsandps

    Thisstep

    we

    have

    already

    done,

    2different

    ways

    Computationofdistributiongivenindividual

    policy

    functions.Thisisthenewstepthatyouhaventseen.

    Stepsfor

    computing

    the

    stationary

    eqm ofthehetagentmodelinmore

    detail

  • 8/12/2019 Computational Methods in Macro1

    137/152

    1. Compute stationary employmentN

    2. Make initial guesses at Kand

    3. Compute the factor prices wandr

    4. Compute household decision rulesc,a,a ,a

    5. ComputeFa ,stationary distribution of assets for emp and unemp

    6. ComputeKandTthat solve aggregate consistency7. Computethat balances the budget

    8. UpdateKandif necessary and go to 2.

    1. Computingstationaryemployment

  • 8/12/2019 Computational Methods in Macro1

    138/152

    t pue1Nt1 peeNt1

    Todaysemploymentisyesterdays,timesthechancethattheystayin

    employment,plus

    yesterdays

    unemployed

    times

    the

    chance

    they

    leave

    unemployment.

    GivenanyinitialN_0wecansimplyiterateonthisequationtoproduce

    thestationaryN

    WecanalsocomputestationaryNanalytically.

    5. Computingstationarydistribution

    Threemethods

  • 8/12/2019 Computational Methods in Macro1

    139/152

    Montecarlo simulationFunctionapproximation

    Discretisationofthedensityfunction

    5. Computingstationarydn using

    Monte

    Carlo

    simulation

  • 8/12/2019 Computational Methods in Macro1

    140/152

    1. Choose sample sizeN[not to be confused withNfor employment]x 10k

    2. Initialise asset holdingsa0i and employment status0

    i .

    3. Using the policy function already computed, computea i i,aifor each of theNagents.

    4. Use random number generator to draw i for each agent.

    5. Compute summary moments of distribution of asset holdings, ega,a

    6. Iterate until moments converge.

    Remarks

    Noguaranteethatconvergentsolutionexists,

    if it d th t it i i

  • 8/12/2019 Computational Methods in Macro1

    141/152

    or,ifitdoes,thatitisunique

    Noguarantee

    that

    even

    if

    you

    have

    aunique

    stationarydistribution,thatthisalgorithm,

    even

    if

    correctly

    coded,

    will

    find

    it. Muchtrialanderrorneeded!

    KrusselSmith

    Nextlogicalstepistoincludeaggregateuncertainty

  • 8/12/2019 Computational Methods in Macro1

    142/152

    uncertainty.

    Recallwe

    had

    only

    idiosyncratic

    uncertainty.

    Thisisfornexttime.

    Thatpapercontainedmethodologicalinsightthat

    agents

    could

    make

    do

    with

    just

    mean

    of

    momentsofdistributions.

    Contains

    within

    it

    the

    hint

    that

    heterogeneity

    doesntmatter.

  • 8/12/2019 Computational Methods in Macro1

    143/152

    Recapping

    on

    all

    the

    different

    methods

    Recap:

    quasilinear,

    perfect

    foresight

    methodtosolvethezerobound

    problem Guesswhenthenonlinearitystopsbinding,

    and the model is linear

  • 8/12/2019 Computational Methods in Macro1

    144/152

    andthemodelislinear.

    Solvethe

    linear

    model.

    Usethatlinearsolutiontosolvebackwardsfortheinitialperiod,whenthemodelisALSO

    linear,and

    with

    1less

    equation,

    and

    1fewer

    unknowns.

    Verifythattheguessholdsbycheckingthemax

    policy

    rule

    implies

    ZLB

    binding.

    Recap: perfectforesight,nonlinear

    Newton

    Raphson method RBCexample.

    Solveforsteadystate. Problem: tosolvefortrajectory

  • 8/12/2019 Computational Methods in Macro1

    145/152

    y j ygivensomeinitialvalue.

    Derivethe

    FOCs;

    substitute

    out

    for

    C

    using

    the

    resourceconstraint.

    Formulatesystemofnonlinearequations,oneforeach

    unknown

    period. SolveusingmultidimensionalNR.

    Linearise aroundapoint,thenfindtherootofthelinearsystem. Usethatroot[provideditfallsinthe

    domain]as

    the

    next

    point

    around

    which

    to

    approximate.

    Recap: Parameterisedexpectations

    algorithm RBCexample.

    Derive Euler equation Substitute in

  • 8/12/2019 Computational Methods in Macro1

    146/152

    DeriveEulerequation. Substitutein

    approximatefunction,

    involving

    shocks

    and

    states.

    Drawalargetimeseriesofshocks.

    Choosenew

    parameters

    in

    forecast

    function

    tominimisegapbetweensimulatedforecastsandwhatconsumptionactuallyturnsouttobe

    in

    the

    simulation.

    Recap: ProjectionusingChebyshev

    Polynomials Anotherexampleoffunctionapproximation.

    Approximate at the Chebyshev nodes gaining

  • 8/12/2019 Computational Methods in Macro1

    147/152

    ApproximateattheChebyshev nodes,gaining

    globalaccuracy

    for

    agiven

    computational

    time.

    ApproximatepolicyfunctionsusingCPs. Define

    residualfunctionusingtheEulerEquation.

    Minimisetheintegralofthisresidualfunction,

    approximatingthatwithasumofresidualsatthe

    nodes.

    Recap: deterministicdynamic

    programming FormulatetheBellmanequation: recursive

    definition of the value function

  • 8/12/2019 Computational Methods in Macro1

    148/152

    definitionofthevaluefunction.

    Magic:

    startingfrom

    any

    degenerate

    guess,

    iterateontheBellmanequationtogetthe

    solution. Discretisethestate[inthiscase,justcapital]

    space.

    Essentialwhen

    choices

    are

    discontinuous.

    Recap: stochasticdynamic

    programming

    RBC: approximatetechnologyshockwith

    finitestate Markov chain

  • 8/12/2019 Computational Methods in Macro1

    149/152

    finite stateMarkovchain.

    Nowexpectation

    of

    value

    function

    next

    period

    isprobabilityweightedsumofdifferent

    choices

    under

    the

    different

    outcomes

    for

    the

    shock.

    Recap: usingChebyshev collocationto

    solvetheBellmanequation

    ApproximatethevaluefunctionwithCP.

    Alternative to discretising the capital/shock

  • 8/12/2019 Computational Methods in Macro1

    150/152

    Alternativetodiscretisingthecapital/shock

    space.

    Recap: Aiyagari

    Guessrealinterestratethatclearsthecapital

    market.

  • 8/12/2019 Computational Methods in Macro1

    151/152

    market.

    Atthat

    real

    rate,

    solve

    the

    individuals

    problemusingdynamicprogramming.

    Sumup

    individual

    capital

    demand,

    and

    see

    whatinterestrateclearsthemarket.

    Repeatuntilconvergence.

    Recap: KrusselSmith

  • 8/12/2019 Computational Methods in Macro1

    152/152