Optimal stopping time, consumption, labour, and portfolio decision for a pension scheme

In this work we solve in a closed form the problem of an agent who wants to optimise the inter-temporal recursive utility of both his consumption and leisure by choosing: (1) the optimal inter-temporal consumption, (2) the optimal inter-temporal labour supply, (3) the optimal share of wealth to invest in a risky asset, and (4) the optimal retirement age. The wage of the agent is assumed to be stochastic and correlated with the risky asset on the financial market. The problem is split into two sub-problems: the optimal consumption, labour, and portfolio problem is solved first, and then the optimal stopping time is approached. We compute the solution through both the so-called martingale approach and the solution of the Hamilton–Jacobi–Bellman partial differential equation. In the numerical simulations we compare two cases, with and without the opportunity, for the agent, to work after retirement, at a lower wage rate.

''European pension systems are facing the dual challenge of remaining financially sustainable and being able to provide Europeans with an adequate income in retirement'' (European Commission 2017). Actually, life expectancy after the age of 70 has been constantly increasing over the last decades, generating the socalled ''longevity risk'' (European Commission 2018a). Thus, without a counterbalance increase in the retirement age, the level of contributions paid by the workers, could not be able to suitably finance the pensions that will have to be paid for increasingly longer period of time.
Combined to this, the calculation of the optimal retirement age plays a crucial role (Farhi and Panageas 2007). Let us assume a worker that must decide the level of consumption for the coming years including the retirement period, given his level of wealth. This agent would be exposed to both market risks and mortality risk. In this work we study the problem of such an agent whose wage, investment opportunities, and death are all stochastic. We show that a part of the optimal strategy for the agent is to invest in a life annuity and to borrow against his human capital.
It is well known that social security wealth, 2 which typically constitutes the biggest share of a retiree's wealth, comes in an annuitised form. In some countries, annuity markets are growing, especially in UK where pension schemes have transferred £135bn of liabilities to insurers over the last decade, and this is set to quadruple over the next 10 years, 3 while in the US the annuity market is around 234 billion dollars. 4 In this work we do not take into account any pension scheme. Instead, we investigate the choice of an agent who can only rely on both his wage and his financial investments. Actually, in some countries, future retirees will have to rely less on social security schemes and more on funded pension plans (Feldstein and Siebert 2002;Diamond and Orszag 2005;Rusconi 2008), which mostly leave to each individual the choice between annuitising and cashing-out pension wealth at retirement.
There exists a wide literature about optimal investment in financial market and annuitisation, and it mainly refers to life cycle frameworks with uncertainty. Benitez-Silva (2000) presents a dynamic model of labour/leisure, consumption/ saving, considering additional sources of uncertainty, introducing annuities and Social Security, and providing a general framework which allows for policy experimentation in a life cycle model. Friedman and Warshawsky (1990), focus on annuity pricing in order to explain the almost nonexistence of a market for these instruments and do not consider investment uncertainty. Longevity uncertainty and purchase of annuities is taken into account in Brugiavini (1993) in a two/three period model with different behaviour of employees and entrepreneurs. Mitchell et al. (1999) calculate the expected present value of the annuities by using the term structure of interest rate rather than a fixed interest rate, and they find that retirees should value annuities even if they are not actuarially fair. Brown (1999a, b), introduce uncertainty and use data on older Americans to construct a measure of the consumer's valuation of additional annuitisation and to test the hypothesis that old individuals purchase term insurance to offset the excessive annuitisation imposed by the government social programs. Kotlikoff and Spivak (1981) study the role of the family as an incomplete annuities market, with the annuity decision made at exogenous points in time. Eichenbaum and Peled (1987) analyse the over accumulation of private capital in a two period model of competitive annuities with adverse selection. Recently, Menoncin and Regis (2017) found that individuals should optimally invest a large fraction of their wealth in longevity linked assets in the pre-retirement phase, because of their need to hedge against stochastic fluctuations in their remaining lifetime at retirement. In a two period framework, Magnani (2020) studies the optimal retirement problem for an agent who can also chose how to save from his/her (risky) salary.
In line with the previous statements, in this paper we solve the problem of a representative agent who must decide, at the same time: (1) how much to work, (2) how much to invest on financial market, (3) how much to consume, and (4) when to retire. The agent's time horizon coincides with his death time and the optimisation problem is subject to some risks: (1) the market risk on the financial market (mainly price risk), (2) the mortality risk on agent's lifetime, and (3) the wage risk on agent's wealth.
We model the risk through a Wiener process and we solve the problem to maximise the expected utility of agent's inter-temporal consumption and leisure (defined as nonworking hours). After retirement, we assume the agent is still able to work, but he will receive a fraction of the wage. Of course, the agent must finance his consumption over his whole life time. The utility of leisure is assumed to be proportional to agent's received wage and, accordingly, reduces after retirement. Here, we define the human capital as the total expected discount value of future wages.
This work builds on the same framework studied in Menoncin (2008) and Menoncin and Regis (2017). In both these papers, a longevity linked security is listed on a complete arbitrage-free financial market, but the retirement age is compulsory. Instead, here we take into account only the mortality risk, but we solve the problem of the optimal retirement age. We use a two step approach: first we find the optimal consumption, labour supply, and portfolio for any possible (stochastic) stopping time, then we compute the optimal stopping time by maximising the value function that solves the first problem. We solve the problem by using both the socalled martingale approach and the Hamilton-Jacobi-Bellman partial differential equation.
The framework of an optimal stopping time problem is often applied to the real options, 5 when an irrevocable decision must be taken. Actually, also in this case, the decision to retire cannot be called off and it permanently affects the dynamics of agent's problem. Bodie et al. (1992) suggested that ''one current research objective is to analyse the retirement problem as an optimal stopping problem and to evaluate the accompanying portfolio effects''. Also Kula (2003) wrote that ''the retirement decision may be treated as an investment process: first we collect capital/retirement wealth, and if we have accumulated enough we invest/retire, depending on the actual and expected prices/wages' '. Finally, Farhi andPanageas (2007) extended Bodie et al. (1992) in a optimal stopping problem, also focusing on the ''importance of the real option to retire for portfolio choice''.
In solving our problem we must assume that the market is complete. This means that the agent is able to borrow against his future wages (human capital) and any risk on the financial market can be perfectly hedged through a suitable portfolio.
When we turn to the second problem, that is the optimal stopping problem, we are able to find a closed form solution only if we assume that the inter-temporal preference parameter coincides with the risk aversion parameter. Under this hypothesis, the value function of the second problem can be written in closed form as a function of a wage threshold. When this threshold is crossed, then the agent finds it optimal to retire.
Finally, we calibrate our model to the US data and we present some numerical results that allow to investigate the dynamic behaviour of the optimal consumption, labour supply, and portfolio.
In the simulations we study two cases: (A) when the agent is not allowed to work any longer after retirement and so his salary immediately drops to zero, and (B) when the agent is still allowed to work but at a reduced salary (one third of the original salary).
We show that the optimal retirement should happen after about 50 years of working (on average) in case A and 35 years in case B. If we assume that an agent begins working when he is about 25, this choice implies a retirement age that is close to the statutory value in case A, but which is much lower than the statutory age in case B. The optimal labour supply is of course higher in case A then in case B, while in case B it remains positive even for a very old age.
Furthermore, we show that cases A and B differ a lot also for the optimal choice of consumption and portfolio. In case B both optimal values are monotonic function of time. In particular, the optimal consumption is a reducing fraction of wealth over time, while the optimal portfolio is an increasing function of time. This last result suggests that agent should invest in a less risky portfolio when they are young, and increase the risky proportion when they grow older. This result is definitely different in case A: the fact that the agent cannot count any longer on a wage after retirement, deeply modify his portfolios strategy. The optimal portfolio composition is highly volatile during the middle age of the agent, while after retirement the percentage of risky asset becomes constant. In fact, when there is no more (wage) risk to hedge against, the optimal portfolio is just given by its speculative component.
In case A, the optimal consumption ratio is decreasing over time for a young agent, but then it starts increasing and it becomes constant after retirement. In fact, we know from the literature, that without labour income, and with constant relative risk aversion preferences, the optimal consumption is a constant percentage of wealth.
The remaining of the paper is organised as follows: Sect. 2 shows the framework, Sect. 3 presents the result of the first problem, i.e. the optimal consumption, labour supply, and portfolio. Section 4 shows the optimal stopping problem, and solves it in closed form. Section 5 presents a numerical simulation calibrated on the US data. Section 6 concludes, and some technical results are gathered in three appendices.

