Deep Reinforcement Learning in a Monetary Model

We propose using deep reinforcement learning to solve dynamic stochastic general equilibrium models. Agents are represented by deep artificial neural networks and learn to solve their dynamic optimisation problem by interacting with the model environment, of which they have no a priori knowledge. Deep reinforcement learning offers a flexible yet principled way to model bounded rationality within this general class of models. We apply our proposed approach to a classical model from the adaptive learning literature in macroeconomics which looks at the interaction of monetary and fiscal policy. We find that, contrary to adaptive learning, the artificially intelligent household can solve the model in all policy regimes.


Introduction
Agent expectations are central to macroeconomics. The idea of rational expectations assumes individual rationality and consistency of expectations for all the agents in the model, and when implemented numerically or econometrically, rational expectations models impute much more knowledge to the agents within the model than is possessed by an econometrician (Sargent 1993, Evans & Honkapohja 2009). While the rational expectations benchmark is a natural one to consider, the assumptions underpinning it are strong, and one may wonder if they should be relaxed (Woodford 2013).
The literature on Adaptive Learning (Sargent 1993, Evans & Honkapohja 2001, one of the leading paradigms in the learning literature and the one that we take as our starting and reference point in this paper, retains the assumption of individual rationality, while replacing the assumption of consistency of expectations with the assumption that agents form their expectations adaptively, and use recursive linear least squares as a forecasting rule. These forecasts are an input into agent's decision rules, and in each period the economy attains a temporary equilibrium. Models populated with Adaptively Learning Agents put the agents on an equal footing with the econometrician who is observing data from the model. However, this type of parametric recursive method assumes that agents correctly specify the laws of motion and other relevant functional relationships of the model. By assumption, the predictions of this econometric model need not coincide with the predictions of the true model. It is, therefore, important to correctly specify the reduced form forecasting rule such that the learning agent's expectations converge to the rational ones (in this case, an equilibrium is referred to as learnable). Moreover, economic dynamics, e.g. the stability of central bank policies such as Taylor rules or forward guidance, may be different under adaptively learning agents compared to fully rational ones (Eusepi & Preston 2018).
In this paper, we propose to combine a standard dynamic stochastic general equilibrium modeling approach with flexible expectations formation, by using modern developments in deep reinforcement learning (Mnih et al. 2015). Specifically, we work with models populated by Deep Reinforcement Learning Agents (a.k.a. Artificially Intelligent Agents) who have no a priori knowledge about the structure of the economy, and, instead, use their utility realisations in response to their actions in order to learn nonlinear decision rules via deep artificial neural networks (Goodfellow et al. 2016). Artificially Intelligent Agents can be trained to learn a good strategy to apply within an environment that is complicated (Sutton & Barto 2018). We adopted a policy-based deep reinforcement learning approach that can deal with high dimensional continuous action spaces (Haarnoja et al. 2018). Our approach enables agents to learn flexibly, as our learning algorithms are nonparametric and recursive, therefore reducing the risk of misspecification induced by the parametric approach. Allowing for misspecification and learning via expelling rational expectation agents and replacing them with "artificially intelligent" ones is also reminiscent of the paradigm of Sargent (1993) populating models with boundedly rational agents via introducing artificially intelligent agents.
Reinforcement learning is about understanding how agents learn and make optimal decisions through repeated experience (Sutton & Barto 2018). Agents strive to maximize some long-term reward, similar to the cumulated discounted sum of future utilities as in classical macroeconomic models, by interacting with a generally unknown environment. The environment in our case is the model economy. Agents obtain observations of state variables from this environment. They take actions based on these observations, e.g. how much to consume this period. They are then rewarded by the environment, which also returns a new state observation, and so on. The two main differences to adaptive learning are that agents in reinforcement learning have very limited information about the economy, and that neither their behaviour nor their expectation process is explicitly formulated. Thus, inference happens from their reward function together with the transitions generated by interacting with the environment. 1 The recent advances of deep reinforcement learning -reinforcement learning with function approximation by deep artificial neural networks -have improved the performance of traditional reinforcement learning in several very challenging domains such as computer games and simulated robotics in the computer science and machine learning community (Mnih et al. 2013(Mnih et al. , 2015. The use of deep artificial neural networks, which belongs to the class of universal function approximators (Cybenko 1989, Goodfellow et al. 2016, in reinforcement learning reduces the risk of misspecification and is, at the same time, at the forefront of advances in artificial intelligence, where agents learn to master complex dynamic environments. We contribute to the literature by showing that deep reinforcement learning can be used by economists to solve complex behavioral problems, and that this approach holds promise for modelling expectations in economic models. We start with investigating how our proposed deep reinforcement learning approach enables agents to learn "sensible" equilibria, and comparing with results from Adaptively Learning Agents. We apply our approach to a classical model from the learning literature in macroeconomics, which looks at the interaction of monetary and fiscal policy with a single representative household agent. The model considers inflation and debt dynamics under a global Taylor-rule. Given the zero lower bound on interest rates, a global Taylor-rule is known to generate two steady states of inflation steady state. One is the inflation target, while the other is a low inflation "liquidity trap", where is a continuum of perfect foresight paths that start around the inflation target and converge to the low inflation steady state. 2 Evans & Honkapohja (2005), Eusepi (2007), Evans & Honkapohja (2008) have studied the E-stability properties of these two steady states under adaptive learning, and show that the learnability of the two steady states depends on the specifications of monetary and fiscal policy.
We find that when an active fiscal or monetary policy is paired with a passive policy, i.e. active monetary policy and passive fiscal policy, or, passive monetary policy and active fiscal policy, the corresponding rational expectations equilibria are determinate, and both Adaptively Learning Agent and Artificially Intelligent Agent can learn these equilibria. However, when both monetary and fiscal policy are active (or passive), the corresponding rational expectations equilibria are explosive (or indeterminate), and contrary to the Adaptively Learning Agent, our Artificially Intelligent Agent remains capable of learning these equilibria. Our results also echo some early results in the literature comparing adaptive learning with artificial agents, e.g. learning via genetic algorithms (Arifovic 1995). The main reason why all regimes are learnable by the Artificially Intelligent Agent as compared to the Adaptively Learning Agent is that the former is not constrained by the dynamics of the linearised system, but instead by the "global 1 Reinforcement learning is related to the value function iteration procedure which has been used in the context of dynamics programming in economics.
2 More detailed discussions can be found in Benhabib et al. (2001a,b) among others.
map" given by long-term utility maximization. The more general results obtained from our Artificially Intelligent Agent also means that the economy can end up in potentially more states than previously thought.
During learning, we assess the state of learning or the state of (bounded) rationality of our agents. The Artificially Intelligent Agent's learning can generally be characterised by three phases: an initial random phase due to algorithm initialisation, followed by a learning phase, and finally the achievement of the rational expectations equilibrium, or a rational phase. We define a set of measures to quantify this process, which we label first-order condition distances and steady state distances for learning about behaviour and state values, respectively. The agent's behaviour and learned state values constitute solutions of the model during each of the three phases, though suboptimal before reaching the rational phase.
Finally, we show how the implicit expectations of the Artificially Intelligent Agent can be extracted in a small numerical experiment that looks into the process of learning about inflation expectations. Together with the proposed measures of bounded rationality, this type of analysis may help to eventually bring the proposed approaches to the data.
The remainder of this paper is structured as follows. Section 2 introduces the model. Section 3 provides introductions to both adaptive and (deep) reinforcement learning. Section 4 presents the main results. We conclude with a general discussion in Section 5. Auxiliary information is provided in the Appendix.

Model
The model closely follows Benhabib et al. (2001b) and Evans & Honkapohja (2005). Time is discrete and prices are flexible.

Household
There is a single representative household who discounts the future at a rate β ∈ (0, 1). The agent has access to fiat money and nominal government bonds. Agents seek to maximize their utility, which depends on consumption, real money balances and hours worked, subject to an inter-temporal budget constraint. Formally, the household solves the following problem max ct,mt,nt (1) where P t is the price level at time t, x t = Xt Pt , X t ∈ {M t , B t , C t , W t }. x t denote the the real levels of money, government bonds, consumption and wages. n t is the hours worked. The household pays τ t as a real lump-sum tax to the government each period.

Optimality conditions
The agent chooses sequences of money, bonds, labour supply and consumption, taking the price of goods, the real wage and nominal interest rates as given. The optimality conditions are given by where R t is the nominal interest rate on government bonds, and π t is the inflation rate at time t. We follow Evans & Honkapohja (2005) by adopting a utility function of the form 3 Combining the utility (6) and the household optimality conditions (3) -(5), we arrive the Euler equation the real money demand and the labour supply equation based on the real wage w t w t = c σ t n ϕ t .
2.3 Firms A representative firm is assumed with a production function constant in return to scale given by where ε y t is the technology which evolves exogenously with a unit mean. Each period the firm maximizes profits as the difference between production and the wage bill by setting the real wage rate, i.e. max wt y t − w t n t , yielding the optimality condition for wages 2.4 Market Clearing We assume that markets clear in every period. The market clearing conditions for the goods market is c t = y t .
The labour market clears combining (12) and (9), yielding the condition The market clearing conditions (13)-(14) together with production function (10) imply that output, consumption and labor depend on technology shock, 2.5 Government Budget Constraint and Policy Rules The government issues interestbearing bonds and non-interesting bearing currency (money), and collects taxes. It operates under the real inter-temporal government budget constraint (GBC) subject to the transversality condition Fiscal policy takes the linear tax rule as in Leeper (1991) where ε τ t is an exogenous random shock that is assumed to be i.i.d. with mean zero. We also make the natural assumption that 0 ≤ γ ≤ β −1 . We follow the terminology of Leeper (1991) to define fiscal policy as being active if γ < β −1 − 1 and passive if γ > β −1 − 1.
Monetary policy follows Benhabib et al. (2001b) and Evans & Honkapohja (2005) with a global non-linear interest rate rule The function f (π) is assumed to be non-negative and nondecreasing, while ε R t is an exogenous, i.i.d. and positive random shock with a mean of one. We adopt the notation α = f (π t ) and use the functional form where A > 1, and π * > 1 is the inflation target of the monetary authority. This specification of monetary policy implies that the nominal interest rate is strictly positive and strictly increasing in the inflation rate. We refer to monetary policy as active (passive) if the monetary authority raises the nominal interest rate by more (less) than one-for-one in response to an increase in the inflation rate, that is, if α > (<)1.

Steady State and Rational Expectations Equilibrium
The deterministic steady states in the absence of random shocks is characterised by the following set of equations: Monetary Policy: Output: Equation (21) and (23) together determine the steady state of inflation: If f (·) is continuous and differentiable as in (20), and has a steady state π * with f (π * ) > 1, in accordance with the Taylor principle given by (19), non-negativity of nominal interest rate implies the existence of a second low inflation steady state π L with f (π L ) < 1. Figure 1 illustrates this multiplicity of steady-state inflation via the intersection of the Fisher equation and monetary policy. These results are formalised by Proposition 1. [Benhabib et al. (2001b)] There exist two steady states of inflation. The first one is an inflation rate π * ≥ 1 at which the steady state Fisher equation is satisfied and at which the feedback rule is active; that is, R * = 1 β π * and f (π * ) = A β > β −1 . The second one is an inflation rate π L < π * such that the steady state Fisher equation is satisfied and the interest rate rule is passive; that is R L = 1 β π L and f (π L ) = A β ( π L π * ) Once inflation is determined, real money balances are given by (22), and real debt is determined by (24).
In the neighbourhood of either steady state, our model can be described by a linear approximation for π t and b t of the form Note that output is given by (15), which is exogenous, depending only on the technology shock. According to Blanchard & Kahn (1980), the solution to (27) is locally unique if and only if one eigenvalue is within the unit circle and the other eigenvalue is outside the unit circle. The two eigenvalues of the system (27) are given by 1 αβ and 1 1/β−γ (see the Appendix for derivation) 4 .
When there is a non-stochastic steady state, it can be shown that stochastic steady states exist their neighbourhoods if the support of the exogenous shocks is sufficiently small. Furthermore, in this case the steady state is locally determinate, provided the corresponding linearisation is determinate. Throughout the paper we assume that the shocks are small in the sense of having small support. Determinacy needs to be assessed separately for the two steady states at π * and π L . We have the following formal result: Proposition 2. [Evans & Honkapohja (2007)] In the linear system given by (27), (i) If fiscal policy is passive, |γ − β −1 | < 1, the steady state π * is locally determinate and the steady state π L is locally indeterminate. (ii) If fiscal policy is active, |γ − β −1 | > 1, the steady state π * is locally explosive and the steady state π L is locally determinate.

Learning Approaches
In this section, we first review the adaptive learning approach, one of the main learning approaches used in economics, in light of our model. We then give a general introduction to the main concepts in (deep) reinforcement learning, and to the specific learning algorithm used in this paper. We translate this algorithm to our model, and derive state transition and learning protocols tailored to the model setting. Finally, we put both learning approaches in context using the concept of generalised policy iteration, which offers a unifying framework.
3.1 Adaptive Learning Learning in (macro)economics is a way to deviate from the rational expectation hypothesis in principled ways while still adhering to general equilibrium models (Sargent 1993, Evans & Honkapohja 2001, 2009, Eusepi & Preston 2018. In this sense, learning approaches contribute the the study of the general notion of bounded rationality, which may include rational expectations as a special case. One of the main approaches in the economic learning literature is adapative learning. Private agents, households in our case, make forecasts using a reduced form econometric model of the relevant variables, and estimate the parameters of this model in a self-referential system based on past data. In each period, the economy uses the agent forecast as input and attains a temporary equilibrium which provides a new data point for the next period's forecast. This sequence of temporary equilibria may generate parameter estimates that converge to a fixed point corresponding to a rational expectation equilibrium for the economy. In this case, the rational expectations equilibrium is stable under learning, or learnable. Evans & Honkapohja (2001) have shown that there is a close connection between the possible convergence of least squares learning to a rational expectation equilibrium and a stability condition, known as E-stability, based on a mapping from a perceived law of motion (that private agents are estimating) to an implied actual law of motion generating the data under these perceptions. E-stability is defined in terms of the local stability at a rational expectations equilibrium of a differential equation based on this map.
If there are multiple rational expectations equilibria, the nature of the perceived law of motion used by the agents in forecasting, i.e. their econometric model, can determine which equilibria are learnable. This may then serve as a selection process for the study of equilibria under learning. We focus on the case in which the exogenous shocks are i.i.d. processes. The rational expectation solutions of π t and b t are just noisy steady states, i.i.d. processes. The forecasts of π e t+1 and b e t+1 do not depend on the exogenous shocks. It is now natural for private agents to forecast by simply estimating the mean values of π t and b t . It is called steady state learning. This simplifies our analysis without affecting the theoretical results.
Translating this to our model setting, agents treat (27) as the perceived law of motion, where they estimate the mean of each variable. We can express the expectations of the variables with the estimates of their means. This can be written as a simple recursive algorithms, (31) The dynamics for π t and b t under learning is then given by equations (28)-(32). According to Evans & Honkapohja (2001), the local asymptotic stability of the ordinary differential equation again with x ∈ {π, b}, provides the relevant E-stability criterion for the stochastic model, under steady state learning, when the shocks are small. Here, u denotes notional time, and F e (·) is the mapping from the perceived law of motion to the corresponding actual law of motion. Estability is determined by the Jacobian matrix of F e (·) at the steady state. This is approximated by the matrix B of (27) evaluated at the steady state. The E-stability conditions are that one eigenvalue of |B − I| have real part less than zero and the other eigenvalue bigger than zero. The formal learning results are summarised by the following.
Proposition 3. Under steady state learning, if the support of shocks are sufficiently small, we have (i) If fiscal policy is passive, |γ −β −1 | < 1, the steady state π * is locally stable under learning and the steady state π L is not locally stable under learning. (ii) If fiscal policy is active, |γ − β −1 | > 1, the steady state π * is not locally stable under learning and the steady state π L is locally stable under learning.

(Deep) reinforcement Learning
The problem of maximising the long-run reward of an agent within a modelling environment has been studied extensively in the field of reinforcement learning. The idea of reinforcement learning is to learn behavioural rules, or policies, that, depending on state observations, lead to agent actions that maximise the expected reward. 7 The full rational expectations problem can be written as E F (y t+1 , y t , y t−1 , ε t ) = 0 for endogenous state variables y t and innovations ε t . Here we make the assumption of point expectations, e.g. replacing E t c t+1 π σ t+1 with c e t+1 (π e t+1 ) σ . For stochastic shocks with small bounded support this is a reasonable approximation. Instead of relying on an analysis of the economic model, which requires extensive knowledge of the model on the part of the agents, reinforcement learning has the promise of finding model solutions with minimal, but flexible, requirements on agents' knowledge. In this section, we give a brief introduction to reinforcement learning and connect it to our model setting from Section 2. This connection has a number of features that are specific to expectational models used in economics and finance, which can be readily transferred to other model settings. A comprehensive introduction to reinforcement learning is given in Sutton & Barto (2018).

The (deep) reinforcement learning problem
An agent in a reinforcement learning setting aims to maximise its expected cumulative lifetime reward, or the expected return, that is with β ∈ (0, 1] a discount factor and the state-dependent reward r t (s) = r(s = s t ) ∈ R and s ∈ S ⊂ R ns , n s being the dimension of the state space. The agent achieves maximisation of (34) by optimising its behavioural rules, or policy, P : s t → a t ∈ A ⊂ R na (n a being the dimension of the action space) based on observed state transitions. 8 . These actions interact with the environment the agent is living in leading to the next state and returning a reward, i.e. E : (s t , a t ) → (s t+1 , r t ). This process is schematically shown in Figure 2. At each time step t, the agent observes the state s t , takes action a t , while the environment returns reward r t+1 and a new state s t+1 to the agent, which acts again, and so on. This can be formulated as a Markov decision process defined by the tupel (S, A, T , r). The transition probability T : S × A × S → [0, 1] describes the probability of the next state P r(s t+1 |s t , a t ) = F (s t+1 |s t , a t ) given the current state s t and action a t , where F (·) describes the model environment. This transition function fulfils the Markov property, i.e. it only depends on the current state and action, but not the history of state transitions.
Finding the optimal policy P * can be approached from the state-value function following a policy P where the last expression defines the action-value function, i.e. the expected return following a behavioural rule P given a state and action. The optimal policy P * maximises both state and state-actions values, which also maximises expected return -our final goal.
The state-action value function fulfils the recursive Bellman equation The current state-action value is the current reward plus the expected value of the next state. These components form the backbone of so-called actor-critic approaches, where one aims to improve the actor a t = P(s t ) which is evaluated by the critic Q(s t , a t ). That is, we will be estimating two separate quantities, P and Q, where the one can be used to evaluate the other. These can be parameterised using general function approximators in the form of artificial neural networks with internal weights φ and θ, denoted by P φ and Q θ , respectively. The use of deep artificial neural networks (Goodfellow et al. 2016) is more generally at the forefront of advances in solving complex tasks like computer vision, speech recognition or robotic navigation. Deep reinforcement learning, as used in this analysis, combines the traditional reinforcement learning approach to dynamic problems and the use of deep artificial neural networks. The general function approximator properties of the latter dramatically increase the capabilities of the former making possible recent advances, including the analysis in our study. Now, using sampled state transitions as observations, i.e. interactions of the agent and the environment, and standard optimisation techniques like stochastic gradient descent, the policy and action-value function networks can be trained by iteratively minimising the Bellman residuum, The details of how to calculate the needed gradients vary by algorithm, while the development of efficient and stable approaches to solve the above problem in different settings is the subject of ongoing research in artificial intelligence. In this paper we use the soft actor-critic approach of Haarnoja et al. (2018). 9 We have now defined the general setting in deep reinforcement learning. We next relate this setting to our model environment.

Deep reinforcement learning in the context of expectational macroeconomics
The household's problem (1) is analogous in structure to the learning agent's problem (34) when replacing the general reward with the household's utility (6).
The environment E, about which the agent is ignorant, is given by the production process (10), goods pricing (12), 10 the government budget constraint (16), market clearing (13), fiscal policy (18) and monetary policy (19). It does not include the optimality conditions (7)-(9), which the household has to learn about using deep reinforcement learning.
We can make a connection here with dynamic programming and value iteration methods which have been used in the economics literature. The difference to the current setting is that these approaches assume that the agent possesses knowledge about the model probabilities F (s t+1 |s t , a t ). In deep reinforcement learning this knowledge is mostly absent or intractable. It is part of the agent's learning task is to infer the probabilities from observations that are generated through interactions with the environment. Now, the state at time t, s t , is given by last period's money, bond holdings, inflation, consumption, and hours worked, as well as the exogenous components of this period's fiscal policy, monetary policy, and technology shocks: The state representation is not unique, 11 but it does need to fulfil the Markov property of allowing for state transitions only based on the knowledge of the current state and not past states.
The household's actions a t at each time step t are a tuple of consumption, bond saving and hours worked, denoted by where x act t , x ∈ {c, b}, represents actions with reference to last period's price level, i.e. X t /P t−1 with X t being nominal consumption or bond holdings. The state variables in (40) are now determined by the interactions of the household's actions (41) and the model environment. These actions set the level of inflation, real consumption and real bond holdings according to this period's prices, i.e.
The first relation stands for prices clearing markets (13) where the relationship between the agent's actions (here, choosing consumption with reference to last period's price level) and the price adjustment process between different periods has been made explicit. This mechanism respects the information flow in the model, with price inflation relating real quantities between 10 The prices of goods are assumed to be set optimally by the firm. This could be relaxed by extending the current setting to a multi-agent problem, where the firm would have to learn about its pricing strategy. Multiagent learning problems are considerably more complex than single-agent problems and we leave this setting for future work.
11 Inflation can be replaced by the gross interest rate set by the monetary authority according to (19).
periods. The agent observes the state with reference to past period's price level P t−1 and takes its actions accordingly. This period's price level P t is then set via the market clearing condition (42), determining this period's inflation π t . This mechanism incorporates the dynamics of nonstationary nominal quantities within a stationary real setting, which is particular to economics settings. That considerably simplifies the learning process, because learning a non-stationary environments is considerably more challenging.
Learning happens in episodes. Each episode is initiated with a random state drawn uniformly from a region of interest in the state space. Subsequently, iterations between agent actions and the environment result in state transitions. The agent's parameters, Q θ and P φ , are updated between such steps. An episode ends when a termination criterion is reached. This is in our case, either a maximal number of steps N max epi or an improvement in agent utility below a fixed small threshold d min u . The rationale for using an episodic termination criterion is that this allows the agent to experience more regions of the state space during learning, and this this is coupled to learning progress in the case of d min u . 12 Training/learning: Parameter updates and explorative actions characterise the training or learning of the agent. Explorative actions are actions which are not optimal according to the currently learned behavioural policy, but have noise components to them. This is a crucial part in deep reinforcement learning, as it allows the agent to discover new and ultimately better actions. The magnitude of the random component in actions characterises the exploration-exploitation trade-off in deep reinforcement learning. Set too small or large, the agent will fail to effectively learn.
Our action space is continuous, and exploration is achieved by drawing from a normal distribution generated from P φ (s t ). 13 That is, most actions will be close to the current best action, the mean of this action distribution, while deviations from this mean explore the action space. If such actions turn out to be beneficial, i.e. return higher utility to the household given the current state, the action network P φ will move into this direction during learning.
For updates of the parameter in (P φ , Q θ ), the agent draws randomly from a fixed-size memory of experience consisting of N mem past state transitions, e.g. to perform stochastic gradient descent. 14 The overall training phase is set to last for a maximal number of steps N train , i.e. the number of parameter updates by which we expect the agent to solve its optimisation problem. In the current setting, we consider the agent's problems as solved if the household finds action values corresponding to one of the steady states of our model, and if episodes terminate in such a state.
Testing: The evaluation of learning goals, such as the distance to a steady state in the state space, happens during testing. Testing consists of a set number of test episodes N test that the agent runs through between a fixed number of training steps N interval N train . 15 12 The learning problem can alternatively be formulated without the termination criterion on d min u as the learning task is open-ended.
The full training-cum-test setting is summarised in Algorithm 1. The initial N burn steps of pure random actions serve as a burn-in phase to give the agent some orientation before exploration starts. We save all test transitions, as well as the agent parameters (P φ , Q θ ) at different stages of learning. This allows ex-post experimentation, the reproduction of test results, or the the flexible adjustment of the learning setting.
Algorithm 1 Training and testing protocol of household agent Initialise: Environment E (parameterised model), agent (parameterised by P φ , Q θ ) for steps = 1 to N train do initialise training episode with random state s t while training episode is not done do if steps ≤ N burn then Take allowed random action a t else Draw exploration action a t = P exp φ (s t ) end if Environment returns (r t , s t+1 ) = E(s t , a t ) Add transition (s t , a t , r t , s t+1 ) to memory Update P φ , Q θ using batch gradient descent from memory if mod ( We still need to define the state transition of a single (testing) step (* in Algorithm 1) which also includes the economics of the household's learning problem.
Step sequence (*) for single transition: s t → s t+1 1. Observe state s t 2. Take actions P φ (s t ) = a t = (b act t , c act t , n t ) [P exp φ is used during training for exploration] 3. Production y t takes place according to (10) and firm sets wages using (12) 4. Markets clear: Inflation π t is set by (42) number of training episodes is that the length of an episodes during training or testing is stochastic and may also change during learning, such that a number of steps allows us to measure the agent's learning progress uniformly.
5. This determines real consumption c t and real bond holdings b t according to (43)- (44) 6. Policy realisations: • The monetary authority sets the current gross interest rate R t based on π t via the Taylor rule (19) • The government raises taxes τ t (18) 7. The money holdings m t are realised from the GBC (16) 8. Agent obtains reward r t = U (c t , m t , n t ) 9. Next periods shocks are realised, ( τ t+1 , R t+1 , y t+1 ) Looking at the learning algorithm and state transition, the state representation (40) can be roughly partitioned into three groups of variables, those used for state transitions (b t−1 , π t−1 ), the evaluation of convergence (c t−1 , n t−1 , m t−1 ), and observed shocks ( τ t , R t , y t ). The first and the last group are needed for non-terminal state transitions. The second group, together with last period's money holdings m t−1 , is used to evaluate the termination criterion if an episode will be terminated and a new one initiated if d u ≡ |U t − U t−1 | < d min u . 16 The higher the threshold d min u is, the more episodes the agent will go through during training, thus exploring more of the state space, with a smaller chance of getting stuck during learning. However, too high a value will lead to imprecision as episodes terminate before the agent reached sufficient precision in its actions potentially ending up far from a steady state value.

Generalised Policy Iteration
Our two learning approaches, adaptive learning and deep reinforcement learning, can be conceptually compared from the point of view of generalised policy iteration (GPI). In GPI, policy evaluation, which delivers the value of a state given a policy, and policy improvement, which delivers the change of behaviour to attain higher returns, interact iteratively (Sutton & Barto 2018). This is depicted in Figure 3. Under the (nontrivial) assumption that learning converges, this process results in a fixed point of optimal policy P * (s) and maximal-return state values V P * (s). Both together specify the rational expectations equilibrium in our model. As long as the agent has not converged to this point, it is called boundedly rational.
In our modelling environment, optimal behaviour is given by the household first-order conditions (FOC) (3)-(5), while (locally) optimal state values are the two steady states corresponding to π * and π L . Adaptive learning fixes the agent's behaviour by using these FOC within the system equations (29)-(31). This can be thought of as a horizontal policy line in Figure 3. The state equations (28) describe state values, and converge according to Proposition 3. The difference between adaptive learning and deep reinforcement learning is that the latter does not fix behaviour, but both the agent policy P and the corresponding state-action values Q are learned simultaneously. The GPI framework will be useful to understand and quantify learning behaviour. 17 17 GPI can also be used describe Euler learning in macroeconomics where the behavioural rules differ from the FOC (see e.g. Eusepi & Preston (2018) for a brief discussion). In a nutshell, it may be less desirable from the GPI perspective as convergence cannot happen if the behavioural rules are not flexible enough to converge to the FOC.

Learning results
We analyse household learning within the deep reinforcement learning framework and the model presented in Section (2). The main parameterisation used in our analysis is given in Table 1. The motivation for these choices is a trade-off between clarity of presentation and realism within our arguably simple model. Table 1 reports the calibration. We take the model's frequency to be quarterly 18 and set β = 0.99 which implies a steady state real interest rate of about 4 percent; ϕ = 1, implying a unitary Frisch elasticity of labor supply; σ = 3, which is within the range of 1 to 3.5 in the literature; χ = 0.1, following Evans & Honkapohja (2005). The Taylor rule coefficient A = 1.3 gives two steady states of inflation, one is π * = 1.01 (4% net per annum), the other one is π L = 1.0014 (liquidity trap).
parameter value description β 0.9900 discount factor σ 3.0000 inverse of intertemporal elasticity of consumption and money holdings η 0.001 production scaling factor ϕ 1.0000 inverse of Frisch elasticity of labor supply χ 0.1000 relative preference weight of money holdings γ P 0.0200 passive fiscal policy (PFP) coefficient γ A 0.0000 active fiscal policy (AFP) coefficient A 1.3000 Taylor rule coefficient π * 1.0100 target gross high-inflation rate (4% net per annum) π L 1.0014 implied gross low-inflation steady state (see Figure 1)  Table 1: Baseline model parameterisation. The shock series τ t , R t , y t follow log-normal, normal and normal distributions, with means of one, zero and one, respectively.
Steady state values for high and low inflation, as well as for passive and active policy, are given in Table 2. For better comparability of regimes, the fiscal policy intercept γ 0 is calibrated such that bond holdings equal annualised output for each policy combination. This does not affect the local stability properties of the model or the learning dynamics of the agent. Steady state money holdings are between 40-50% of output which is about double the amount of the long-term average of narrow money holdings (M1 in the US) and half the amount of broad money (M3 in the US). While strictly speaking our model only talks to narrow money, extension with a financial sector would represent broader aggregates. Annualised net target inflation of 4% is well above the mandate or recent experience in most advanced economies but well within those of emerging markets. Note that money holdings and household utility are generally higher in the low-inflation steady state π L with passive monetary policy.  Table 2 is determined via the eigenvalues of matrix B in (27) and described in Proposition 2. This is graphically summarised in Figure 4 for the parameterisation in Table 1. The horizontal axis shows the fiscal response parameter γ and the vertical axis inflation. For monetary policy, the two steady steady inflation values correspond to the intersections in Figure 1, which are indicated by the horizontally dashed lines. They mark the active and passive monetary policy regimes at π * (AMP) and π L (PMP), respectively. For fiscal policy, the centre vertical grey line marks the boundary between passive and active fiscal policy. Passive and active fiscal policy as used in our analysis, are marked by the vertical red lines at γ P = 0.02 (PFP) and γ A = 0 (AFP), respectively. The cross of solid grey lines separate the four policy regimes. In the adaptive learning literature the learnability criterion from Proposition 2 is used as a selection criterion for policy regimes. The determinate regimes (AMP-PFP and PMP-AFP) are learnable while the explosive (AMP-AFP) and indeterminate (PMP-PFP) regimes are not. We now investigate which of these policy regimes are learnable by deep reinforcement learning.

Deep reinforcement learning
While there exists a correspondence between the dynamic stability of non-linear maps and local linear approximations, there is no such general relation for deep reinforcement learning problems. Hence, learnability is an empirical question, which we address via numerical simulations. In each of our experiments, we define a region of interest in the household's action space and the state space around either the low or high inflation steady state according to the policy regime of interest. We follow the learning protocol described in Algorithm 1. Details of the actions, states and settings of the learning algorithm following (Haarnoja et al. 2018) are listed in  Table 3: Comparison of learnability of different policy regimes for adaptive learning (AL) and deep reinforcement learning (DRL): active/passive monetary policy (AMP/PMP at π * /π L ) and passive/active fiscal policy (PFP/AFP). ∆ ss and |∆ ss | measure the mean and mean absolute difference in percentage from their respective steady state values for the end of test episodes during the last 5e5 steps of DRL training. The numbers of inflation refer to difference to net inflation, i.e. 1 and 0.14 for π * and π L , respectively. † indicates that action values are mostly learned well, but with some discrepancy in the learning of steady state money holdings. Source: Authors' calculations.
AMP-PFP regime: This is the classically considered policy regime of monetary dominance around the target inflation level π * . All results we present in the following are taken from test episodes between learning intervals. We focus on the end of these episodes, that is, the final action and state values of each test episode to assess the state of convergence of the household's behaviour and how it compares with steady state values.
The convergence of household actions during learning to their respective steady state values is shown in Figure 5. Consumption choices are implied by inflation via the market clearing condition (13). The vertical axis shows the distance to steady state values relative to the maximal test distance observed. This normalisation allows for the uniform comparison of learning behaviour for different actions as their numerical scales differ. All lines are moving averages over 25 learning intervals and test cycles. To account for volatility in learning outcomes, e.g. due to the randomisation of episodes' initial states and differences in convergence, 95% confidence intervals are indicated by the shaded areas. 19 Despite having no shocks in the model, the finite confidence intervals come from the random initialisation of test episodes which lead to slightly different end points. These are distributed around the steady state values of the model in the rational phase.
We see that households learn the optimal steady state solution well, with all actions converging synchronously, and that actions subsequently stay at this point. The initial increase in the learning distance is due to the 'breaking of randomness' at the beginning of learning. This randomness comes form the random initiations of neural network weights. Initial random behaviour can on average be close to steady state values, because experiences are sampled uniformly around them, such that errors cancel each other out. However, we expect a large variance in outcomes during this initial random phase, which is indeed the case as can be seen from the wide confidence intervals at the beginning of learning. In summary, we can divide the learning process into three phases, an initial random phase, an intermittent learning phase and a terminal rational phase. This final phase means that the household has learned the rational expectation solution, which we will quantify in more detail below.
We report learning behaviour on this normalised scale, because absolute deviations from steady state values depend on several factors of both the learning algorithm and model parameterisation. However, their magnitudes may nevertheless be instructive, as we see the maximal distance an agents behaviour deviates from the optimal during learning conditioned on the settings of the experiment. The peak distances at the transition to the learning phase in Figure  5 for net inflation, bond holdings and hours worked are (11.07%/11.07%), (0.60%/29.92%) and (0.14%/7.12%), respective. The first number refers the distance to the steady state value and the second compares this distance to corresponding action range in Table A.1. We will look at the interpretation of these number in more detail when discussion inflation expectations in more detail below.
All policy regimes: The learning results are summarised in Figure 6 and Table 3 (the learning of money holdings is shown separately in Figure A.1 in the Appendix). The learning behaviour is qualitatively the same for all policy regimes. We conclude that all regimes are learnable by deep reinforcement learning unlike to adaptive learning. This means that the local linear dynamic properties of the model around a steady state are not necessarily a selection criterion if this state can be attained by the agent. The reason for this is that the household under deep reinforcement learning is not bound by the dynamics of the linearised system, but instead by the "global map" given by long-term utility maximisation. In the linear system wandering off the optimal path may lead to unstable (learning) dynamics, while in deep reinforcement learning such an action may just be identified as an action improvement rewarded by higher utility. Economically, this means that all policy regimes can become entrenched if the household spends enough time close to the corresponding steady state. More generally, this shows that deep reinforcement learning is a "global" solution technique, as it is capable of retrieving multiple steady state solutions without the need to specify a localised approximation.
However, there are also differences in deep reinforcement learning outcomes between the different policy regimes. These are again not related to the dynamic properties of the linearised system but rather to the state of monetary policy. The regimes of passive monetary policy, i.e. where the slope of the Taylor rule (19) is smaller than π/β, requires more time to be learned with less precision. This is especially the case with passive fiscal policy, where convergence takes considerably more observations, and is more noisy.
The details are instructive from an economic and methodological perspective. Table 3 shows that the imprecision in learning is related to the monetary policy regime. Most of the deviation from steady state values stems from inflation, and to a lesser degree from bond holdings. 20 This translates into larger average deviations of money holdings in the PMP regime, as shown in Figure A.1 in the Appendix. This can be related to the general characteristics of the learning problem and aspects of deep reinforcement learning. The Taylor rule provides less feedback for low inflation values, and the household's utility function is relatively flat with respect to money holdings at the steady state values. This matters because episodes terminate when absolute changes in utility fall below the threshold d min u . This contributes to less precise learning of the low-inflation steady state in the current setting. This discrepancy is small in inflation terms 21 but gets amplified in the volatility of money holdings in the low-inflation steady state. Finally, steady state utility values in Table 3 are also close to the long-run optima with mean deviation well below 1% in all regimes. We next investigate in more detail the learning agent's actions going beyond mere convergence to steady state values. 4.2 Measuring bounded rationality Household optimal or rational behaviour under deep reinforcement learning is taken to mean that the agent follows an Euler path, i.e. that its actions are in line with the first-order conditions (FOC) from Eq. 7-9, and that it has learned about the steady state values of the model. The deep reinforcement learning agent does not know about either on the onset of learning but rather has to infer them to solve its reward maximisation problem. Hence, the FOC together with the household's actions and the realised values of state variables allow us to gauge the rationality of the agent at different stages of learning. We define the FOC-distance as which allows us to evaluate deviations in a standardised way. A value of zero implies that the agent is on an Euler path, fulfilling its first order conditions. The explicit expression for the Euler equation (7), which we call the Euler distance, is We test FOC-learning by focusing again on the common AMP-PFP regime. Eq. 7-9 are evaluated analogously to the previous section by looking at the final transitions of each test episode at different stages of learning. Deep reinforcement learning does not provide us with explicit expectations. Instead, expected values in (46) are taken to be next-period realised values. That is, the agent's expectations are interpreted consistent with its actions, which is a simple form of self-fulling expectations.
Normalised FOC-learning curves are shown in Figure 7 for the Euler equation, money demand and labour supply. These are very similar to the convergence of household actions in Figure 5. The three learning phases can be clearly identified and coincide with convergence to the steady state values. This is in line with the GPI framework from Section 3.2.3. There is a joint convergence of behaviour (FOC) and state learning. This means that the state values of Figures  5 and 6 are the corresponding equivalents of Eq. 45 in the state space. Convergence in both corresponds to the rational expectation equilibrium. This also means that more generally, Eq. 45 in either the action or state space quantify bounded rationality in this class of models. For instance, maximal distances in Figure 7 correspond to random actions, while zero distances imply compliance with the FOC and convergence to a steady state equilibrium.
In adaptive learning, FOC-distances are zero by construction. However, bounded rationality can still be assessed within the same framework by looking at state convergence in Eq. 28, provided Proposition 3 holds. The FOC-learning curves for all policy regimes are given in Figure  A.2 in the Appendix. These again converge to zero, or very close to zero within confidence bounds, in all four cases. The small discrepancies from steady state actions values are reflected in non-zero FOC-distances as suggested by GPI. Contrary to the learning of steady state actions, FOC-distances may converge partly asynchronously. However, we always observe the three phases of learning, and full convergence of all quantities coincides between state and action learning. We next look into how these learning dynamics can be used to arrive at testable results. 4.3 Agent behaviour as a model parameter One of the contributions of this study is the development of tools to quantify bounded rationality. The FOC-distances (45) do this by measuring the difference in household behaviour through the choice of consumption, bond savings and hours worked compared to optimal value during learning. The basic idea is that the agent solves the model at any stage or learning, being 'more or less rational.' Working with such an agent, one needs to determine the state of learning. Some evaluation criterion will be used for this, e.g. like FOC-distances or a calibration to data, such that the state of learning is a free parameter.
Questions of interest are how to interpret these learning results, and, relatedly, how these can be brought to the data? The representative agent setting, and the fact that learning quantities themselves, like the steps to convergence, or the maximal FOC-distances during learning, depend on a variety of parameters of the model and learning algorithm, make the interpretation of results more difficult. This is even more so when we want to connect the learning setting to the real world. One possibility of interpretation is to interpret the state of learning, as expressed through steady state or FOC-distances, as the collective state of the population of agents in the economy represented by the agent at different stages of learning. The learning curves shown before offer devices to assess this state during learning. This allows to interpret learning results detached from the parameters of the model or learning algorithms used.
We demonstrate how such an approach can be used to address agent behaviour in the context of inflation expectations. Using the Euler distance, we run an experiment to investigate the relationship between the current interest rate R t and next-period inflation π t+1 as determined by the household's consumption choice. The agent behaves consistently with its own model P φ based on the current state, so next-period inflation is equated with E t [π t+1 ]. We fix the household's real consumption schedule at its optimal value, i.e. c t = c t+1 = c ss . This is achieved by setting n t = n ss at all times, which fixes c t through the clearing of the goods market. That is, we isolate the learned relation between inflation and interest rates by fixing other actions at their optimal values. The Euler equation (7) then simplifies to the Fisher equation, i.e. a simple relation between this period's interest rate and next period's inflation, We next take the household agent at each test stage of learning 22 and rerun all test cycles with hours fixed as described above recording all state transitions. The results of this exercise are depicted in Figure 8. Both axes show net inflation expectations, the horizontal axis the ones implied by the current rate of interest R t and the Fisher equation (47), and the vertical axis the actual agent expectations measured through the household's consumption choices. The dotted diagonal line describes rational behaviour, i.e. following FOC, again the Fisher equation. The household's actual actions during each test transition are given by the scatter points at different times of learning as indicated by the colour coding. The agent's learning curve is traced out by the dashed line. The vertical distance between this line and the diagonal measures the average deviation of expectations from the rational expectation equilibrium alongside this dimension, that is, bounded rationality.
We can draw the following conclusions from this experiment. The household's initial inflation expectations deviate about 5-7% from optimal expectations (random phase, purple dots). During learning the household's expectations and actions converge to the optimal values, i.e. the vertical distance between the two lines narrow (learning phase, blue dots). Eventually, agent actions coincide with the Fisher equation (rational phase, yellow dots).
This experiment shows how we can arrive at tangible, i.e. testable, propositions from the deep reinforcement learning framework. This type of analysis could now be used to bring a model to the data by quantifying real-world agents' state of learning or their bounded rationality. FOCdistances could be estimated from suitable datasets, and agents at the corresponding learning stage could then be used for further analyses, like counterfactual experiments and their outcomes be compared to the conventional case of fully rational agents. We leave this to future work.

Learning under uncertainty
The analyses so far have not taken uncertainty into account. However, it is an interesting question whether shocks to monetary or fiscal policy, or to the labour supply, affect the household agent's ability to learn in deep reinforcement learning, and if so, whether there are differences in outcomes. We repeat the experiments from Section 4.1 for the AMP-PFP and the PMP-AFP regimes, with the shock sizes for both scenarios given in Table 1. These are comparably small for the active policy regime but large relative to steady state net inflation in the low-inflation state. The agent again follows the learning protocol in Algorithm 1, with the difference that now shocks are realised at each state transition, and that shocks enter the state observations. 23 The results for these experiments are summarised in Figure 9, where we again look at endof-episode transitions during testing. 24 Convergence again means actions and FOC-distances are in line with those for the cases without shocks and converge to the rational expectation equilibrium. The only difference in learning is that the confidence intervals are generally wider. This is expected in the presence of external random fluctuations of state variables. Thus, the presence of shocks does generally not inhibit learning.
An interesting aspect of learning in the presence of shocks is that solutions correspond to stochastic steady states, which are generally hard to assess.

Learning challenges
Despite the general learnability results we presented, there are significant challenges to the application of deep reinforcement learning. The sensitivity to hyperparameter choices, or brittleness of deep and, in particular, deep reinforcement learning is known in the literature (Haarnoja et al. 2018, Heaven 2019. Some of this also affects our analysis. We discuss the main learning parameters relevant to the present analysis, that is, those factors which lie at the intersection between learning and the economic model setting, and that have a significant effect on the learning outcome. The aim of this is to lay out challenges for future research on the one hand, and, on the other, to facilitate the adaptation of deep reinforcement learning to economics and finance problem more generally.
Three hyperparameters relevant to our learning results are the speed of learning, action and state bounds, and episodic termination criteria: 4.5.1 The speed of learning This is controlled by the learning rate α learn which sets the step size by which the parameters in the agents functions P φ and Q θ are updated during learning. 25 The larger its values, the faster the agent learns, and the less steps it will need to converge. So, ideally α learn is chosen as large as possible. However, too large a value destabilises learning, leading either to explosive or stagnant behaviour. Our baseline value α learn = 10 −5 is relatively small. However, larger values led to unstable learning and breakdown of the optimisation algorithm, highlighting the challenges of our learning problem.

Agent experience
Ideally one would offer a learning agent the full state space to learn from. Unfortunately, this is quite challenging given the current setting and will likely lead to a failure to learn. For instance, the agent may end up converging to a mid-point between the two inflation steady states. In the current setting, learning outcomes are often best if the agent's action space is centred around one of the two steady states. This can be seen in Figure 10, which shows convergence to steady state action values in the PMP-AFP regime. Convergence is improved relative to the non-centred case in the lower right of Figure 6. Note, however, that comparable improvement is not seen for the PMP-PFP regime, such that this is not a universal remedy to convergence issues. This is not the only parameter to improve learning in this regime.

Episode termination
A feature of our learning problem is that optimal solutions are steady states, i.e. points in the action, state and utility space which map into themselves. This is accounted for by the episodic termination criterion using d min u in our setting. This does not contain direct information about where the optimal solution of the household's problem lies. A large value of d min u lets the agent have more experience as episodes terminate and restart after fewer steps. However, this may lead to decreased learning precision around steady states. On the other hand, a small value increases precision, but offers less experience to the agents as episodes take more steps and the agents potentially spends more time in 'uninteresting' regions of the state space. The effect of increased precision on action convergence in the PMP-AFP regime is show on the RHS of Figure 10. Here, d min u has been set to 1e-9 instead of 1e-7. 26 Convergence again improves compared to the baseline.

Conclusion
We propose the use of deep reinforcement learning to solve dynamic models commonly used in economic analysis, particularly DSGE models. Here, agents are capable of solving the model based only on state transitions, knowing their preferences in the form of a reward function, but not knowing any other part of the structure of the model economy. We apply deep reinforcement learning to a monetary model with a representative household agent. The salient feature of this model, which is commonly used in the learning literature, is the existence of two steady states, where one of them may be interpreted as a liquidity trap with lower inflation and higher money holdings. The interaction between monetary and fiscal policy regimes defines the learnability of solutions in well known adaptive learning approaches, where this then serves as a selection criterion for the study and plausibility of a regime. By contrast, the deep reinforcement learning agent recovers all possible steady state solutions under the different policy regimes. Given that this learning behaviour is more general, as seen through the lens of generalised policy iteration, this widens the scope of solutions of interest, irrespective of their local dynamics. This is achieved by the "global" nature of deep reinforcement learning without the need of a local model approximation. Agents' learning and behaviour is ultimately determined by the long-run reward subject to constraints. In our case this consists of household utility subject to the standard inter-temporal accounting constraint.
Conceptually, deep reinforcement learning allows us to define and measure bounded rationality on a continuous spectrum of agent behaviour, which is limited by the rational expectations 26 A technical aspect to consider when setting a low d min u is potentially increased memory need if episodic transitions are saved during training or testing. equilibrium as the learning goal. In other words, agent behaviour becomes a free parameter of the model. We proposed measures and procedures to assess this. These can be used in either computational exercises or to quantify real-world agent behaviour. For instance, the spectrum of learning given by state value or first-order learning curves, can be used to calibrate agent behaviour.
However, the deep reinforcement learning approach is not without challenges. Learning approaches based on deep artificial neural networks can be brittle and sensitive to parameter choices. We discussed some of the choices, like the learning rate, action and state space bounds or episodic termination criteria. Furthermore, we only considered the single-agent case in this study while it is known that multi-agent settings can be considerably more difficult to handle with these techniques. Deep reinforcement learning also requires substantial computational resources and specialised programming skills.
However, agent behaviour is one of the most contentious parts of modern economic theory and analysis. This criticism goes beyond the DSGE plus rational expectations modelling paradigm discussed here. Deep reinforcement learning, on the other hand, is a general purpose technology and can be applied to a wide range of problems. The only requirement is that these problems can be moulded into its fairly general structure. As such, we believe that deep reinforcement learning offers a flexible and potentially highly useful tool to address major conceptual and practical concerns, and to interlink different approaches within a rich research agenda.

A Technical Appendix
A.1 Derivation of (A.6) In an neighbourhood of a non-stochastic steady state π and c, we can derive a linear approximation Note thatx t denotes the deviation of variable x t from steady state. We now consider determinacy of the linearized system. We can rewrite (A.1)-(A.5) as a bivariate forward-looking system of the form According to Blanchard & Kahn (1980), the solution to (A.6) is locally unique if and only if one eigenvalue is within the unit circle and the other eigenvalue is outside the unit circle. To assess this we bring the above expressions into an explicit form,    Haarnoja et al. (2018) for active monetary policy (AMP) around π * and passive monetary policy (PMP) around π L . Action bounds refer to the minimal and maximal actions the agent can choose from. Initial state bounds refer to the min./max. values of initial state variables episodes can be sampled from. Learning algorithm parameters relate to parts of the agent's optimisation process which are not directly related to economic quantities (state variables). Additional learning parameters are the number of policy P φ and critique Q θ updates per step (1), and the use of automatic entropy tuning (true).