Financial market
On a continuously open and friction-less financial market over the time set ½t 0 ; þ1½, one risky asset is traded, and its price S t 2 R þ follows a geometric Brownian motion where both the expected return (l) and the volatility (r) are constant, and W t is a Wiener processes (with zero mean and variance t). The initial asset price S t 0 is known. Also a risk-less asset is listed and its price G t solves the ordinary differential equation where r is the risk-less interest rate. We assume G t 0 ¼ 1, i.e. the risk-less asset is the nume´raire of the economy. This financial market is arbitrage free and complete. In other words, there exists a unique market price of risk n such that rn ¼ l À r.
Girsanov's theorem allows us to switch from the historical (P) to the risk-neutral probability Q by using dW Q t ¼ ndt þ dW t . The value in t 0 of any cash flow N t available at time t can be written as where E t 0 ½ and E Q t 0 ½ are the expected value operators under the historical (P) and the risk neutral (Q) probabilities respectively, conditional on the information set at time t 0 , and the martingale m t 0 ;t , such that m t 0 ;t 0 ¼ 1, solves 2.2 Agent's wage In this framework, we assume that the agent (household) works for the firm whose stocks are listed on the financial market, and this firm pays an instantaneous wage w t to the agent. Thus, the risk source that drives the price S t is the same that drives the wage. Accordingly, we assume that w t solves the following differential equation: The agent can choose how much to work (l t ) at any instant and, accordingly, his instantaneous wage will be l t w t . The agent optimally chooses when to retire (at time T), and after retirement he can still work, bu he will receive a percentage (x) of the wage w t . Thus, the labour income for the agent is given by following formula in which I e is the indicator function of the event e whose value is 1 if the event happens and 0 otherwise. This means that the labour income is w t l t before retirement, while it becomes xw t l t after retirement. Furthermore, we commit a slight abuse of notation by defining x t the 'dynamic' version of x. Here, in particular, we set x t ¼ 1 when t\T and x t ¼ x when t ! T.
In the numerical simulations we will show the difference in the final results when x ¼ 0 and x 6 ¼ 0. These two cases can be dealt together in the theoretical framework, and, nevertheless, they are characterised by a very different behaviour of the optimal agent's strategy (in terms of retirement age, consumption, and portfolio).

The mortality risk
The agent is aged x at t 0 and he dies at a random time X 2 ½t 0 ; 1½. If we call k t the force of mortality, his probability to be alive at time t, given that he is alive at time t 0 , is where we have used the property that the expected value of the indicator function of an event is the probability of that event.

The human capital
In this framework, the human capital is defined as the expected present value of future wages that the agent will obtain during his working life. If we define W t 0 such a human capital at time t 0 , we can compute it as follows: The human capital is computed under the risk neutral probability since it measures a kind of ''market power'' for the agent. In the complete market of our framework, the agent can trade his human capital. Accordingly, his disposable income is not only the current wage, but also the future flow of wages.
If we use the property of the indicator function I t\T ¼ 1 À I t ! T , the human capital can be written as in which the subtrahend is the human capital which the agent renounces to when he decides to retire.

The investor's wealth
The investor holds a portfolio given by h G;t 2 R quantities of the risk-less asset and h t 2 R quantities of the risky asset. Thus, at any instant in time the value of his wealth R t is given by Negative values of h G;t and h t indicate short selling. The differential of this constraint is where the term in brackets must: • finance the agent's consumption c t dt, • be financed by the agent's salary during his working life x t w t l t dt, • finance the loss in wealth due to death: k t R t dt.
Thus, the dynamic constraint can be written as and if h G;t , dS t , and dG t are substituted from (8), (1), and (2) respectively, we obtain Note that under the risk neutral probability, (10) can be written as and it implies that the initial wealth must be and this is actually the constraint that we will use for solving the optimisation problem of the agent.

Agent's preferences
We assume that the preferences of the agent can be represented through a recursive utility function U t having the following form: in which the function f is the so called Esptein-Zin 'aggregator'. Inside the aggregator, we assume that consumption and labour are additive. In particular, we adopt the following parametrisation used in Duffie and Epstein (1992): whose elements are described in what follows.
• c m is the subsistence level of consumption. We assume that the agent takes utility only from consumption that exceeds this minimum level; in fact, it will be optimal to consume always more than c m . We stress that preferences of consumption belong to the Hyperbolic Absolute Risk Aversion (HARA) family. • L is the maximum number of working hours that the agent can supply and, thus, the difference L À l t is the leisure time.
Þ is the relative weight of the leisure utility with respect to the consumption utility. We assume that the leisure utility during retirement has a different weight (v B ) than leisure utility during working life (v A ). Furthermore, the utility of the leisure is weighted by the salary w t (reduced by a percentage after retirement) for modelling the attitude of the agent towards leisure, which usually gives higher utility when the wage is higher.
• q is the (constant) subjective discount rate.
• d and / are, respectively, the Arrow-Pratt relative risk aversion parameter and the elasticity of inter-temporal substitution. We highlight that if 1 / ¼ d then the utility function collapses to the usual time separable utility with constant relative risk aversion (in which the inter-temporal preferences and the risk aversion are not disentangled). In fact, under this hypothesis and whose solution is Finally, the optimisation problem can be written as follows: 3 The optimal consumption, portfolio, and labour In order to compute the optimal solution to Problem (11), we split it into two subproblems. The idea is to follow a three step procedure.
1. First step: optimising with respect to consumption, labour supply, and portfolio, given any possible pension time T. In optimising this part of the problem, we treat T as a stochastic variable. 2. Second step: computing the value function of the problem as a function of the stochastic variable T. 3. Third step: optimising the value function with respect to T.
The solution to the first step is shown in the following proposition.
Proposition 1 Given the stochastic pension time T, the optimal consumption, portfolio, and labour supply that solve Problem (11) given (5) and (10) are in which and The optimal consumption rule (12) implies that it is always optimal to consume more than the subsistence level. In fact, we have demonstrated in Appendix 2 that the ratio R t ÀH t F t is always positive. Here, the function H t measures the expected present value of all the future subsistence consumption (c m ) reduced by the expected present value of the future maximum, or potential, wage (i.e. the wage that the agent would receive if he supplied the maximum hours of labour L). This result implies that if c m is very high, then the optimal consumption will be close to this minimum level. In fact, if the consumption is sufficiently low, the wealth can be accumulated at a higher rate.
We note that the function H t can be simplified as follows where only the second term depends on w t , and actually coincides with the human capital defined in (7). We stress that LW t T ð Þ is the maximum human capital, i.e. the human capital that would be obtained by working the maximum number of available hours.
The first part of the function H t can be written as follows which is the expected present value of a life annuity whose instalment is c m .

Remark 2
The wealth that is taken into account for computing the optimal consumption, labour, and portfolio allocation is a kind of 'modified' wealth given by the nominal wealth R t , reduced by the life annuity A t , and increased by the human capital LW t T ð Þ, i.e. R t À A t þ LW t T ð Þ. This means that the optimal behaviour of the agent is to buy a life annuity whose instalment is the minimum consumption c m , and to borrow against his maximum human capital.
The optimal labour supply (13) is lower than the maximum level L. The optimal leisure, i.e. the difference L À l Ã t , is inversely proportional to the wage and directly proportional to the ratio R t ÀH t F t . Determining the sign of the elasticity of the labour supply with respect to w t is not trivial, since both function H t and F t depend on w t . Nevertheless, by combining (12) and (13) we can write where we can conclude what follows.
Corollary 3 The elasticity of the optimal leisure with respect to wage is always lower than the same elasticity of consumption.
Furthermore, we see that the exchange rate between labour and consumption is a function of the time preference /, while it does not depend on the risk aversion d.
The optimal portfolio (14) is formed by three components: (1) a speculative component R t ÀH t d n r which is proportional to the market price of risk n, and negatively depends on both the risk aversion d and the volatility r, (2) a hedging component that covers the agent against the stochastic changes in H t due to the changes in the wage w t , and (3) a hedging component that covers against the stochastic changes in F t due to the changes in the wage w t .
The function F t cannot be simplified further if we keep the hypothesis that / 6 ¼ 1 d . Instead, if we merge the time preference and the risk aversion, the function F t takes the following linear form and can be further simplified as follows Accordingly, the optimal portfolio can be alternatively written as The functions H t and F t contribute to the computation of the value function J t given in (17), as demonstrated in both Appendixes 1 and 2, The optimal pension time problem The optimal pension time can be found by solving the problem where the value function J t has been defined in (17).
Here, in order to obtain a result that can be computed in closed form, we restrict the analysis by assuming two simplifying hypotheses: (1) the force of mortality (k) is constant, and (2) the time preference and risk preference are measured by the same parameter (i.e. / ¼ 1 d ). Under these hypotheses, the functions H t and F t contain the expected value of the wage w t under two probability measures. The process of w t under these probabilities is Thus, the function H t can be written as 6 The function F t , instead, has the following value: and so we can write 7 For solving both functions, we use the result of the following proposition. 7 Here, of course, we assume dÀ1 Proposition 4 Given the stochastic process dX t X t ¼ adt þ bdW t ; and a stopping time T, with X T ¼ x, the following equations hold if q [ a : Thanks to this result, we can finally compute the function H t as: Remark 5 We stress that the shape of the function H t strongly depends on the value of x, which is the percentage of wage that is obtained if working is allowed after retirement. In fact, • if x [ 0, the function H t after T is time dependent and is decreasing in w t ; • if x ¼ 0 (i.e. working is not allowed after retirement), the function H t becomes constant after T and simply coincides with the discounted subsistence consumption level.
In the numerical simulations we will show the difference in the agent's behaviour in these two cases.
The function F t , instead, has the following value: Remark 6 Also the function F t has a shape that strongly depends on x. We see that when x ¼ 0 it becomes constant after T, while for x [ 0 it is increasing in w t also after T.
As it is common in the literature about optimal stopping time, we have now transformed the original optimal stopping problem into an optimal threshold problem where we want to find a value of the state variable (the wage) such that the value function is maximum. The optimal stopping time, then, is given by the first moment when the wage crosses the threshold.
Given the above results, the value function can be further simplified as follows, where j is the threshold of the wage (i.e. j :¼ w T ): in which H t 0 and F t 0 are given by the above computed formulas.

The parameters
The parameters of the risky asset (l and r) are calibrated on the daily values of S&P500 from 1970 to 2018. We apply the method of moments to the geometric Brownian motion and we obtain l ¼ 0:084; r ¼ 0:167: The wage process is calibrated on the wages and salaries for US workers (fred.stlouisfed.org series A576RC1A027NBEA) for the same period . The same method of moments gives l w ¼ 0:0612; r w ¼ 0:07: The initial value of the wage is set to 20 dollars (per hour). Of course this value can be changed without any loss of generality, cause it affects just the level of the value function but not its shape.
The risk-less return is assumed to coincide with the average return on 3 month T-Bill from 1950 to 2018: For the sake of simplicity we further assume that the subjective discount rate q coincides with this risk-less interest rate.
The force of mortality is calibrated on the data of the human mortality database (https://www.mortality.org/) for US, on the average of both males and females aged 25: Here, we have used all annual data (interest rates and growth rates), and so the maximum number of working hours is set to L ¼ 250 Â 8, given by the product between the number of working days in a year and the number of working hours in a day.
The initial wealth is set to a level that coincides with the total amount that could be received by working the maximum number of hours in a year at the initial wage (i.e. Lw t 0 ).
The relative magnitude of v A and v B is crucial for determining the behaviour of the agent with respect to the working effort before and after retirement. Instead, the absolute magnitude of these two parameters is relevant for determining the optimal consumption.
We have conducted many simulations and we have checked that the values of v A and v B that generate optimal solutions that are consistent with the results usually obtained in the literature are v A ¼ 1 10;000 ; v B ¼ 1:6 10;000 : Furthermore, these values allow us to compare the magnitude of the leisure utility to the magnitude of the consumption utility (we recall that, under our previous hypotheses, the initial wealth is R t 0 ¼ w t 0 L ¼ 40;000).
Finally, we will conduct two sets of simulations, one with x ¼ 0 for showing the agent's behaviour when working is not allowed after retirement, and one with x ¼ 1

The value function and the optimal wage threshold
The numerical values of the value function J j ð Þ, in which j is the wage threshold, are drawn in Fig. 1. The maximum of the function is obtained for which are the thresholds of the wage above which the agent will decide to retire. If we simulate some trajectories of the wage and we compare them with these thresholds, we obtain the graph shown in Fig. 2.
The time zero in the graph represents the first period when the agent starts receiving a wage. Thus, it should coincide with an age of about 25.
The main result is that, in our framework, it is optimal for an agent to retire depending on the wage that he will receive after retirement. In particular, we distinguish the following cases.   Fig. 1 Value function J j ð Þ given the parameters shown in Table 1 • If x ¼ 0 (no wage after retirement): it is optimal to retire after about 50 years of work (on average). We stress that the volatility of the wage in such a long period of time may imply an optimal retirement time that could be either anticipated to about 40 years of work or postponed up to more than 60 years. • If x ¼ 1 3 : it is optimal to retire after about 35 years of work (on average). In this case, the volatility of the forecast on the future wage may lead to a retirement either anticipated to less than 30 years of work, or postponed up to about 45 years.
If we compare this result with the EU15 average retirement age of 65 years and with the trend forecast for the next few years (towards 68 years for some states), we can identify a misalignment between the statutory and the optimal retirement age.
In our framework, we do not take into account any pension scheme and, thus, we do not have to comply with the related sustainability issue. Instead, in European public and private pension systems, such an issue is becoming more and more relevant over time, especially in the face of an ageing population and a reduced birth rate trend.
Another hypothesis for justifying this misalignment relates instead to the growth rate of wages. Indeed, if the wages increase at a lower rate, as shown, among others, by IMF (2018), European Commission (2018b) and Astrov et al. (2018), then it is optimal to retire later. A trend reduction in the average growth rate of wages could lead to an alignment between the statutory and the optimal retirement age.

The auxiliary functions
Under the hypotheses of our framework, the function H t is always negative (or zero) and we recall that it measures the (opposite of the) expected present value of the future wages (here we assume c m ¼ 0). The value, over time, of this function is drawn in Fig. 3 for both cases x 2 0; 1 3 È É . We can see that with x ¼ 0 the function H t reaches an 'equilibrium' level and then becomes constant, while with x ¼ 1 3 it is monotonically decreasing over time. The function F t is always strictly positive and its value, over time, is drawn in Fig. 4. Also in this case, we see a very different behaviour according to the value of x. If x ¼ 0 the function tends towards an equilibrium level, while for x [ 0 it is strictly increasing over time.

The optimal wealth, consumption, labour, and portfolio
In Fig. 5 we draw the optimal wealth. We check that the optimal wealth is increasing over time, but with x ¼ 0 its growth rate is much lower than with x [ 0. In fact, if the agent is allowed to have a wage even after retirement, he can obtain a higher growth rate of his wealth.
In Fig. 6 we draw the optimal labour supply. We see that the average labour supply is decreasing over time, firstly at a higher speed, and for older ages at a lower speed. In this case the effect of x is over the magnitude of the labour supply. In fact, if there is no more wage after retirement (i.e. x ¼ 0) the agent will work much more hours during his working life. If x ¼ 0 the labour supply will fall to zero, while for x [ 0 it will become stable over time, at a very low level of about 100 working hour per year. The maximum number of working hours is about 700 per year, which may seem low. Such a result depends on two crucial hypotheses on financial market and agent's preferences: (1) the market does not suffer any credit risk, in other words, the asset prices have some volatility, but they never go to zero, and the financial market is always able to fully recover from any fall, (2) the agent has a subsistence consumption c m ¼ 0, which means that he is able to take utility even from a very low consumption.
In Fig. 6 we clearly see that after 60 years of work, the labour supply with x ¼ 0 sharply decreases. Of course, each of the simulated path will reach zero at a different time and, in fact, we see that the curve (which is the average of all the simulations) goes to zero after around 80 years.
The optimal consumption of the agent can be expressed in different ways: (1) as a total amount of money spent, (2) as a percentage of the optimal wealth R t , or (3) as a percentage of the disposable wealth R t À H t . This last way to represent consumption seems to be the best since it suitably takes into account the implicit hypothesis that the agent is able to borrow against his future wage. Figure 7 shows the average result of 500 simulations of the ratio c Ã t R t ÀH t . We see that when x ¼ 0 (no wage after retirement) the optimal (relative) consumption increases over time and once the retirement is reached, it becomes a constant percentage of the disposable wealth. The optimal consumption ratio starts from a value of about 2.5% and reaches, after retirement, its asymptotic value of about 5.5%. Instead, when x [ 0 the consumption rate is constantly decreasing as it happens in any infinite horizon optimisation problem. We recall that in this framework, the optimal consumption and the optimal labour supply are proportional. This means that when x [ 0, a lower labour supply is twinned with a lower consumption. The optimal portfolio can be drawn, again, as a percentage of the disposable wealth h Ã t R t ÀH t . The corresponding plot is shown in Fig. 8. We can see some interesting behaviours of the optimal portfolio share. Both portfolios, with x ¼ 0 and x ¼ 1 3 are on average increasing over time, nevertheless, the optimal portfolio for x [ 0 has a more stable growth from about 50% to about 80%. This is a confirmation of the result often found in the literature: a young agent that still has to finance all his future consumption should invest less in the risky asset, while this percentage should increase while the agent becomes older and older.
The shape of the optimal portfolio for x ¼ 0, instead, presents some very interesting features.
• The percentage to invest in risky asset is almost always smaller (than in the case x [ 0): this is explained by the fact that with x ¼ 0 the agent cannot count on future wages after retirement and so his portfolio must be less aggressive. • The portfolio is very volatile between 30 and 80 years of work, while it becomes constant after retirement. Actually, when both functions F t and H t become constant (after T), there is no more need for hedging against the wage volatility and the optimal portfolio becomes constant. When x [ 0, the need to hedge against the stochastic behaviour of w t remains almost unchanged over time, and so we find a smoother shape of the portfolio.

Conclusion
In our work we study the problem of a representative agent who wants to maximise the expected present value of his inter-temporal recursive utility by choosing the retirement age, the inter-temporal consumption, the labour supply, and the portfolio allocation.
If we assume that an agent starts working at about 25, our main results show that the optimal retirement age should be about 60 if the agent is still allowed to received a (reduced) wage after retirement, while it should be about 75 if working is not allowed after retirement. Comparing these results with the EU15 average retirement age (65 years), we find that this optimal retirement may be close to the optimal solution depending on the legislation about working after retirement.
A possible explanation for a misalignment between the statutory and the optimal solution is that, while first value is chosen to guarantee the financial sustainability of the pension system at macro level, the second derives from an optimal choice at the micro level.
All the results strongly rely on wage dynamics. In particular, if the wages increase at a lower rate, then it is optimal to retire later.
In our model the ratio between the optimal consumption and the disposable wealth increases over time from 2.5% to about 5.5% and, after retirement, it remains constant over time if the pensioner is not allowed to work. On the contrary, the optimal consumption is a constantly reducing percentage of wealth. Moreover, we find that the percentage of disposable wealth invested in the risky asset is smoothly increasing over time if pensioners are allowed to work, while this percentage becomes constant after retirement if this is not allowed.
Acknowledgments Open access funding provided by Università degli Studi di Brescia within the CRUI-CARE Agreement.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creativecommons.org/licenses/by/4.0/.
with transversality condition The First Order Condition (FOC) on consumption c t is the FOC on labour l t is and the FOC on portfolio h t is Once these candidates to the optimal are substituted into the HJB equation we get In order to solve this PDE we guess the following solution in which H t t; w t ð Þ and F t t; w t ð Þ are two functions whose values must solve the HJB equation.
If we substitute this function into the HJB we get a PDE that can be split into two PDEs, one that contains the terms R t À H t ð Þ 1Àd : and one that contains the terms R t À H t ð Þ Àd Thus, we see that This means that (22) can be written as a function of the initial wealth as follows: Given the stochastic differential equations for the wage (5) and for the price kernel (4), the differential of R t is dR t ¼ ::: ð Þdt þ oH t ow t þ / À 1 d m The optimal portfolio is then while the optimal consumption and labour are those presented in the proposition.

Appendix 3: Proof of Proposition 4
Given a geometric Brownian motion dX t X t ¼ adt þ bdW t ; whose solution is (with W t 0 ¼ 0) we want to compute the expected value E t 0 R T t 0 X s e Àq sÀt 0 ð Þ ds h i that can be simplified as follows