From 76836a05d9d6b52f649e88946558403df00f09db Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 27 Jun 2023 09:25:25 -0400 Subject: [PATCH 01/26] update firm objective theory --- docs/book/content/theory/firms.md | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index 87bec2a36..4a35a68a9 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -33,17 +33,46 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ```{math} :label: EqFirmsProfit - PR_{m,t} &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t}\Bigr] - \\ - &\qquad\qquad\quad \bigl(r_t + \delta_{M,t}\bigr)K_{m,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K_{m,t} + \tau^{inv}_{m,t}\delta_{M,t}K_{m,t} \quad\forall m,t + \pi(K_{m,t}, L_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t} - \Psi(I_{m,t}, K_{m,t})\Bigr] - \\ + &\qquad\qquad\quad I_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t ``` - Gross income for the firms is $p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t})$. Labor costs to the firm are $w_t L_{m,t}$, and capital costs are $(r_t +\delta_{M,t})K_{m,t}$. The government supplies public capital $K_{g,m,t}$ to the firms at no cost. The per-period interest rate (rental rate) of capital for firms is $r_t$. The per-period economic depreciation rate for private capital is $\delta_{M,t}\in[0,1]$.[^delta_M] The $\delta^\tau_{m,t}$ parameter in the second-to-last term of the profit function governs how much of capital depreciation can be deducted from the corporate income tax. Note that the last term above represents the benefits from any investment tax credit $\tau^{inv}_{m,t}$. While this should be applied to all investment, firms in `OG-Core` are making static decisions each period about the amount of capital to rent. We therefore proxy for investment with $\delta_{M,t}K_{m,t}$, which is accurate in the steady-state, but is an approximation over the transition to the steady-state. + Gross revenue for the firms is $p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t})$. Labor costs to the firm are $w_t L_{m,t}$, and investment, $I_{m,t}$ contributes to the capital stock through the following law of motion: + + ```{math} + :label: EqFirmsInvest + K_{m,t+1} = (1-\delta_M) K_{m,t} + I_{m,t} \quad\forall m,t + ``` + + The government supplies public capital $K_{g,m,t}$ to the firms at no cost. The per-period economic depreciation rate for private capital is $\delta_{M,t}\in[0,1]$.[^delta_M] The $\delta^\tau_{m,t}$ parameter in the second-to-last term of the profit function governs how much of capital depreciation can be deducted from the corporate income tax. Note that the last term above represents the benefits from any investment tax credit $\tau^{inv}_{m,t}$. We assume that capital adjustment costs, $\Psi(I_{m,t}, K_{m,t})$, are quadratic in the investment rate $I_{m,t}$ and the capital stock $K_{m,t}$ and are deductible from corporate income when determining taxable income. The quadratic adjustment costs are given by the following function: + + ```{math} + :label: EqFirmsAdjCosts + \Psi(I_{m,t}, K_{m,t}) = \frac{\psi}{2}\frac{\left(\frac{I_{m,t}}{K_{m,t}} - \mu_m \right)^2}{\frac{I_{m,t}}{K_{m,t}}} \quad\forall m,t + ``` + + The parameter $\mu_m = \delta_M + \bar{g}_n + g_y$, is the steady state investment rate. Thus adjustment cost are zero in the steady state, but affect firms along the transition path. The parameter $\psi$ governs the strength of the adjustment costs. Taxes enter the firm's profit function {eq}`EqFirmsProfit` in two places. The first is the corporate income tax rate $\tau^{corp}_{m,t}$, which is a flat tax on corporate income that can vary by industry $m$. Corporate income is defined as gross income minus labor costs. This will cause the corporate tax to only have a direct effect on the firms' capital demand decision. - The tax policy also enters the profit function {eq}`EqFirmsProfit` through depreciation deductions at rate $\delta^\tau_{m,t}$, which then lower corporate tax liability. When $\delta^\tau_{m,t}=0$, no depreciation expense is deducted from the firm's tax liability. When $\delta^\tau_{m,t}=\delta_{M,t}$, all economic depreciation is deducted from corporate income. The investment tax credit is characterized by the parameter $\tau^{inv}_{m,t}$ multiplied by a proxy for investment $\delta_{M,t}K_{m,t}$ by industry $m$, which represents the percent of industry-specific capital that can be credited against profits. + The tax policy also enters the profit function {eq}`EqFirmsProfit` through depreciation deductions at rate $\delta^\tau_{m,t}$, which then lower corporate tax liability. When $\delta^\tau_{m,t}=0$, no depreciation expense is deducted from the firm's tax liability. When $\delta^\tau_{m,t}=\delta_{M}$, all economic depreciation is deducted from corporate income. The investment tax credit is characterized by the parameter $\tau^{inv}_{m,t}$ multiplied by the amount of investment. The tax basis for the capital stock, $K^\tau_{m,t}$ is determined through the following law of motion: + + ```{math} + :label: EqFirmsKtau + K^{\tau}_{m,t} = (1-\delta^{\tau}_{m,t}) K^\tau_{m,t-1} + (1-\tau^{inv}_{m,t})I_{m,t} \quad\forall m,t + ``` + + Note the timing difference in the laws of motion for the tax basis for the capital stock and the capital stock. Investment is immediately deducted from the tax basis for the capital stock, where are there is a time to build in the physical capital stock (new investment doesn't become productive until the next period). + + Firms take as given prices $p_{m,t}$, $w_t$, and $r_t$ and the level of public capital supply $K_{g,m,t}$. These firms are forward looking and maximize the present discounted value of profits: + + ```{math} + :label: EqFirmsValue + \max_{I_{m,t}, K_{m,t+1}, L_{m,t}} V(K_{m,t}) = \sum_{u=t}^\infty \prod_{v=t}^u \left(\frac{1}{1+r_v}\right) \pi(K_{m,u}, L_{m,u}) \quad\forall m,t + ``` + - Firms take as given prices $p_{m,t}$, $w_t$, and $r_t$ and the level of public capital supply $K_{g,m,t}$. Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. + Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. ```{math} :label: EqFirmFOC_L From e5d3a6be1927ad81328995b92ba796b6c41530f2 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 28 Jun 2023 13:51:16 -0400 Subject: [PATCH 02/26] add adj cost functions to docs --- docs/book/content/theory/firms.md | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index 4a35a68a9..d358d1bd3 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -64,15 +64,22 @@ Industry $M$ in the model is unique in two respects. First, we will define indu Note the timing difference in the laws of motion for the tax basis for the capital stock and the capital stock. Investment is immediately deducted from the tax basis for the capital stock, where are there is a time to build in the physical capital stock (new investment doesn't become productive until the next period). - Firms take as given prices $p_{m,t}$, $w_t$, and $r_t$ and the level of public capital supply $K_{g,m,t}$. These firms are forward looking and maximize the present discounted value of profits: + Firms take as given prices $p_{m,t}$, $w_t$, and $r_t$ and the level of public capital supply $K_{g,m,t}$. These firms are forward looking and maximize the present discounted value of profits, where firms discount by the real interest rate $r_t$. The firm's problem is the following: ```{math} :label: EqFirmsValue - \max_{I_{m,t}, K_{m,t+1}, L_{m,t}} V(K_{m,t}) = \sum_{u=t}^\infty \prod_{v=t}^u \left(\frac{1}{1+r_v}\right) \pi(K_{m,u}, L_{m,u}) \quad\forall m,t + \begin{split} + V(K_{m,t}, K^\tau_{m,t-1}) &= \max_{\{I_{m,u}, K_{m,u+1},K^\tau_{m,u}, L_{m,u}\}_{u=t}^{\infty}} \sum_{u=t}^\infty \left(\prod_{v=t}^u \frac{1}{1+r_v}\right) \pi(K_{m,u}, L_{m,u}) \quad\forall m,t,\\ + \quad \text{subject to}: & \\ + & \\ + I_{m,t} &= K_{m,t+1} - (1-\delta_M) K_{m,t} + I_{m,t} \quad\forall m,t \\ + K^{\tau}_{m,t} &= (1-\delta^{\tau}_{m,t}) K^\tau_{m,t-1} + (1-\tau^{inv}_{m,t})I_{m,t} \quad\forall m,t + + \end{split} ``` - Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. + Note that one can use the two law of motion for the physical capital stock and the tax basis of the capital stock to eliminate to choice variables: choosing $K_{m,u+1}$ will determine $I_{m,t}$ and $K^\tau_{m,t}$. Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t+1}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. ```{math} :label: EqFirmFOC_L @@ -81,7 +88,21 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ```{math} :label: EqFirmFOC_K - r_t = (1 - \tau^{corp}_{m,t})p_{m,t}(Z_{m,t})^\frac{\varepsilon_m-1}{\varepsilon_m}\left[\gamma_m\frac{Y_{m,t}}{K_{m,t}}\right]^\frac{1}{\varepsilon_m} - \delta_{M,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t} + \tau^{inv}_{m,t}\delta_{M,t} \quad\forall m,t + r_{t+1} = \frac{(1 - \tau^{corp}_{m,t+1})\left(p_{m,t+1}(Z_{m,t+1})^\frac{\varepsilon_m-1}{\varepsilon_m}\left[\gamma_m\frac{Y_{m,t+1}}{K_{m,t+1}}\right]^\frac{1}{\varepsilon_m} - \frac{\partial \Psi(I_{m,t+1},K_{m,t+1})}{\partial K_{m,t+1}}\right) + 1 - \delta_{m} + \tau^{corp}_{m,t+1}\delta^\tau_{m,t+1}\left[(1-\tau^{inv}_{m,t})(1-\delta^\tau_{m,t})-(1-\delta_m)(1-\tau^{inv}_{m,t+1})\right] - \tau^{inv}_{m,t+1}(1-\delta_{m})}{(1-\tau^{corp}_{m,t})\frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t+1}}+1 -\tau^{inv}_{m,t}-\tau^{corp}_{m,t}\delta^{\tau}_{m,t}(1-\tau^{inv}_{m,t})} - 1 \quad\forall m,t + ``` + + The derivatives of of the quadratic adjustment cost function are given by: + + ```{math} + :label: EqFirmAdjCost_dKp1 + \frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t+1}} = \frac{\psi}{2}\frac{\left(\frac{I_{m,t}}{K_{m,t}}- \mu_{m}\right)}{I_{t}}\left[1 -\mu\frac{K_{m,t}}{I_{m,t}}\right] \forall m,t + ``` + + and + + ```{math} + :label: EqFirmAdjCost_dK + \frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t}} = \frac{-\psi}{2}\left(\frac{K_{m,t+1}}{I^2_{m,t}}\right)\left(\frac{I_{m,t}}{K_{m,t}}-\mu\right)\left(\frac{I_{m,t}}{K_{m,t}}+\mu\right) \forall m,t ``` Note that the presence of the public capital good creates economic rents. These rents will accrue to the owners of capital via the financial intermediary. See Section Chapter {ref}`Chap_FinInt` for more details on the determination of the return to the household's portfolio. Because public capital is exogenous to the firm's decisions, the optimality condition for capital demand {eq}`EqFirmFOC_K` is only affected by public capital $K_{g,m,t}$ through the $Y_{m,t}$ term. @@ -89,6 +110,8 @@ Industry $M$ in the model is unique in two respects. First, we will define indu (EqFirmsPosProfits)= ## Positive Profits from Government Infrastructure Investment + NOTE: WITH DYNAMIC FIRMS AND ADJUSTMENT COSTS, THE MPK WILL LOOK DIFFERENT, BUT THE RESULT BELOW SHOULD STILL HOLD -- JUST NEED TO DO SOME MORE ALGEBRA TO SHOW -- AND IT'S COMPLICATED BECAUSE EQ 48 HAS MULIPLE PERIODS IN IT AND POLICY CHANGING OVER TIME. + The CES production function in {eq}`EqFirmsCESprodfun` exhibits constant returns to scale (CRS). A feature of CRS production functions is that gross revenue $Y_{m,t}$ is a sum of the gross revenue attributed to each factor of production, ```{math} From 373aa169bfd1b436361878e824a0cdd51cbaa59a Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 11 Aug 2023 16:23:33 -0400 Subject: [PATCH 03/26] update firm adj costs and eqn's for adj costs --- docs/book/content/theory/firms.md | 71 ++++++------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index d358d1bd3..db9b29d9f 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -64,6 +64,17 @@ Industry $M$ in the model is unique in two respects. First, we will define indu Note the timing difference in the laws of motion for the tax basis for the capital stock and the capital stock. Investment is immediately deducted from the tax basis for the capital stock, where are there is a time to build in the physical capital stock (new investment doesn't become productive until the next period). + The expected (pre-tax) return to a shareholder investing in firm $m$ is given by: + + ```{math} + :label: EqFirmsExpectedReturn + \begin{split} + E_{t}(R_{m,t}) = \frac{\pi_{m,t} + E_{t}V_{m,t+1} - V{m,t}}{V_{m,t}} + \end{split} + ``` + + where $V_t$ is the value of the firm, $E_tV_{t+1}$ is the expected value of the firm next period, and $\pi_t$ is the profit of the firm in period $t$. Without aggregate uncertainty, it must be the case that the expected return to a shareholder for an investment in any industry is the same: $E_{t}(R_{m,t}) = E_{t}(R_{t})$. Futhermore, the rate of return on equity must be the same as the rate of return on government debt, adjusted for the risk premium. That is, $E_{t}(R_{t}) = 1 + r_{t} = 1 + \left(\frac{r_{gov,t} + \mu_d}{(1-\tau_{d,t})}\right)$ where $r_{gov,t}$ is the risk-free rate of return on government debt and the parameters $\mu_d$ and $\tau_{d,t}$ define the risk premium of equity over government debt that we've built into this model with no uncertainty. + Firms take as given prices $p_{m,t}$, $w_t$, and $r_t$ and the level of public capital supply $K_{g,m,t}$. These firms are forward looking and maximize the present discounted value of profits, where firms discount by the real interest rate $r_t$. The firm's problem is the following: ```{math} @@ -79,7 +90,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ``` - Note that one can use the two law of motion for the physical capital stock and the tax basis of the capital stock to eliminate to choice variables: choosing $K_{m,u+1}$ will determine $I_{m,t}$ and $K^\tau_{m,t}$. Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t+1}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. + Note that one can use the two laws of motion (for the physical capital stock and the tax basis of the capital stock) to eliminate to choice variables: choosing $K_{m,u+1}$ will determine $I_{m,t}$ and $K^\tau_{m,t}$. Taking the derivative of the profit function {eq}`EqFirmsProfit` with respect to labor $L_{m,t}$ and setting it equal to zero (using the general CES form of the production function {eq}`EqFirmsCESprodfun`) and taking the derivative of the profit function with respect to private capital $K_{m,t+1}$ and setting it equal to zero, respectively, characterizes the optimal labor and capital demands. ```{math} :label: EqFirmFOC_L @@ -91,7 +102,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu r_{t+1} = \frac{(1 - \tau^{corp}_{m,t+1})\left(p_{m,t+1}(Z_{m,t+1})^\frac{\varepsilon_m-1}{\varepsilon_m}\left[\gamma_m\frac{Y_{m,t+1}}{K_{m,t+1}}\right]^\frac{1}{\varepsilon_m} - \frac{\partial \Psi(I_{m,t+1},K_{m,t+1})}{\partial K_{m,t+1}}\right) + 1 - \delta_{m} + \tau^{corp}_{m,t+1}\delta^\tau_{m,t+1}\left[(1-\tau^{inv}_{m,t})(1-\delta^\tau_{m,t})-(1-\delta_m)(1-\tau^{inv}_{m,t+1})\right] - \tau^{inv}_{m,t+1}(1-\delta_{m})}{(1-\tau^{corp}_{m,t})\frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t+1}}+1 -\tau^{inv}_{m,t}-\tau^{corp}_{m,t}\delta^{\tau}_{m,t}(1-\tau^{inv}_{m,t})} - 1 \quad\forall m,t ``` - The derivatives of of the quadratic adjustment cost function are given by: + The derivatives of the quadratic adjustment cost function are given by: ```{math} :label: EqFirmAdjCost_dKp1 @@ -110,61 +121,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu (EqFirmsPosProfits)= ## Positive Profits from Government Infrastructure Investment - NOTE: WITH DYNAMIC FIRMS AND ADJUSTMENT COSTS, THE MPK WILL LOOK DIFFERENT, BUT THE RESULT BELOW SHOULD STILL HOLD -- JUST NEED TO DO SOME MORE ALGEBRA TO SHOW -- AND IT'S COMPLICATED BECAUSE EQ 48 HAS MULIPLE PERIODS IN IT AND POLICY CHANGING OVER TIME. - - The CES production function in {eq}`EqFirmsCESprodfun` exhibits constant returns to scale (CRS). A feature of CRS production functions is that gross revenue $Y_{m,t}$ is a sum of the gross revenue attributed to each factor of production, - - ```{math} - :label: EqFirmsMargRevEq - Y_{m,t} = MPK_{m,t} K_{m,t} + MPK_{g,m,t} K_{g,m,t} + MPL_{m,t} L_{m,t} \quad\forall m,t - ``` - - where $MPK_{m,t}$ is the marginal product of private capital in industry $m$, $MPK_{g,m,t}$ is the marginal product of public capital, and $MPL_{m,t}$ is the marginal product of labor.[^MPfactors] Each of the terms in {eq}`EqFirmsMargRevEq` is growing at the macroeconomic variable rate of $e^{g_y t}\tilde{N_t}$ (see the third column of {numref}`TabStnrzStatVars`). Firm profit maximization for private capital demand from equation {eq}`EqFirmFOC_K` implies that the marginal product of private capital is equal to the real cost of capital: - - ```{math} - :label: EqFirmsMPK_opt - MPK_{m,t} = \frac{r_t + \delta_{M,t} - \tau^{corp}_{m,t}\delta^\tau_{m,t} - \tau^{inv}_{m,t}\delta_{M,t}}{p_{m,t}(1 - \tau^{corp}_{m,t})} \quad\forall m,t - ``` - - Firm profit maximization for labor demand from equation {eq}`EqFirmFOC_L` implies that the marginal product of labor is equal to the real wage rate: - - ```{math} - :label: EqFirmsMPL_opt - MPL_{m,t} = \frac{w_t}{p_{m,t}} \quad\forall m,t - ``` - - Even though firms take the stock of public capital $K_{g,t}$ from government infrastructure investment as given, we can still calculate the marginal product of public capital from the production function {eq}`EqFirmsCESprodfun`. - - ```{math} - :label: EqFirmsMPKg_opt - MPK_{g,m,t} = \left(Z_{m,t}\right)^{\frac{\varepsilon_m - 1}{\varepsilon_m}}\left(\gamma_{g,m}\frac{Y_{m,t}}{K_{g,m,t}}\right)^{\frac{1}{\varepsilon_m}} \quad\forall m,t - ``` - - If we plug the expressions for $MPK_{m,t}$, $MPK_{g,m,t}$, and $MPL_{m,t}$ from {eq}`EqFirmsMPK_opt`, {eq}`EqFirmsMPKg_opt`, and {eq}`EqFirmsMPL_opt`, respectively, into the total revenue $Y_{m,t}$ decomposition in {eq}`EqFirmsMargRevEq` and then substitute that into the profit function {eq}`EqFirmsProfit`, we see that positive economic rents arise when public capital is positive $K_{g,m,t}>0$. - - ```{math} - :label: EqFirmsProfit_Kg - \begin{split} - PR_{m,t} &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}Y_{m,t} - w_t L_{m,t}\Bigr] - \bigl(r_t + \delta_{M,t}\bigr)K_{m,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K_{m,t} + \tau^{inv}_{m,t}\delta_{M,t}K_{m,t} \\ - &= (1 - \tau^{corp}_{m,t})\Biggl[\biggl(\frac{r_t + \delta_{M,t} - \tau^{corp}_{m,t}\delta^{\tau}_{m,t} - \tau^{inv}_{m,t}\delta_{M,t}}{1 - \tau^{corp}_{m,t}}\biggr)K_{m,t} + p_{m,t}MPK_{g,m,t}K_{g,m,t} + w_t L_{m,t}\Biggr] ... \\ - &\quad\quad - (1 - \tau^{corp}_{m,t})w_t L_{m,t} - (r_t + \delta_{M,t})K_{m,t} + \tau^{corp}_{m,t}\delta^{\tau}_{m,t}K_{m,t} + \tau^{inv}_{m,t}\delta_{M,t}K_{m,t} \\ - &= (1 - \tau^{corp}_{m,t})p_{m,t}MPK_{g,m,t}K_{g,m,t} \quad\forall m,t - \end{split} - ``` - - We assume these positive economic profits resulting from government infrastructure investment are passed on to the owners of private capital through an adjusted interest rate $r_{K,t}$ provided by the financial intermediary (see Chapter {ref}`Chap_FinInt`) that zeroes out profits among the perfectly competitive firms and is a function of $p_{m,t}$, $MPK_{g,m,t}$ and $K_{g,m,t}$ in each industry $m$. Total payouts from the financial intermediary $r_{K,t}\sum_{m=1}^M K_{m,t}$ are a function of the perfectly competitive payout to owners of private capital $r_t \sum_{m=1}^M K_{m,t}$ plus any positive profits when $K_{g,m,t}>0$ from {eq}`EqFirmsProfit_Kg`. - - ```{math} - :label: EqFirmsPayout - r_{K,t}\sum_{m=1}^M K_{m,t} = r_t \sum_{m=1}^M K_{m,t} + \sum_{m=1}^M(1 - \tau^{corp}_{m,t})p_{m,t}MPK_{g,m,t}K_{g,m,t} \quad\forall t - ``` - - This implies that the rate of return paid from the financial intermediary to the households $r_{K,t}$ is the interest rate on private capital $r_t$ plus the ratio of total positive profits across industries (a function of $K_{g,m,t}$ in each industry) divided by total private capital from {eq}`EqFirmsProfit_Kg`, in which the units are put in terms of $K_{m,t}$ (which is in terms of the $M$th industry output, see equation {eq}`eq_rK` in Chapter {ref}`Chap_FinInt`). - - ```{math} - :label: EqFirms_rKt - r_{K,t} = r_t + \frac{\sum_{m=1}^M(1 - \tau^{corp}_{m,t})p_{m,t}MPK_{g,m,t}K_{g,m,t}}{\sum_{m=1}^M K_{m,t}} \quad\forall t - ``` +Note that when $K_{g,t}$ is greater than zero, the public capital factor of production generates above normal profits for the firm. That is, the actual rate of return on equity, $E_t(R_t)$, will exceed the discount factor used by the firm, $1+r_t$. This is because the firm does not pay for the public capital that it uses in production. The above normal return will be distributed to shareholders as part of the firms profits and thus the return on equity. We detail this further in the {ref}`Chap_FinInt` Chapter. (SecFirmsfootnotes)= ## Footnotes From 5784dd42463f0a7da2cd5d49dbb703e041ee47b1 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 11 Aug 2023 16:24:42 -0400 Subject: [PATCH 04/26] update SS soln algo for dyn firms --- docs/book/content/theory/equilibrium.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index f09adf093..1bf01d5bd 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -61,7 +61,7 @@ The computational algorithm for solving for the steady-state follows the steps b 2. Choose an initial guess for the values of the steady-state interest rate (the after-tax marginal product of capital) $\bar{r}^i$, wage rate $\bar{w}^i$, portfolio rate of return $\bar{r}_p^i$, output prices $\boldsymbol{\bar{p}}^i$ (note that $\bar{p}_M =1$ since it's the numeraire good), total bequests $\overline{BQ}^{\,i}$, total household transfers $\overline{TR}^{\,i}$, and income multiplier $factor^i$, where superscript $i$ is the index of the iteration number of the guess. 1. Given $\boldsymbol{\bar{p}}^i$ find the price of consumption goods using {eq}`EqHH_pi2` - 2. From price of consumption goods, determine the price of the composite consmpution good, $\bar{p}$ using equation {eq}`EqCompPnorm2` + 2. From price of consumption goods, determine the price of the composite consumption good, $\bar{p}$ using equation {eq}`EqCompPnorm2` 3. Using {eq}`Eq_tr` with $\overline{TR}^{\,i}$, find transfers to each household, $\overline{tr}_{j,s}^i$ 4. Using the bequest transfer process, {eq}`Eq_bq` and aggregate bequests, $\overline{BQ}^{\,i}$, find $bq_{j,s}^i$ 5. Given values $\bar{p}$, $\bar{r}_{p}^i$, $\bar{w}^i$ $\overline{bq}_{j,s}^i$, $\overline{tr}_{j,s}^i$, and $factor^i$, solve for the steady-state household labor supply $\bar{n}_{j,s}$ and savings $\bar{b}_{j,s+1}$ decisions for all $j$ and $E+1\leq s\leq E+S$. @@ -113,12 +113,13 @@ The computational algorithm for solving for the steady-state follows the steps b 14. Using the law of motion of the stock of infrastructure, {eq}`EqStnrz_Kgmt`, and $\bar{I}_{g}$, solve for $\bar{K}_{g}^{i}$ 15. Find output and factor demands for M-1 industries: 1. By {eq}`EqMarkClrGoods_Mm1`, $\hat{Y}_{m,t}=\hat{C}_{m,t}$, where $\hat{C}_{m,t}$ is determined by {eq}`EqStnrzEqCmt` - 2. The capital-output ratio can be determined from the FOC for the firms' choice of capital: $\frac{\bar{K}_m}{\bar{Y}_m} = \gamma_m\left[\frac{\bar{r} +\bar{\delta}_M - \bar{\tau}^{corp}_m\bar{\delta}^{\tau}_m - \bar{\tau}^{inv}_m\bar{\delta}_M}{\left(1 - \bar{\tau}^{corp}_m\right)\bar{p}_m(\bar{Z}_m)^\frac{\varepsilon_m-1}{\varepsilon_m}}\right]^{-\varepsilon_m}$ - 3. Capital demand can thus be found: $\bar{K}_{m} = \frac{\bar{K}_m}{\bar{Y}_m} * \bar{Y}_m$ - 4. Labor demand can be found by inverting the production function: + + 2. The labor-output ratio can be determined from the FOC for the firms' choice of labor: $\frac{\bar{Y}_m}{\bar{L}_m} = \left(\bar{Z}_m\right)^{\varepsilon_m - 1}\frac{(1-\gamma_m - \gamma_{g,m})}{(\bar{w}\bar{p}_m)}$ + 3. Labor demand can thus be found: $\bar{L}_{m} = \frac{\bar{L}_m}{\bar{Y}_m} * \bar{Y}_m$ + 4. Capital demand can be found by inverting the production function: ```{math} - :label: EqSS_solveL - \bar{L}_{m} = \left(\frac{\left(\frac{\bar{Y}_m}{\bar{Z}_m}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{m}^{\frac{1}{\varepsilon_m}}\bar{K}_m^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}}\bar{K}_{g,m}^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{(1-\gamma_m-\gamma_{g,m})^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} + :label: EqSS_solveK + \bar{K}_{m} = \left(\frac{\left(\frac{\bar{Y}_m}{\bar{Z}_m}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}} \bar{K}_{g,m}^{\frac{\varepsilon_m-1}{\varepsilon_m}}- (1 - \gamma_{m} - \gamma_{g,m})^{\frac{1}{\varepsilon_m}}\bar{L}_m^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{\gamma_m^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} ``` 5. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for private capital demand at the world interest rate $\bar{K}_m^{r^*}$ using the steady-state version of {eq}`EqFirmsMPKg_opt` From 5247f7a023ca5297dada115477a4f4e16c38e076 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Fri, 11 Aug 2023 16:37:26 -0400 Subject: [PATCH 05/26] update TPI algorithm for dyn firms --- docs/book/content/theory/equilibrium.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 1bf01d5bd..c02ea4ffb 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -146,7 +146,7 @@ The computational algorithm for solving for the steady-state follows the steps b 3. Use $\bar{r}^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $\bar{r}_{gov}^{i'}$ 4. Use $\bar{K}_g^{i'}$ and $\bar{Y}^{i''}$ in {eq}`EqFirmsMPKg_opt` for each industry $m$ to solve for the value of the marginal product of government capital in each industry, $\overline{MPK}_{g,m}^{i'}$ 5. Use $\boldsymbol{\overline{MPK}}_g^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{K}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ - 6. Use $\bar{Y}_m$, $\bar{L}_m$ in {eq}`EqStnrzFOC_L` to solve for the updates vector of prices, $\boldsymbol{\bar{p}}^{i'}$ + 6. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updates vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ 7. Use $\bar{r}_{p}^{i'}$ and $\bar{b}_{j,s}$ in {eq}`EqStnrzMarkClrBQ` to solve for updated aggregate bequests $\overline{BQ}^{i'}$. 8. Use $\bar{Y}^{i'}$ in the long-run aggregate transfers assumption {eq}`EqStnrzTfer` to get an updated value for total transfers to households $\overline{TR}^{i'}$. 9. Use $\bar{r}^{i'}$, $\bar{r}_{p}^{i}$, $\bar{w}^{i'}$, $\bar{n}_{j,s}$, and $\bar{b}_{j,s+1}$ in equation {eq}`EqSS_factor` to get an updated value for the income factor $factor^{i'}$. @@ -343,12 +343,12 @@ The stationary non-steady state (transition path) solution algorithm has followi 16. Using the law of motion of the stock of infrastructure, {eq}`EqStnrz_Kgmt`, and $\hat{I}_{g,t}$, solve for $\hat{K}_{g,t}^{i}$ 17. Find output and factor demands for M-1 industries: 1. By {eq}`EqMarkClrGoods_Mm1`, $\hat{Y}_{m,t}=\hat{C}_{m,t}$, where $\hat{C}_{m,t}$ is determined by {eq}`EqStnrzEqCmt` - 2. The capital-output ratio can be determined from the FOC for the firms' choice of capital: $\frac{\hat{K}_{m,t}}{\hat{Y}_{m,t}} = \gamma_m\left[\frac{r_t + \delta_{M,t} - \tau^{corp}_{m,t}\delta^{\tau}_{m,t} - \tau^{inv}_{m,t}\delta_{M,t}}{(1-\tau^{corp}_{m,t})p_{m,t}({Z}_{m,t})^\frac{\varepsilon_m -1}{\varepsilon_m}}\right]^{-\varepsilon_m}$ - 3. Capital demand can thus be found: $\hat{K}_{m,t} = \frac{\hat{K}_{m,t}}{\hat{Y}_{m,t}} * \hat{Y}_{m,t}$ - 4. Labor demand can be found by inverting the production function: + 2. The labor-output ratio can be determined from the FOC for the firms' choice of labor: $\frac{\hat{Y}_{m,t}}{\hat{L}_{m,t}} = \left(\hat{Z}_{m,t}\right)^{\varepsilon_m - 1}\frac{(1-\gamma_m - \gamma_{g,m})}{(\hat{w}_{t}p_{m,t})}$ + 3. Labor demand can thus be found: $\hat{L}_{m,t} = \frac{\hat{L}_{m,t}}{\hat{Y}_{m,t}} * \hat{Y}_{m,t}$ + 4. Capital demand can be found by inverting the production function: ```{math} - :label: EqTPI_solveL - \hat{L}_{m,t} = \left(\frac{\left(\frac{\hat{Y}_{m,t}}{Z_{m,t}}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{m}^{\frac{1}{\varepsilon_m}}\hat{K}_{m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}}\hat{K}_{g,m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{(1-\gamma_m-\gamma_{g,m})^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} + :label: EqTPI_solveK + \hat{K}_{m,t} = \left(\frac{\left(\frac{\hat{Y}_{m,t}}{Z_{m,t}}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}}\hat{K}_{g,m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}}- (1- \gamma_{m} - \gamma_{g,m})^{\frac{1}{\varepsilon_m}}\hat{L}_{m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{\gamma_m^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} ``` 5. Use the interest rate $r_t^*$ and labor demand $\hat{L}_{m,t}$ to solve for private capital demand at the world interest rate $\hat{K}_{m,t}^{r^*}$ using {eq}`EqFirmsMPKg_opt` ```{math} @@ -374,7 +374,7 @@ The stationary non-steady state (transition path) solution algorithm has followi 3. Use $r_t^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $r_{gov,t}^{i'}$ 4. Use $\hat{K}_{g,t}^{i'}$ and $\hat{Y}_t^{i''}$ in in {eq}`EqFirmsMPKg_opt` for each industry $m$ to solve for the value of the marginal product of government capital in each industry, $MPK_{g,m,t}^{i'}$ 5. Use $\boldsymbol{MPK}_{g,t}^{i'}$, $r_t^{i'}$, $r_{gov,t}^{i'}$, $\hat{D}_t^{i'}$, and $\hat{K}_t^{i'}$ to find the return on the households' investment portfolio, $r_{p,t}^{i'}$ - 6. Use $\hat{Y}_{m,t}$, $\hat{L}_{m,t}$ in {eq}`EqStnrzFOC_L` to solve for the updates vector of prices, $\boldsymbol{p}_t^{i'}$ + 6. Use $\hat{Y}_{m,t}$, $\hat{K}_{m,t}$ (for $m Date: Mon, 14 Aug 2023 11:14:36 -0400 Subject: [PATCH 06/26] add stationarized versions of new firm eqn's --- docs/book/content/theory/equilibrium.md | 4 +- docs/book/content/theory/firms.md | 2 +- docs/book/content/theory/stationarization.md | 47 ++++++++++++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index c02ea4ffb..6d64af57c 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -332,8 +332,8 @@ The stationary non-steady state (transition path) solution algorithm has followi 7. Determine from the quantity of the composite consumption good consumed by each household, $\hat{c}_{j,s,t}$, use equation {eq}`EqHH_cmDem` to determine consumption of each output good, $\hat{c}_{m,j,s,t}$ 8. Using $\hat{c}_{m,j,s,t}$ in {eq}`EqCmt`, solve for aggregate consumption of each output good, $\hat{C}_{m,t}$ 9. Given values for $n_{j,s,t}$ and $\hat{b}_{j,s+1,t+1}$ for all $j$, $s$, and $t$, solve for aggregate labor supply, $\hat{L}_t$, and savings, $B_t$ in each period - 1. Use $n_{j,s,t}$ and the stationarized labor market clearing equation {eq}`EqStnrzMarkClrLab` to get a value for $\hat{L}_t^{i}$. - 2. Use $\hat{b}_{j,s+1,t+1}$ and the stationarized expression for total savings by domestic households {eq}`EqStnrz_Bt`to solve for $\hat{B}_t^i$. + 1. Use $n_{j,s,t}$ and the stationarized labor market clearing equation {eq}`EqStnrzMarkClrLab` to get a value for $\hat{L}_t^{i}$. + 2. Use $\hat{b}_{j,s+1,t+1}$ and the stationarized expression for total savings by domestic households {eq}`EqStnrz_Bt`to solve for $\hat{B}_t^i$. 10. Solve for the exogenous government interest rate $r_{gov,t}^{i}$ using equation {eq}`EqUnbalGBC_rate_wedge`. 11. Use {eq}`EqStnrzTfer` to find $\hat{Y}_t^i$ from the guess of $\hat{TR}_t^i$ 12. Using the path of output from each industry, $\hat{Y}_{m,t}$, and the household savings and labor supply decisions, $\{n_{j,s,t},\hat{b}_{j,s+1,t+1}\}_{s=E+1}^{E+S}$, compute the path of stationarizaed total tax revenue, $\hat{Revenue}_{t}^{i}$. diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index db9b29d9f..4d83ce116 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -34,7 +34,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ```{math} :label: EqFirmsProfit \pi(K_{m,t}, L_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t} - \Psi(I_{m,t}, K_{m,t})\Bigr] - \\ - &\qquad\qquad\quad I_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t + &\qquad\qquad\quad I_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K^{\tau}_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t ``` Gross revenue for the firms is $p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t})$. Labor costs to the firm are $w_t L_{m,t}$, and investment, $I_{m,t}$ contributes to the capital stock through the following law of motion: diff --git a/docs/book/content/theory/stationarization.md b/docs/book/content/theory/stationarization.md index bf4787b10..8d2e9f7cd 100644 --- a/docs/book/content/theory/stationarization.md +++ b/docs/book/content/theory/stationarization.md @@ -49,6 +49,14 @@ The previous chapters derive all the equations necessary to solve for the steady - - $\hat{D}_t\equiv\frac{D_t}{e^{g_y t}\tilde{N}_t}$ - $p_{m,t} \equiv \frac{\tilde{p}_{m,t}}{\tilde{p}_{M,t}}$ +* - + - + - $\hat{I}_{m,t}\equiv\frac{I_{m,t}}{e^{g_y t}\tilde{N}_t}$ + - +* - + - + - $\hat{K}^{\tau}_{m,t}\equiv\frac{K^{\tau}_{m,t}}{e^{g_y t}\tilde{N}_t}$ + - ``` The usual definition of equilibrium would be allocations and prices such that households optimize {eq}`EqHH_ciDem2`, {eq}`EqHHeul_n`, {eq}`EqHHeul_b`, and {eq}`EqHHeul_bS`, firms optimize {eq}`EqFirmFOC_L` and {eq}`EqFirmFOC_K`, and markets clear {eq}`EqMarkClrLab`, {eq}`EqMarkClr_DtDdDf`, {eq}`EqMarkClr_KtKdKf`, {eq}`EqMarkClrGoods_Mm1`, {eq}`EqMarkClrGoods_M`, and {eq}`EqMarkClrBQ`. In this chapter, we show how to stationarize each of these characterizing equations so that we can use our fixed point methods described in Sections {ref}`SecEqlbSSsoln` and {ref}`SecEqlbNSSsoln` of Chapter {ref}`Chap_Eqm` to solve for the equilibria in the steady-state and transition path equilibrium definitions. @@ -132,8 +140,41 @@ The usual definition of equilibrium would be allocations and prices such that ho ```{math} :label: EqStnrzProfit - \hat{PR}_{m,t} &= (1 - \tau^{corp}_{m,t})\Bigl[F(\hat{K}_{m,t},\hat{K}_{g,m,t},\hat{L}_{m,t}) - \hat{w}_t \hat{L}_{m,t}\Bigr] - ... \\ - &\qquad\qquad\quad \bigl(r_t + \delta_{M,t}\bigr)\hat{K}_{m,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t}\hat{K}_{m,t} + \tau^{inv}_{m,t}\delta_{M,t}\hat{K}_{m,t} \quad\forall m,t + \pi(\hat{K}_{m,t}, \hat{L}_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(\hat{K}_{m,t},\hat{K}_{g,m,t},\hat{L}_{m,t}) - w_t \hat{L}_{m,t} - \Psi(\hat{I}_{m,t}, \hat{K}_{m,t})\Bigr] - \\ + &\qquad\qquad\quad \hat{I}_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}\hat{K}^{\tau}_{m,t} + \tau^{inv}_{m,t}\hat{I}_{m,t} \quad\forall m,t + ``` + + The stationarized version of the law of motion for the capital stock for industry $m$ is given by: + + ```{math} + :label: EqStnrz_Kgm + \hat{K}_{m,t+1} = \frac{(1 - \delta_M)\hat{K}_{m,t} + \hat{I}_{m,t}}{e^{g_y}(1 + \tilde{g}_{n,t+1})} \quad\forall m,t + ``` + + And the analogous stationarized version of the law of motion for the tax basis of the capital stock is given by: + + ```{math} + :label: EqStnrz_Ktaum + \hat{K}^{\tau}_{m,} = \frac{(1 - \delta^{\tau}_{m,t})\hat{K}^{\tau}_{m,t-1} + (1-\tau^{inv}_{m,t})\hat{I}_{m,t}}{e^{g_y}(1 + \tilde{g}_{n,t+1})} \quad\forall m,t + ``` + +The stationarized version of the capital adjustment cost function and it's first derivatives are given by: + + ```{math} + :label: EqStnrzAdjCosts + \Psi(\hat{I}_{m,t}, \hat{K}_{m,t}) = \frac{\psi}{2}\frac{\left(\frac{\hat{I}_{m,t}}{\hat{K}_{m,t}} - \mu_m \right)^2}{\frac{\hat{I}_{m,t}}{\hat{K}_{m,t}}} \quad\forall m,t + ``` + + ```{math} + :label: EqStnrzAdjCost_dKp1 + \frac{\partial \Psi(\hat{I}_{m,t},\hat{K}_{m,t})}{\partial \hat{K}_{m,t+1}} = \frac{\psi}{2}\frac{\left(\frac{\hat{I}_{m,t}}{\hat{K}_{m,t}}- \mu_{m}\right)}{\hat{I}_{t}}\left[1 -\mu\frac{\hat{K}_{m,t}}{\hat{I}_{m,t}}\right] \forall m,t + ``` + + and + + ```{math} + :label: EqStnrzAdjCost_dK + \frac{\partial \Psi(\hat{I}_{m,t},\hat{K}_{m,t})}{\partial \hat{K}_{m,t}} = \frac{-\psi}{2}\left(\frac{\hat{K}_{m,t+1}}{e^{g_y}(1+g_{n,t+1})\hat{I}^2_{m,t}}\right)\left(\frac{\hat{I}_{m,t}}{\hat{K}_{m,t}}-\mu\right)\left(\frac{\hat{I}_{m,t}}{\hat{K}_{m,t}}+\mu\right) \forall m,t ``` The firms' first order equation for labor demand {eq}`EqFirmFOC_L` is stationarized by dividing both sides by $e^{g_y t}$. This stationarizes the wage $\hat{w}_t$ on the left-hand-side and cancels out the $e^{g_y t}$ term in front of the right-hand-side. To complete the stationarization, we multiply and divide the $\frac{Y_{m,t}}{e^{g_y t}L_{m,t}}$ term on the right-hand-side by $\tilde{N}_t$. @@ -147,7 +188,7 @@ The usual definition of equilibrium would be allocations and prices such that ho ```{math} :label: EqStnrzFOC_K - r_t = (1 - \tau^{corp}_{m,t})p_{m,t}(Z_{m,t})^\frac{\varepsilon_m-1}{\varepsilon_m}\left[\gamma_m\frac{\hat{Y}_{m,t}}{\hat{K}_{m,t}}\right]^\frac{1}{\varepsilon_m} - \delta_{M,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t} + \tau^{inv}_{m,t}\delta_{M,t} \quad\forall m,t + r_{t+1} = \frac{(1 - \tau^{corp}_{m,t+1})\left(p_{m,t+1}(Z_{m,t+1})^\frac{\varepsilon_m-1}{\varepsilon_m}\left[\gamma_m\frac{\hat{Y}_{m,t+1}}{\hat{K}_{m,t+1}}\right]^\frac{1}{\varepsilon_m} - \frac{\partial \Psi(\hat{I}_{m,t+1},\hat{K}_{m,t+1})}{\partial \hat{K}_{m,t+1}}\right) + 1 - \delta_{m} + \tau^{corp}_{m,t+1}\delta^\tau_{m,t+1}\left[(1-\tau^{inv}_{m,t})(1-\delta^\tau_{m,t})-(1-\delta_m)(1-\tau^{inv}_{m,t+1})\right] - \tau^{inv}_{m,t+1}(1-\delta_{m})}{(1-\tau^{corp}_{m,t})\frac{\partial \Psi(\hat{I}_{m,t},\hat{K}_{m,t})}{\partial \hat{K}_{m,t+1}}+1 -\tau^{inv}_{m,t}-\tau^{corp}_{m,t}\delta^{\tau}_{m,t}(1-\tau^{inv}_{m,t})} - 1 \quad\forall m,t ``` A stationary version of the firms' gross revenue attributed to each factor of production {eq}`EqFirmsMargRevEq` is found by dividing both sides of the equation by $e^{g_y t}\tilde{N}_t$. From 4e80c7ac6afd783f7b0229d454b2624f59f916db Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 28 Nov 2023 09:28:18 -0500 Subject: [PATCH 07/26] add adj costs to market clearing --- docs/book/content/theory/market_clearing.md | 9 +++++++-- docs/book/content/theory/stationarization.md | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/book/content/theory/market_clearing.md b/docs/book/content/theory/market_clearing.md index 3d3a7d9b9..dbd3399e4 100644 --- a/docs/book/content/theory/market_clearing.md +++ b/docs/book/content/theory/market_clearing.md @@ -111,11 +111,11 @@ We also characterize here the law of motion for total bequests $BQ_t$. Although Y_{m,t} = C_{m,t} \quad\forall t \quad\text{and}\quad m=1,2,...M-1 ``` - The output of the $M$th industry can be used for private investment, infrastructure investment, government spending, and government debt.[^M_ind] As such, the market clearing condition in the $M$th industry will look more like the traditional $Y=C+I+G+NX$ expression.[^RCrates_note] + The output of the $M$th industry can be used for private investment, infrastructure investment, government spending, and government debt.[^M_ind] As such, the market clearing condition in the $M$th industry will look more like the traditional $Y=C+I+G+NX$ expression.[^RCrates_note] Note also that adjustment costs are paid in units of capital, which is the same units as the output of the $M$th industry. Therefore we must include the adjustment costs in the market clearing condition for the $M$th industry. ```{math} :label: EqMarkClrGoods_M - Y_{M,t} = C_{M,t} + I_{M,t} + I_{g,t} + G_t + r_{p,t} K^f_t + r_{p,t}D^f_t - (K^f_{t+1} - K^f_t) - \bigl(D^f_{t+1} - D^f_t\bigr) \quad\forall t + Y_{M,t} = C_{M,t} + I_{M,t} + I_{g,t} + G_t + r_{p,t} K^f_t + r_{p,t}D^f_t - (K^f_{t+1} - K^f_t) - \bigl(D^f_{t+1} - D^f_t\bigr) + \Psi_{M,t} \quad\forall t ``` where ```{math} @@ -124,6 +124,11 @@ We also characterize here the law of motion for total bequests $BQ_t$. Although &= K_{t+1} - (1 - \delta_{M,t})K_t \\ &= (K^d_{t+1} + K^f_{t+1}) - (1 - \delta_{M,t})(K^d_t + K^f_t) ``` +and + ```{math} + :label: EqMarkClrGoods_IMt + \Psi_{M,t} &\equiv \sum_{m=1}^M \Psi(I_{m,t},K_{m,t}) \quad\forall t \\ + ``` In the partially open economy, we must add to the right-hand-side of {eq}`EqMarkClrGoods_M` the output paid to the foreign owners of capital $r_{p,t} K^f_t$ and to the foreign holders of government debt $r_{p,t}D^f_t$. And we must subtract off the foreign inflow component $K^f_{t+1} - K^f_t$ from private capital investment as shown in the first term in parentheses on the right-hand-side of {eq}`EqMarkClrGoods_M`. You can see in the definition of private investment {eq}`EqMarkClrGoods_IMt` where this amount of foreign capital is part of $I_{M,t}$. diff --git a/docs/book/content/theory/stationarization.md b/docs/book/content/theory/stationarization.md index 8d2e9f7cd..5510815f8 100644 --- a/docs/book/content/theory/stationarization.md +++ b/docs/book/content/theory/stationarization.md @@ -405,7 +405,7 @@ The stationarized version of the capital adjustment cost function and it's first ```{math} :label: EqStnrzMarkClrGoods_M \hat{Y}_{M,t} &= \hat{C}_{M,t} + \hat{I}_{M,t} + \hat{I}_{g,t} + \hat{G}_t + r_{p,t} \hat{K}^f_t + r_{p,t}\hat{D}^f_t ... \\ - &\quad - \Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{K}^f_{t+1} - \hat{K}^f_t\Bigr) - \Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{D}^f_{t+1} - \hat{D}^f_t\Bigr) \quad\forall t + &\quad - \Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{K}^f_{t+1} - \hat{K}^f_t\Bigr) - \Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{D}^f_{t+1} - \hat{D}^f_t\Bigr) + \hat{\Psi}_{M,t} \quad\forall t ``` where ```{math} @@ -419,6 +419,11 @@ The stationarized version of the capital adjustment cost function and it's first &= e^{g_y}\bigl(1 + \tilde{g}_{n,t+1}\bigr)\hat{K}_{t+1} - (1 - \delta_{M,t})\hat{K}_t \\ &= e^{g_y}\bigl(1 + \tilde{g}_{n,t+1}\bigr)(\hat{K}^d_{t+1} + \hat{K}^f_{t+1}) - (1 - \delta_{M,t})(\hat{K}^d_t + \hat{K}^f_t) ``` + and + ```{math} + :label: EqStnrzMarkClrGoods_IMt + \hat{\Psi}_{M,t} &\equiv \sum_{m=1}^M \Psi(\hat{I}_{m,t},\hat{K}_{m,t}) \quad\forall t \\ + ``` We stationarize the law of motion for total bequests $BQ_t$ in {eq}`EqMarkClrBQ` by dividing both sides by $e^{g_y t}\tilde{N}_t$. Because the population levels in the summation are from period $t-1$, we must multiply and divide the summed term by $\tilde{N}_{t-1}$ leaving the term in the denominator of $1+\tilde{g}_{n,t}$. From c1da05b02666c58edb1e18c0a278b00888c072a2 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 28 Nov 2023 14:02:02 -0500 Subject: [PATCH 08/26] start on fin --- docs/book/content/theory/financial.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/book/content/theory/financial.md b/docs/book/content/theory/financial.md index 183acce46..464e15722 100644 --- a/docs/book/content/theory/financial.md +++ b/docs/book/content/theory/financial.md @@ -3,7 +3,7 @@ # Financial Intermediary -Domestic household wealth $W^d_{t}=B_{t}$ and foreign ownership of domestic assets $W^f_{t}$, both in terms of the numeraire good, are invested in a financial intermediary. This intermediary purchases a portfolio of government bonds and private capital in accordance with the domestic and foreign investor demand for these assets and then returns a single portfolio rate of return to all investors. +Domestic household wealth $W^d_{t}=B_{t}$ and foreign ownership of domestic assets $W^f_{t}$, both in terms of the numeraire good, are invested in a financial intermediary. This intermediary purchases a portfolio of government bonds and private equity in accordance with the domestic and foreign investor demand for these assets and then returns a single portfolio rate of return to all investors. Foreign demand for government bonds is specified in section {ref}`SecMarkClrMktClr_G` of the {ref}`Chap_MarkClr` chapter: @@ -19,14 +19,14 @@ This leaves domestic investors to buy up the residual amount of government debt: D^{d}_{t} = D_{t} - D^{f}_{t} \quad\forall t ``` -We assume that debt dominates the capital markets, such that domestic investor demand for capital, $K^{d}_{t}$ is given as: +We assume that debt dominates the capital markets, such that domestic investor demand for equity, $V^{d}_{t}$ is given as: ```{math} :label: eq_domestic_cap_demand - K^{d}_{t} = B_{t} - D^{d}_{t} \quad\forall t + V^{d}_{t} = B_{t} - D^{d}_{t} \quad\forall t ``` -Foreign demand for capital is given in {ref}`SecMarkClrMktClr_K`, where $K^{f}_{t}$ is an exogenous fraction of excess capital demand at the world interest rate: +Foreign demand for equity is given in {ref}`SecMarkClrMktClr_K`, where $V^{f}_{t}$ is an exogenous fraction of excess capital demand at the world interest rate: ```{math} :label: eq_foreign_cap_demand From 3dde6b017e222f02d820ac078bb3aaa85600e5df Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 5 Dec 2023 15:11:19 -0500 Subject: [PATCH 09/26] update MC with foreign outflows --- docs/book/content/theory/market_clearing.md | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/book/content/theory/market_clearing.md b/docs/book/content/theory/market_clearing.md index dbd3399e4..09288feef 100644 --- a/docs/book/content/theory/market_clearing.md +++ b/docs/book/content/theory/market_clearing.md @@ -62,32 +62,32 @@ We also characterize here the law of motion for total bequests $BQ_t$. Although (SecMarkClrMktClr_K)= - ### Private capital market clearing + ### Equity market clearing - Domestic firms in each industry $m$ rent private capital $K_t\equiv\sum_{m=1}^M K_{m,t}$ from domestic households $K^d_t$ and from foreign investors $K^f_t$. + Equity in domestic firms, $V_t\equiv\sum_{m=1}^M K_{m,t}$, is held by domestic households, $V^d_t$ and foreign investors $V^f_t$. The equity market clearing condition is thus: ```{math} :label: EqMarkClr_KtKdKf - K_t = K^d_t + K^f_t \quad\forall t \quad\text{where}\quad K_t \equiv \sum_{m=1}^M K_{m,t} + V_t = V^d_t + V^f_t \quad\forall t \quad\text{where}\quad V_t \equiv \sum_{m=1}^M V_{m,t} ``` - Assume that there exists some exogenous world interest rate $r^*_t$. We assume that foreign capital supply $K^f_t$ is an exogenous percentage $\zeta_K\in[0,1]$ of the excess total domestic private capital demand $ED^{K,r^*}_t$ that would exist if domestic private capital demand were determined by the exogenous world interest rate $r^*_t$ and domestic private capital supply were determined by the model consistent return on household savings $r_{p,t}$. This percentage $\zeta_K$ is something we calibrate. Define excess total domestic capital demand at the exogenous world interest rate $r^*_t$ as $ED^{K,r^*}_t$, where $K^{r^*}_t\equiv\sum_{m=1}^M K^{r^*}_{m,t}$ is the capital demand by domestic firms at the world interest rate $r^*_t$, and $K^{d}_t$ is the domestic supply of private capital to firms, which is modeled as being a function of the actual rate faced by households $r_{p,t}$. Then our measure of excess demand at the world interest rate is the following. + Assume that there exists some exogenous world interest rate $r^*_t$. We assume that foreign equity holdings, $V^f_t$, is an exogenous percentage $\zeta_K\in[0,1]$ of the excess total supply of domestic equity, $ES^{K,r^*}_t$ that would exist if domestic firm values were determined by investment decisions made under the exogenous world interest rate $r^*_t$ and domestic equity demand were determined by the model consistent return on household savings $r_{p,t}$. This percentage $\zeta_K$ is something we calibrate. Define excess supply of equity at the exogenous world interest rate $r^*_t$ as $ES^{V,r^*}_t$, where $V^{r^*}_t\equiv\sum_{m=1}^M V^{r^*}_{m,t}$ is value of domestic firms at the world interest rate $r^*_t$, and $V^{d}_t$ is the domestic demand for equity, which is modeled as being a function of the actual rate of return faced by households $r_{p,t}$. Then our measure of excess supply at the world interest rate is the following. ```{math} :label: EqMarkClr_ExDemK - ED^{K,r^*}_t \equiv K^{r^*}_t - K^d_t \quad\forall t \quad\text{where}\quad K^{r^*}_t\equiv \sum_{m=1}^M K^{r^*}_{m,t} + ES^{V,r^*}_t \equiv V^{r^*}_t - V^d_t \quad\forall t \quad\text{where}\quad V^{r^*}_t\equiv \sum_{m=1}^M V^{r^*}_{m,t} ``` - Then we assume that total foreign private capital supply $K^f_t$ is a fixed fraction of this excess capital demand at the world interest rate $r^*$. + Then we assume that total foreign private capital supply $V^f_t$ is a fixed fraction of this equity supply at the world interest rate $r^*$. ```{math} :label: EqMarkClr_zetaK - K^{f}_t = \zeta_{K}ED^{K,r^*}_t \quad\forall t + V^{f}_t = \zeta_{K}ES^{K,r^*}_t \quad\forall t ``` - This approach nicely nests the small open economy specification discussed in Section {ref}`SecSmallOpen` of Chapter {ref}`Chap_SmOpEcn` in which $\zeta_K=1$, foreigners flexibly supply all the excess demand for private capital, the marginal product of capital is fixed at the exogenous world interest rate $r^*$, and domestic households face the least amount of crowd out by government debt. The opposite extreme is the closed private capital market assumption of $\zeta_K=0$ in which $K^f_t=0$ and households must supply all the capital demanded in the domestic market. In this specification, the interest rate is the most flexible and adjusts to equilibrate domestic private capital supply $K^d_t$ with private capital demand $K_t$. + This approach nicely nests the small open economy specification discussed in Section {ref}`SecSmallOpen` of Chapter {ref}`Chap_SmOpEcn` in which $\zeta_K=1$, foreigners flexibly demand the excess supply of domestic equity, the domestic interest rate is fixed at the exogenous world interest rate $r^*$, and domestic households face the least amount of crowd out by government debt. The opposite extreme is the closed private capital market assumption of $\zeta_K=0$ in which $V^f_t=0$ and households must hold all the domestic firms' equity. In this specification, the interest rate is the most flexible and adjusts to equilibrate domestic equity demand, $V^d_t$, with the supply of equity, $V_t$. - For the intermediate specifications of $\zeta_K\in(0,1)$, foreigners provide a fraction of the excess demand defined in {eq}`EqMarkClr_ExDemK`. This allows for partial inflows of foreign private capital, partial crowd-out of government spending on private investment, and partial adjustment of the domestic interest rate $r_t$. This latter set of model specifications could be characterized as large-open economy or partial capital mobility. + For the intermediate specifications of $\zeta_K\in(0,1)$, foreigners provide a fraction of the excess supply of equity in {eq}`EqMarkClr_ExDemK`. This allows for partial inflows of foreign equity holdings, partial crowd-out of government spending on private investment, and partial adjustment of the domestic interest rate $r_t$. This latter set of model specifications could be characterized as large-open economy or partial capital mobility. (SecMarkClrMktClr_goods)= @@ -115,7 +115,7 @@ We also characterize here the law of motion for total bequests $BQ_t$. Although ```{math} :label: EqMarkClrGoods_M - Y_{M,t} = C_{M,t} + I_{M,t} + I_{g,t} + G_t + r_{p,t} K^f_t + r_{p,t}D^f_t - (K^f_{t+1} - K^f_t) - \bigl(D^f_{t+1} - D^f_t\bigr) + \Psi_{M,t} \quad\forall t + Y_{M,t} = C_{M,t} + I_{M,t} + I_{g,t} + G_t + r_{g,t}D^f_t - \Pi^f_{t} + (V^f_{t+1} - V^f_t) - \bigl(D^f_{t+1} - D^f_t\bigr) + \Psi_{M,t} \quad\forall t ``` where ```{math} @@ -129,6 +129,11 @@ and :label: EqMarkClrGoods_IMt \Psi_{M,t} &\equiv \sum_{m=1}^M \Psi(I_{m,t},K_{m,t}) \quad\forall t \\ ``` + and + ```{math} + :label: EqMarkClrGoods_Pi + \Pi^f_{t} &\equiv \sum_{m=1}^M \pi_{m,t} * \frac{V^f}{V} \quad\forall t \\ + ``` In the partially open economy, we must add to the right-hand-side of {eq}`EqMarkClrGoods_M` the output paid to the foreign owners of capital $r_{p,t} K^f_t$ and to the foreign holders of government debt $r_{p,t}D^f_t$. And we must subtract off the foreign inflow component $K^f_{t+1} - K^f_t$ from private capital investment as shown in the first term in parentheses on the right-hand-side of {eq}`EqMarkClrGoods_M`. You can see in the definition of private investment {eq}`EqMarkClrGoods_IMt` where this amount of foreign capital is part of $I_{M,t}$. From 8c27018b678d0a195b3554aa6a512610d7e9d8f0 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 5 Dec 2023 15:11:49 -0500 Subject: [PATCH 10/26] move from ED for captial to ES of equity --- docs/book/content/theory/open_economy.md | 16 ++++++++-------- docs/book/content/theory/stationarization.md | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/book/content/theory/open_economy.md b/docs/book/content/theory/open_economy.md index 045aef4e9..929eca7b1 100644 --- a/docs/book/content/theory/open_economy.md +++ b/docs/book/content/theory/open_economy.md @@ -1,11 +1,11 @@ (Chap_SmOpEcn)= # Open Economy Options -`OG-Core` offers a wide range of specifications regarding the type and degree of openness assumed in the economy. In none of our specifications do we fully model foreign economies as is done by {cite}`BenzellEtAl:2017` and others. However, one of the findings of {cite}`BenzellEtAl:2017` is that a full multi-country model is closely approximated by the types of large partial open economy specifications we use in `OG-Core`. Our specifications range from fully closed, to partially closed, to small open economy, to large open economy. We discuss some of these specifications in Chapter {ref}`Chap_MarkClr`. But the open economy assumptions only refer to how foreign capital can flow into the private capital market $K_t\equiv\sum_{m=1}^M K_{m,t}$ and into the government bond market $D_t$. The labor market and goods markets are closed. +`OG-Core` offers a wide range of specifications regarding the type and degree of openness assumed in the economy. In none of our specifications do we fully model foreign economies as is done by {cite}`BenzellEtAl:2017` and others. However, one of the findings of {cite}`BenzellEtAl:2017` is that a full multi-country model is closely approximated by the types of large partial open economy specifications we use in `OG-Core`. Our specifications range from fully closed, to partially closed, to small open economy, to large open economy. We discuss some of these specifications in Chapter {ref}`Chap_MarkClr`. But the open economy assumptions only refer to how foreign investment can flow into the equity market $V_t\equiv\sum_{m=1}^M V_{m,t}$ and into the government bond market $D_t$. The labor market and goods markets are closed. (SecSmallOpen)= ## Small Open Economy -In the small open economy version of `OG-Core`, the economy faces an exogenous world interest rate on capital $r^{*}_{t}$. The parameterization for this setting is $\zeta_K=1$. This implies that foreign capital flows freely into (out of) the country to take up all the excess demand (excess supply) and that firms face the world interest rate $r^{*}_{t}$ as the competitive, zero-profit rate of return on capital as the interest rate analogous to $r_t$ that goes into the profit function {eq}`EqFirmsProfit` of each firm in each industry, $r_{K,t}$ in {eq}`EqFirmsPayout` and {eq}`eq_rK`, $r_{gov,t}$ in {eq}`EqUnbalGBC_rate_wedge`, and $r_{p,t}$ in {eq}`eq_portfolio_return`. In this case, the rate of return on capital inside the country is exogenously fixed at $r^{*}_{t}$ {eq}`EqSmOpen_rstar_r`, and foreign private capital inflows $K^f_t$ are just the difference between total private capital demand $K_t\equiv\sum_{m=1}^M K_{m,t}$ by firms at the world interest rate and total domestic private capital supply by domestic households $K^d_t$ at the world interest rate. +In the small open economy version of `OG-Core`, the economy faces an exogenous world interest rate on capital $r^{*}_{t}$. The parameterization for this setting is $\zeta_K=1$. This implies that foreign investment flows freely into (out of) the country to take up all the excess demand (supply) and that the equilibrium rate of return on equity in the domestic market is equilibrated with the world interest rate $r^{*}_{t}$. To solve this parameterization of the model, we can assume the rate of return on capital inside the country is exogenously fixed at $r^{*}_{t}$ {eq}`EqSmOpen_rstar_r`, and foreign investor inflows, $V^f_t$, are just the difference between total value of firms when returning $r^{*}_{t}$, $V_t\equiv\sum_{m=1}^M V_{m,t}$, and total domestic holdings of equity by domestic households, $V^d_t$, at the world interest rate, $r^{*}_{t}$. ```{math} :label: EqSmOpen_rstar_r @@ -14,24 +14,24 @@ In the small open economy version of `OG-Core`, the economy faces an exogenous w ```{math} :label: EqSmOpen_Kft - K^f_t = K_t - K^d_t \quad\forall t \quad\text{where}\quad K_t\equiv\sum_{m=1}^M K_{m,t} + V^f_t = V_t - V^d_t \quad\forall t \quad\text{where}\quad V_t\equiv\sum_{m=1}^M V_{m,t} ``` (SecPartialOpen)= ## Partially Open Economy -The partially open economy is the default specification of `OG-Core` in which $0<\zeta_K,\zeta_D<1$. In this case, foreign flows of private capital $K^f_t$ and foreign holdings of government bonds $D^f_t$ partially supply the respective domestic demands for these two types of capital. The equations for this partially open specification are described in Sections {ref}`SecMarkClrMktClr_G` and {ref}`SecMarkClrMktClr_K` of Chapter {ref}`Chap_MarkClr`. +The partially open economy is the default specification of `OG-Core` in which $0<\zeta_K,\zeta_D<1$. In this case, foreign equity holdings, $V^f_t$, and foreign holdings of government bonds, $D^f_t$, partially satisfy the respective domestic demands for these two types of assets. The equations for this partially open specification are described in Sections {ref}`SecMarkClrMktClr_G` and {ref}`SecMarkClrMktClr_K` of Chapter {ref}`Chap_MarkClr`. -The partially open economy specification can also be referred to as a large open economy because changes in underlying policy or parameter assumptions will influence the equilibrium interest rate on private capital $r_t$, while the world interest rate $r^*_t$ remains fixed. The degree to which the domestic rental rate on private capital $r_t$ responds to policy parameter changes depends on the degree to which the economy is open. In the most open case, the small open economy specification described in Section {ref}`SecSmallOpen` with $\zeta_K=1$, foreign flows of private capital $K^f_t$ are the most flexible and the domestic interest rate is exogenously fixed at the world interest rate $r^*_t$. As $\zeta_K$ goes to 0, foreign private capital flows $K^f_t$ become less flexible and the domestic interest rate $r_t$ has to adjust more to make domestic private capital demand $K_t$ equal total private capital supply $K^d_t + K^f_t$. +The partially open economy specification can also be referred to as a large open economy because changes in underlying policy or parameter assumptions will influence the equilibrium interest rate on private capital $r_t$, while the world interest rate $r^*_t$ remains fixed. The degree to which the domestic interest rate, $r_t$, responds to policy parameter changes depends on the degree to which the economy is open. In the most open case, the small open economy specification described in Section {ref}`SecSmallOpen` with $\zeta_K=1$, foreign holdings of domestic equity, $V^f_t$, are the most responsive and the domestic interest rate is equilibrated to the world interest rate $r^*_t$. As $\zeta_K$ goes to 0, foreign equity holdings $V^f_t$ become less responsive to interest rate differentials and the domestic interest rate $r_t$ has to adjust more to make domestic equity supply, $V_t$, equal total demand to hold equities, $V^d_t + V^f_t$. -Note that in our partially open economy specification, the world interest rate $r^*_t$ is necessary for determining equilibrium because the foreign supply of private capital $K^f_t$ depends on a concept of excess demand that is based on domestic demand at the world interest rate {eq}`EqMarkClr_ExDemK`. It is also worth noting that our partially open economy specification is not a multi-country model in which the rest of the world or multiple other countries are explicitly modeled. In our specification, the rest of the world is simply modeled as the relationship between the domestic rental rate on private capital $r_t$ and the world interest rate $r^*_t$ as influenced by the supply of foreign private capital $\zeta_K$ and by foreign purchases of new issues of government bonds $\zeta_D$. +Note that in our partially open economy specification, the world interest rate $r^*_t$ is necessary for determining equilibrium because the foreign demand to hold domestic equities, $V^f_t$, depends on a concept of excess demand that is based on domestic demand at the world interest rate {eq}`EqMarkClr_ExDemK`. It is also worth noting that our partially open economy specification is not a multi-country model in which the rest of the world or multiple other countries are explicitly modeled. In our specification, the rest of the world is simply modeled as the relationship between the domestic interest rate, $r_t$, and the world interest rate, $r^*_t$, as influenced by foreign demand for domestic equity via $\zeta_K$ and by foreign purchases of new issues of government bonds via $\zeta_D$. (SecClosed)= ## Closed Economy -The closed economy specification in `OG-Core` is parameterized by $\zeta_D=0$ and $\zeta_K=0$ and is characterized as no foreign inflows of private capital. The government debt market clearing condition and the private capital market clearing condition are the following. +The closed economy specification in `OG-Core` is parameterized by $\zeta_D=0$ and $\zeta_K=0$ and is characterized as no foreign investment inflows. The government debt market clearing condition and the equity market clearing condition are the following. ```{math} :label: EqClosed_D @@ -40,7 +40,7 @@ The closed economy specification in `OG-Core` is parameterized by $\zeta_D=0$ an ```{math} :label: EqClosed_K - K_t = K^d_t \quad\forall t + V_t = V^d_t \quad\forall t ``` In the closed economy setting, the world interest rate $r^*_t$ is not relevant. diff --git a/docs/book/content/theory/stationarization.md b/docs/book/content/theory/stationarization.md index 5510815f8..b3dbd54f6 100644 --- a/docs/book/content/theory/stationarization.md +++ b/docs/book/content/theory/stationarization.md @@ -389,12 +389,12 @@ The stationarized version of the capital adjustment cost function and it's first ```{math} :label: EqStnrz_ExDemK - \hat{ED}^{K,r^*}_t \equiv \hat{K}^{r^*}_t - \hat{K}^d_t \quad\forall t \quad\text{where}\quad \hat{K}^{r^*}_t \equiv \sum_{m=1}^M \hat{K}^{r^*}_{m,t} + \hat{ES}^{K,r^*}_t \equiv \hat{V}^{r^*}_t - \hat{V}^d_t \quad\forall t \quad\text{where}\quad \hat{V}^{r^*}_t \equiv \sum_{m=1}^M \hat{V}^{r^*}_{m,t} ``` ```{math} :label: EqStnrz_zetaK - \hat{K}^{f}_t = \zeta_{K}\hat{ED}^{K,r^*}_t \quad\forall t + \hat{V}^{f}_t = \zeta_{K}\hat{ES}^{V,r^*}_t \quad\forall t ``` We stationarize the goods market clearing equations for the first $M-1$ industries {eq}`EqMarkClrGoods_Mm1` and for the $M$th industry {eq}`EqMarkClrGoods_M` by dividing both sides by $e^{g_y t}\tilde{N}_t$. On the right-hand-side, we must multiply and divide the $K^d_{t+1}$ term and the $D^f_{t+1}$ term, respectively, by $e^{g_y(t+1)}\tilde{N}_{t+1}$ leaving the coefficient $e^{g_y}(1+\tilde{g}_{n,t+1})$. From 888131161dc7691cb66e60f6d4ec232cd3b10910 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 5 Dec 2023 15:12:06 -0500 Subject: [PATCH 11/26] return on portfolio --- docs/book/content/theory/financial.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/docs/book/content/theory/financial.md b/docs/book/content/theory/financial.md index 464e15722..4c9004d80 100644 --- a/docs/book/content/theory/financial.md +++ b/docs/book/content/theory/financial.md @@ -3,7 +3,7 @@ # Financial Intermediary -Domestic household wealth $W^d_{t}=B_{t}$ and foreign ownership of domestic assets $W^f_{t}$, both in terms of the numeraire good, are invested in a financial intermediary. This intermediary purchases a portfolio of government bonds and private equity in accordance with the domestic and foreign investor demand for these assets and then returns a single portfolio rate of return to all investors. +Domestic household wealth $B_{t}$ is invested in a financial intermediary. This intermediary purchases a portfolio of government bonds and private capital in accordance with the domestic demand for these assets and then returns a single portfolio rate of return to all investors. Foreign demand for government bonds is specified in section {ref}`SecMarkClrMktClr_G` of the {ref}`Chap_MarkClr` chapter: @@ -26,33 +26,26 @@ We assume that debt dominates the capital markets, such that domestic investor d V^{d}_{t} = B_{t} - D^{d}_{t} \quad\forall t ``` -Foreign demand for equity is given in {ref}`SecMarkClrMktClr_K`, where $V^{f}_{t}$ is an exogenous fraction of excess capital demand at the world interest rate: +Foreign demand for equity is given in {ref}`SecMarkClrMktClr_K`, where $V^{f}_{t}$ is an exogenous fraction of excess equity demand: ```{math} :label: eq_foreign_cap_demand - K^{f}_t = \zeta_{K, t}ED^{K,r^*}_t \quad\forall t + V^{f}_t = \zeta_{K, t}ED^{V,r^*}_t \quad\forall t ``` The total amount invested in the financial intermediary is thus: ```{math} -W_{t} & = W^d_{t} + W^f_{t} \\ - & = D^d_t + K^d_t + D^f_t + K^f_t \\ - & = D_t + K_t + B_t & = D^d_t + V^d_t \\ ``` -Interest rates on private capital through the financial intermediary and on government bonds differ. The return on the portfolio of assets held in the financial intermediary is the weighted average of these two rates of return. As derived in {eq}`EqFirms_rKt` of Section {ref}`EqFirmsPosProfits`, the presence of public infrastructure in the production function means that the returns to private factors of production ($r_t$ and $w_t$) exhibit decreasing returns to scale.[^MoorePecoraro] It is assumed that competition ensures a zero profit condition among firms and the returns to public infrastructure through the returns of firms are captured by the financial intermediary and returned to share holders. The return on capital is therefore the sum of the (after-tax) returns to private and public capital. +The return on the portfolio of assets held in the financial intermediary is the weighted average of the return on equity and government debt. As derived in {eq}`EqFirms_rKt` of Section {ref}`EqFirmsPosProfits`, the presence of public infrastructure in the production function means that the returns to private factors of production ($r_t$ and $w_t$) exhibit decreasing returns to scale.[^MoorePecoraro]. These excess profits are returned to shareholders through the financial intermediary. -```{math} -:label: eq_rK - r_{K,t} = r_{t} + \frac{\sum_{m=1}^M(1 - \tau^{corp}_{m,t})p_{m,t}MPK_{g,m,t}K_{g,m,t}}{\sum_{m=1}^M K_{m,t}} \quad\forall t -``` - -The return on the portfolio of assets held by the financial intermediary is thus a weighted average of the return to government debt $r_{gov,t}$ from {eq}`EqUnbalGBC_rate_wedge` and the adjusted return on private capital $r_{K,t}$ from {eq}`eq_rK`. +The return on the portfolio of assets held by the financial intermediary is thus a weighted average of the return to government debt $r_{gov,t}$ from {eq}`EqUnbalGBC_rate_wedge` and the adjusted return on equity through the distribution of profits and capital gains: ```{math} :label: eq_portfolio_return - r_{p,t} = \frac{r_{gov,t}D_{t} + r_{K,t}K_{t}}{D_{t} + K_{t}} \quad\forall t \quad\text{where}\quad K_t \equiv \sum_{m=1}^M K_{m,t} + r_{p,t} = \frac{r_{gov,t}D_{t} + \Pi^d_{m,t} + (V^d_{t+1} - V^d_{t}) }{D_{t} + V^d_{t}} \quad\forall t \quad\text{where}\quad \Pi^d_t \equiv \sum_{m=1}^M \pi_{m,t} * \frac{V^d_{t}}{V_{t}} ``` (SecFinfootnotes)= From 115ede54aa8ec4bb1d8ce3bf3bae17b86d994165 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Tue, 5 Dec 2023 16:24:58 -0500 Subject: [PATCH 12/26] updates to SS algo: --- docs/book/content/theory/equilibrium.md | 60 ++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 6d64af57c..00f0adf70 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -58,15 +58,15 @@ The computational algorithm for solving for the steady-state follows the steps b 1. Use the techniques from Section {ref}`SecDemogPopSSTP` to solve for the steady-state population distribution vector $\boldsymbol{\bar{\omega}}$ and steady-state growth rate $\bar{g}_n$ of the exogenous population process. -2. Choose an initial guess for the values of the steady-state interest rate (the after-tax marginal product of capital) $\bar{r}^i$, wage rate $\bar{w}^i$, portfolio rate of return $\bar{r}_p^i$, output prices $\boldsymbol{\bar{p}}^i$ (note that $\bar{p}_M =1$ since it's the numeraire good), total bequests $\overline{BQ}^{\,i}$, total household transfers $\overline{TR}^{\,i}$, and income multiplier $factor^i$, where superscript $i$ is the index of the iteration number of the guess. +2. Choose an initial guess for the values of the steady-state interest rate (the after-tax rate of return on firm equity) $\bar{r}^i$, wage rate $\bar{w}^i$, portfolio rate of return $\bar{r}_p^i$, output prices $\boldsymbol{\bar{p}}^i$ (note that $\bar{p}_M =1$ since it's the numeraire good), total bequests $\overline{BQ}^{\,i}$, total household transfers $\overline{TR}^{\,i}$, and income multiplier $factor^i$, where superscript $i$ is the index of the iteration number of the guess. 1. Given $\boldsymbol{\bar{p}}^i$ find the price of consumption goods using {eq}`EqHH_pi2` - 2. From price of consumption goods, determine the price of the composite consumption good, $\bar{p}$ using equation {eq}`EqCompPnorm2` + 2. Using the prices of consumption goods, determine the price of the composite consumption good, $\bar{p}$ using equation {eq}`EqCompPnorm2` 3. Using {eq}`Eq_tr` with $\overline{TR}^{\,i}$, find transfers to each household, $\overline{tr}_{j,s}^i$ 4. Using the bequest transfer process, {eq}`Eq_bq` and aggregate bequests, $\overline{BQ}^{\,i}$, find $bq_{j,s}^i$ 5. Given values $\bar{p}$, $\bar{r}_{p}^i$, $\bar{w}^i$ $\overline{bq}_{j,s}^i$, $\overline{tr}_{j,s}^i$, and $factor^i$, solve for the steady-state household labor supply $\bar{n}_{j,s}$ and savings $\bar{b}_{j,s+1}$ decisions for all $j$ and $E+1\leq s\leq E+S$. - 1. Each of the $j\in 1,2,...J$ sets of $2S$ steady-state Euler equations can be solved separately. `OG-Core` parallelizes this process using the maximum number of processors possible (up to $J$ processors). Solve each system of Euler equations using a multivariate root-finder to solve the $2S$ necessary conditions of the household given by the following steady-state versions of stationarized household Euler equations {eq}`EqStnrz_eul_n`, {eq}`EqStnrz_eul_b`, and {eq}`EqStnrz_eul_bS` simultaneously for each $j$. + 1. Each of the $j\in 1,2,...J$ sets of $2S$ steady-state Euler equations can be solved separately. `OG-Core` parallelizes this process using the maximum number of processors available (up to $J$ processors). Solve each system of Euler equations using a multivariate root-finder to solve the $2S$ necessary conditions of the household given by the following steady-state versions of stationarized household Euler equations {eq}`EqStnrz_eul_n`, {eq}`EqStnrz_eul_b`, and {eq}`EqStnrz_eul_bS` simultaneously for each $j$. ```{math} :label: EqSS_HHBC @@ -90,9 +90,10 @@ The computational algorithm for solving for the steady-state follows the steps b :label: EqSS_HHeul_bS (\bar{c}_{j,E+S})^{-\sigma} = e^{-\sigma g_y}\chi^b_j(\bar{b}_{j,E+S+1})^{-\sigma} \quad\forall j ``` - 6. Determine from the quantity of the composite consumption good consumed by each household, $\bar{c}_{j,s}$, use equation {eq}`EqHH_cmDem` to determine consumption of each output good, $\bar{c}_{m,j,s}$ - 7. Using $\bar{c}_{m,j,s}$ in {eq}`EqCmt`, solve for aggregate consumption of each output good, $\bar{C}_{m}$ - 8. Given values for $\bar{n}_{j,s}$ and $\bar{b}_{j,s+1}$ for all $j$ and $s$, solve for steady-state labor supply, $\bar{L}$, savings, $\bar{B}$ + 6. From the quantity of the composite consumption good consumed by each household, $\bar{c}_{j,s}$, use equation {eq}`EqHH_cmDem` to determine consumption of each output good, $\bar{c}_{i,j,s}$ + 7. Using $\bar{c}_{i,j,s}$ in {eq}`EqCmt`, solve for aggregate consumption of each consumption good, $\bar{C}_{i}$ + 8. Using $\bar{C}_{i}$ in {eq}`EqMarkConsDemand`, solve for aggregate consumption of each output good, $\bar{C}_{m}$ + 9. Given values for $\bar{n}_{j,s}$ and $\bar{b}_{j,s+1}$ for all $j$ and $s$, solve for steady-state labor supply, $\bar{L}$, savings, $\bar{B}$ 1. Use $\bar{n}_{j,s}$ and the steady-state version of the stationarized labor market clearing equation {eq}`EqStnrzMarkClrLab` to get a value for $\bar{L}^{i}$. ```{math} @@ -105,13 +106,13 @@ The computational algorithm for solving for the steady-state follows the steps b :label: EqSS_Bt \bar{B} \equiv \frac{1}{1 + \bar{g}_{n}}\sum_{s=E+2}^{E+S+1}\sum_{j=1}^{J}\Bigl(\bar{\omega}_{s-1}\lambda_j\bar{b}_{j,s} + i_s\bar{\omega}_{s}\lambda_j\bar{b}_{j,s}\Bigr) ``` - 9. Solve for the exogenous government interest rate $\bar{r}_{gov}^{i}$ using equation {eq}`EqUnbalGBC_rate_wedge`. - 10. Use {eq}`EqStnrzTfer` to find $\bar{Y}^i$ from the guess of $\overline{TR}^i$ - 11. Use {eq}`EqStnrz_DY` to find $\bar{D}^i$ from $\bar{Y}^i$ - 12. Using $\bar{D}^i$, we can find foreign investor holdings of debt, $\bar{D}^{f,i}$ from {eq}`EqMarkClr_zetaD2` and then solve for domestic debt holdings through the debt market clearing condition: $\bar{D}^{d,i} = \bar{D}^i - \bar{D}^{f,i}$ - 13. Using $\bar{Y}^i$, find government infrastructure investment, $\bar{I}_{g}$ from {eq}`EqStnrz_Igt` - 14. Using the law of motion of the stock of infrastructure, {eq}`EqStnrz_Kgmt`, and $\bar{I}_{g}$, solve for $\bar{K}_{g}^{i}$ - 15. Find output and factor demands for M-1 industries: + 10. Solve for the exogenous government interest rate $\bar{r}_{gov}^{i}$ using equation {eq}`EqUnbalGBC_rate_wedge`. + 11. Use {eq}`EqStnrzTfer` to find $\bar{Y}^i$ from the guess of $\overline{TR}^i$ + 12. Use {eq}`EqStnrz_DY` to find $\bar{D}^i$ from $\bar{Y}^i$ + 13. Using $\bar{D}^i$, we can find foreign investor holdings of debt, $\bar{D}^{f,i}$ from {eq}`EqMarkClr_zetaD2` and then solve for domestic debt holdings through the debt market clearing condition: $\bar{D}^{d,i} = \bar{D}^i - \bar{D}^{f,i}$ + 14. Using $\bar{Y}^i$, find government infrastructure investment, $\bar{I}_{g}$ from {eq}`EqStnrz_Igt` + 15. Using the law of motion of the stock of infrastructure, {eq}`EqStnrz_Kgmt`, and $\bar{I}_{g}$, solve for $\bar{K}_{g}^{i}$ + 16. Find output and factor demands for M-1 industries: 1. By {eq}`EqMarkClrGoods_Mm1`, $\hat{Y}_{m,t}=\hat{C}_{m,t}$, where $\hat{C}_{m,t}$ is determined by {eq}`EqStnrzEqCmt` 2. The labor-output ratio can be determined from the FOC for the firms' choice of labor: $\frac{\bar{Y}_m}{\bar{L}_m} = \left(\bar{Z}_m\right)^{\varepsilon_m - 1}\frac{(1-\gamma_m - \gamma_{g,m})}{(\bar{w}\bar{p}_m)}$ @@ -121,35 +122,34 @@ The computational algorithm for solving for the steady-state follows the steps b :label: EqSS_solveK \bar{K}_{m} = \left(\frac{\left(\frac{\bar{Y}_m}{\bar{Z}_m}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}} \bar{K}_{g,m}^{\frac{\varepsilon_m-1}{\varepsilon_m}}- (1 - \gamma_{m} - \gamma_{g,m})^{\frac{1}{\varepsilon_m}}\bar{L}_m^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{\gamma_m^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} ``` - 5. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for private capital demand at the world interest rate $\bar{K}_m^{r^*}$ using the steady-state version of {eq}`EqFirmsMPKg_opt` + 5. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for private capital demand at the world interest rate $\bar{K}_m^{r^*}$ using the steady-state version of {eq}`EqFirmFOC_K`. NEED TO UPDATE EQ'N BELOW... ```{math} :label: EqSS_MPKg \bar{K}_m^{r^*} = \bar{L}_m\left(\frac{\bar{w}}{\frac{\bar{r} + \bar{\delta}_M - \bar{\tau}^{corp}_m\bar{\delta}^{\tau}_m - \bar{\tau}^{inv}_m\bar{\delta}_M}{1 - \bar{\tau}^{corp}_m}}\right)^{\varepsilon_m} \frac{\gamma_m}{(1 - \gamma_m - \gamma_{g,m})} ``` - - 16. Determine factor demands and output for industry $M$: + 6. Use $\bar{K}_m^{r^*}$ and $\bar{r}^*$ to find the value of equity at the world interest rate, $\bar{V}^*_m$. NOTE, ALOS NEED TO HAVE THE TAX BASIS FOR THE CAPITAL STOCK DETERMINED... + 17. Determine factor demands and output for industry $M$: 1. $\bar{L}_M = \bar{L} - \sum_{m=1}^{M-1}\bar{L}_{m}$ - 2. Find $\bar{K}_m^{r^*}$ using the steady-state version of {eq}`EqFirmsMPKg_opt` - 3. Find total capital supply, and the split between that from domestic and foreign households: $\bar{K}^{i'}$, $\bar{K}^d$, $\bar{K}^f$: - 1. We then use this to find foreign demand for domestic capital from {eq}`eq_foreign_cap_demand`: $\bar{K}^{f} = \bar{\zeta}_{K}\sum_{m=1}^{M}\bar{K}_m^{r^*}$ - 2. Using $\bar{D}^{d,i}$ we can then find domestic investors' holdings of private capital as the residual from their total asset holdings: , $\bar{K}^{d,i} = \bar{B}^i - \bar{D}^{d,i}$ - 3. Aggregate capital supply is then determined as $\bar{K}^{i'} = \bar{K}^{d,i} + \bar{K}^{f,i}$. - 4. $\bar{K}_M = \bar{K}^{i'} - \sum_{m=1}^{M-1}\bar{K}_{m}$ + 2. Find $\bar{V}_m^{r^*}$ using the steady-state version of {eq}`EqFirmFOC_K` (TODO: CHECK THIS) + 3. Find total supply of equity, and the split between that from domestic and foreign households: $\bar{V}^{i'}$, $\bar{V}^d$, $\bar{V}^f$: + 1. Use $\bar{V}_m^{r^*}$ to find foreign demand for domestic equity {eq}`eq_foreign_cap_demand`: $\bar{V}^{f} = \bar{\zeta}_{K}\sum_{m=1}^{M}\bar{V}_m^{r^*}$ + 2. Using $\bar{D}^{d,i}$ we can then find domestic investors' holdings of equity as the residual from their total asset holdings: , $\bar{V}^{d,i} = \bar{B}^i - \bar{D}^{d,i}$ + 3. Aggregate demand for equities is then determined as $\bar{V}^{i'} = \bar{V}^{d,i} + \bar{V}^{f,i}$. + 4. Solve for $\bar{K}_M = \bar{K}^{i'} - \sum_{m=1}^{M-1}\bar{K}_{m}$ TODO: Update this. Need to use V to find K, I think... maybe that marginal q = average q? Also, need to somewhere compute $\bar{\pi}_m^i$... this can also help to find V... 5. Use the factor demands and $\bar{K}_g$ in the production function for industry $M$ to find $\bar{Y}_M$. - 17. Find an updated value for GDP, $\bar{Y}^{i'} = \sum_{m=1}^{M} \bar{p}_m \bar{Y}_m$. - 18. Find a updated values for $\bar{I}_{g}$ and $\bar{K}_g$ using $\bar{Y}^{i'}$, equations {eq}`EqStnrz_Igt` and {eq}`EqStnrz_Kgmt` + 18. Find an updated value for GDP, $\bar{Y}^{i'} = \sum_{m=1}^{M} \bar{p}_m \bar{Y}_m$. + 19. Find a updated values for $\bar{I}_{g}$ and $\bar{K}_g$ using $\bar{Y}^{i'}$, equations {eq}`EqStnrz_Igt` and {eq}`EqStnrz_Kgmt` 3. Given updated inner-loop values based on initial guesses for outer-loop variables $\{\bar{r}_p^i, \bar{r}^i, \bar{w}^i, \boldsymbol{\bar{p}}, \overline{BQ}^i, \overline{TR}^i, factor^i\}$, solve for updated values of outer-loop variables $\{\bar{r}_p^{i'}, \bar{r}^{i'}, \bar{w}^{i'}, \boldsymbol{\bar{p}}^{i'}, \overline{BQ}^{i'}, \overline{TR}^{i'}, factor^{i'}\}$ using the remaining equations: 1. Use $\bar{Y}_M^{i'}$ and $\bar{K}_M^{i'}$ in {eq}`EqStnrzFOC_K` to solve for updated value of the rental rate on private capital $\bar{r}^{i'}$. 2. Use $\bar{Y}_M^{i'}$ and $\bar{L}_M^{i}$ in {eq}`EqStnrzFOC_L` to solve for updated value of the wage rate $\bar{w}^{i'}$. 3. Use $\bar{r}^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $\bar{r}_{gov}^{i'}$ - 4. Use $\bar{K}_g^{i'}$ and $\bar{Y}^{i''}$ in {eq}`EqFirmsMPKg_opt` for each industry $m$ to solve for the value of the marginal product of government capital in each industry, $\overline{MPK}_{g,m}^{i'}$ - 5. Use $\boldsymbol{\overline{MPK}}_g^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{K}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ - 6. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updates vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ - 7. Use $\bar{r}_{p}^{i'}$ and $\bar{b}_{j,s}$ in {eq}`EqStnrzMarkClrBQ` to solve for updated aggregate bequests $\overline{BQ}^{i'}$. - 8. Use $\bar{Y}^{i'}$ in the long-run aggregate transfers assumption {eq}`EqStnrzTfer` to get an updated value for total transfers to households $\overline{TR}^{i'}$. - 9. Use $\bar{r}^{i'}$, $\bar{r}_{p}^{i}$, $\bar{w}^{i'}$, $\bar{n}_{j,s}$, and $\bar{b}_{j,s+1}$ in equation {eq}`EqSS_factor` to get an updated value for the income factor $factor^{i'}$. + 4. Use $\boldsymbol{\overline{\Pi}}^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{V}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ + 5. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updates vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ + 6. Use $\bar{r}_{p}^{i'}$ and $\bar{b}_{j,s}$ in {eq}`EqStnrzMarkClrBQ` to solve for updated aggregate bequests $\overline{BQ}^{i'}$. + 7. Use $\bar{Y}^{i'}$ in the long-run aggregate transfers assumption {eq}`EqStnrzTfer` to get an updated value for total transfers to households $\overline{TR}^{i'}$. + 8. Use $\bar{r}^{i'}$, $\bar{r}_{p}^{i}$, $\bar{w}^{i'}$, $\bar{n}_{j,s}$, and $\bar{b}_{j,s+1}$ in equation {eq}`EqSS_factor` to get an updated value for the income factor $factor^{i'}$. ```{math} :label: EqSS_factor From 94cc8998ee7ce3635ba84dc8b74919975a696dd5 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 6 Dec 2023 11:31:16 -0500 Subject: [PATCH 13/26] update SS algo --- docs/book/content/theory/equilibrium.md | 46 +++++++++++++++++-------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 00f0adf70..5947a6520 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -122,27 +122,45 @@ The computational algorithm for solving for the steady-state follows the steps b :label: EqSS_solveK \bar{K}_{m} = \left(\frac{\left(\frac{\bar{Y}_m}{\bar{Z}_m}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - \gamma_{g,m}^{\frac{1}{\varepsilon_m}} \bar{K}_{g,m}^{\frac{\varepsilon_m-1}{\varepsilon_m}}- (1 - \gamma_{m} - \gamma_{g,m})^{\frac{1}{\varepsilon_m}}\bar{L}_m^{\frac{\varepsilon_m-1}{\varepsilon_m}}}{\gamma_m^{\frac{1}{\varepsilon_m}}}\right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} ``` - 5. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for private capital demand at the world interest rate $\bar{K}_m^{r^*}$ using the steady-state version of {eq}`EqFirmFOC_K`. NEED TO UPDATE EQ'N BELOW... + 5. The tax basis of the capital stock can be solved for using the steady-state version of the law of motion for the tax basis of the capital stock: - ```{math} - :label: EqSS_MPKg - \bar{K}_m^{r^*} = \bar{L}_m\left(\frac{\bar{w}}{\frac{\bar{r} + \bar{\delta}_M - \bar{\tau}^{corp}_m\bar{\delta}^{\tau}_m - \bar{\tau}^{inv}_m\bar{\delta}_M}{1 - \bar{\tau}^{corp}_m}}\right)^{\varepsilon_m} \frac{\gamma_m}{(1 - \gamma_m - \gamma_{g,m})} + ```{math} + :label: EqSS_MPK_tau + \bar{K}_m^{\tau} = \frac{(1-\tau^{inv})\delta_m \var{K}_{m}}{\delta^{\tau}_m} ``` - 6. Use $\bar{K}_m^{r^*}$ and $\bar{r}^*$ to find the value of equity at the world interest rate, $\bar{V}^*_m$. NOTE, ALOS NEED TO HAVE THE TAX BASIS FOR THE CAPITAL STOCK DETERMINED... + 6. Find $\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` + 7. Find the value of the firm in steady-state as $\bar{V}_{m} = \frac{$\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)$}{(1+\bar{r})}$ + 8. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for the value of the firm the world interest rate $\bar{V}_m^{r^*}$: + 1. Use $\bar{Y}_{m}$, $\bar{r}^*$, and $\bar{L}_m$ in {eq}`EqStnrzFOC_K` to solve for $\bar{K}_m^{r^*}$. + 2. Solve for $\bar{K}_m^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_m \var{K}^{r^*}_{m}}{\delta^{\tau}_m}$ + 3. Find $\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau, r^*}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` + 4. Find the value of the firm in steady-state under the world interest rate as $\bar{V}^{r^*}_{m} = \frac{\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau , r^*}_m, \bar{L}_m)$}{(1+\bar{r}^*)}$ 17. Determine factor demands and output for industry $M$: - 1. $\bar{L}_M = \bar{L} - \sum_{m=1}^{M-1}\bar{L}_{m}$ - 2. Find $\bar{V}_m^{r^*}$ using the steady-state version of {eq}`EqFirmFOC_K` (TODO: CHECK THIS) - 3. Find total supply of equity, and the split between that from domestic and foreign households: $\bar{V}^{i'}$, $\bar{V}^d$, $\bar{V}^f$: - 1. Use $\bar{V}_m^{r^*}$ to find foreign demand for domestic equity {eq}`eq_foreign_cap_demand`: $\bar{V}^{f} = \bar{\zeta}_{K}\sum_{m=1}^{M}\bar{V}_m^{r^*}$ - 2. Using $\bar{D}^{d,i}$ we can then find domestic investors' holdings of equity as the residual from their total asset holdings: , $\bar{V}^{d,i} = \bar{B}^i - \bar{D}^{d,i}$ - 3. Aggregate demand for equities is then determined as $\bar{V}^{i'} = \bar{V}^{d,i} + \bar{V}^{f,i}$. - 4. Solve for $\bar{K}_M = \bar{K}^{i'} - \sum_{m=1}^{M-1}\bar{K}_{m}$ TODO: Update this. Need to use V to find K, I think... maybe that marginal q = average q? Also, need to somewhere compute $\bar{\pi}_m^i$... this can also help to find V... - 5. Use the factor demands and $\bar{K}_g$ in the production function for industry $M$ to find $\bar{Y}_M$. + 1. $\bar{L}_M = \bar{L} - \sum_{m=1}^{M-1}\bar{L}_{m}$ + 2. Use $\bar{L}_{M}$ and $\bar{r}$ {eq}`EqStnrzFOC_K` to solve for $\bar{K}_M$. NOTE: may not be an analytical solution here so might have to use a root finder... + 3. Use the production function to find $\bar{Y}_M$. + 4. Solve for $\bar{K}_M^{\tau} = \frac{(1-\tau^{inv})\delta_M \var{K}^_{M}}{\delta^{\tau}_M}$ + 5. Find $\pi(\bar{K}_M, \bar{K}^{\tau}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` + 6. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_M$ to solve for the value of the firm the world interest rate $\bar{V}_M^{r^*}$: + 1. Use $\bar{L}_{M}$ and $\bar{r}^*$ {eq}`EqStnrzFOC_K` to solve for $\bar{K}_M^{r^*}$. NOTE: may not be an analytical solution here so might have to use a root finder... + 2. Solve for $\bar{K}_M^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_M \var{K}^{r^*}_{M}}{\delta^{\tau}_M}$ + 3. Find $\bar{pi}_M^{i'}=\pi(\bar{K}^{r^*}_M, \bar{K}^{\tau, r^*}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` + 4. Find the value of the firm in steady-state under the world interest rate as $\bar{V}^{r^*}_{M} = \frac{\pi(\bar{K}^{r^*}_M, \bar{K}^{\tau , r^*}_M, \bar{L}_M)}{(1+\bar{r}^*)}$ + 7. Find total supply of equity, and the split between that from domestic and foreign equity holdings: $\bar{V}^{i'}$, $\bar{V}^d$, $\bar{V}^f$: + 1. Use $\bar{V}_m^{r^*}$ to find foreign demand for domestic equity {eq}`eq_foreign_cap_demand`: $\bar{V}^{f} = \bar{\zeta}_{K}\sum_{m=1}^{M}\bar{ES}_m^{r^*} = \bar{\zeta}_{K}\sum_{m=1}^{M}(\bar{V}_m^{r^*} - \bar{V}_m$ + 2. Using $\bar{D}^{d,i}$ we can then find domestic investors' holdings of equity as the residual from their total asset holdings: , $\bar{V}^{d,i} = \bar{B}^i - \bar{D}^{d,i}$ + 3. Aggregate demand for equities is then determined as $\bar{V}^{i'} = \bar{V}^{d,i} + \bar{V}^{f,i}$. + 8. Use the equity market clearing condition, {eq}`EqStnrz_VtVdVf`, to find the value of the $M$th firm, $\bar{V}_M$: + + ```{math} + :label: EqSS_V_M + \bar{V}_m = \bar{V}^{i'} - \sum_{m=1}^{M-1}\bar{V}_{m} + ``` 18. Find an updated value for GDP, $\bar{Y}^{i'} = \sum_{m=1}^{M} \bar{p}_m \bar{Y}_m$. 19. Find a updated values for $\bar{I}_{g}$ and $\bar{K}_g$ using $\bar{Y}^{i'}$, equations {eq}`EqStnrz_Igt` and {eq}`EqStnrz_Kgmt` 3. Given updated inner-loop values based on initial guesses for outer-loop variables $\{\bar{r}_p^i, \bar{r}^i, \bar{w}^i, \boldsymbol{\bar{p}}, \overline{BQ}^i, \overline{TR}^i, factor^i\}$, solve for updated values of outer-loop variables $\{\bar{r}_p^{i'}, \bar{r}^{i'}, \bar{w}^{i'}, \boldsymbol{\bar{p}}^{i'}, \overline{BQ}^{i'}, \overline{TR}^{i'}, factor^{i'}\}$ using the remaining equations: - 1. Use $\bar{Y}_M^{i'}$ and $\bar{K}_M^{i'}$ in {eq}`EqStnrzFOC_K` to solve for updated value of the rental rate on private capital $\bar{r}^{i'}$. + 1. Use $\bar{pi}_M^{i'}$ and $\bar{V}_M^{i'}$ in {eq}`EqFirmsExpectedReturn` to solve for updated value of the pre-tax return on equity, $\bar{r}^{i'}$. 2. Use $\bar{Y}_M^{i'}$ and $\bar{L}_M^{i}$ in {eq}`EqStnrzFOC_L` to solve for updated value of the wage rate $\bar{w}^{i'}$. 3. Use $\bar{r}^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $\bar{r}_{gov}^{i'}$ 4. Use $\boldsymbol{\overline{\Pi}}^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{V}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ From 45c336dae96af00ffa727ad5e5d6279aac9b7156 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 6 Dec 2023 11:31:24 -0500 Subject: [PATCH 14/26] fix typo --- docs/book/content/theory/firms.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index 4d83ce116..b24a71c43 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -33,7 +33,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ```{math} :label: EqFirmsProfit - \pi(K_{m,t}, L_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t} - \Psi(I_{m,t}, K_{m,t})\Bigr] - \\ + \pi(K_{m,t}, K^{\tau}_{m,t}, L_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t} - \Psi(I_{m,t}, K_{m,t})\Bigr] - \\ &\qquad\qquad\quad I_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K^{\tau}_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t ``` From 8803553779687a247d81928dc0f03e9724841e2e Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 6 Dec 2023 14:59:45 -0500 Subject: [PATCH 15/26] fix typos --- docs/book/content/theory/equilibrium.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 5947a6520..73d46bbaa 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -126,24 +126,24 @@ The computational algorithm for solving for the steady-state follows the steps b ```{math} :label: EqSS_MPK_tau - \bar{K}_m^{\tau} = \frac{(1-\tau^{inv})\delta_m \var{K}_{m}}{\delta^{\tau}_m} + \bar{K}_m^{\tau} = \frac{(1-\tau^{inv})\delta_m \bar{K}_{m}}{\delta^{\tau}_m} ``` 6. Find $\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` - 7. Find the value of the firm in steady-state as $\bar{V}_{m} = \frac{$\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)$}{(1+\bar{r})}$ + 7. Find the value of the firm in steady-state as: $\bar{V}_{m} = \frac{\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)}{(1+\bar{r})}$ 8. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for the value of the firm the world interest rate $\bar{V}_m^{r^*}$: 1. Use $\bar{Y}_{m}$, $\bar{r}^*$, and $\bar{L}_m$ in {eq}`EqStnrzFOC_K` to solve for $\bar{K}_m^{r^*}$. - 2. Solve for $\bar{K}_m^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_m \var{K}^{r^*}_{m}}{\delta^{\tau}_m}$ + 2. Solve for $\bar{K}_m^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_m \bar{K}^{r^*}_{m}}{\delta^{\tau}_m}$ 3. Find $\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau, r^*}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` - 4. Find the value of the firm in steady-state under the world interest rate as $\bar{V}^{r^*}_{m} = \frac{\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau , r^*}_m, \bar{L}_m)$}{(1+\bar{r}^*)}$ + 4. Find the value of the firm in steady-state under the world interest rate as $\bar{V}^{r^*}_{m} = \frac{\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau , r^*}_m, \bar{L}_m)}{(1+\bar{r}^*)}$ 17. Determine factor demands and output for industry $M$: 1. $\bar{L}_M = \bar{L} - \sum_{m=1}^{M-1}\bar{L}_{m}$ 2. Use $\bar{L}_{M}$ and $\bar{r}$ {eq}`EqStnrzFOC_K` to solve for $\bar{K}_M$. NOTE: may not be an analytical solution here so might have to use a root finder... 3. Use the production function to find $\bar{Y}_M$. - 4. Solve for $\bar{K}_M^{\tau} = \frac{(1-\tau^{inv})\delta_M \var{K}^_{M}}{\delta^{\tau}_M}$ + 4. Solve for $\bar{K}_M^{\tau} = \frac{(1-\tau^{inv})\delta_M \bar{K}_{M}}{\delta^{\tau}_M}$ 5. Find $\pi(\bar{K}_M, \bar{K}^{\tau}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` 6. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_M$ to solve for the value of the firm the world interest rate $\bar{V}_M^{r^*}$: 1. Use $\bar{L}_{M}$ and $\bar{r}^*$ {eq}`EqStnrzFOC_K` to solve for $\bar{K}_M^{r^*}$. NOTE: may not be an analytical solution here so might have to use a root finder... - 2. Solve for $\bar{K}_M^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_M \var{K}^{r^*}_{M}}{\delta^{\tau}_M}$ + 2. Solve for $\bar{K}_M^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_M \bar{K}^{r^*}_{M}}{\delta^{\tau}_M}$ 3. Find $\bar{pi}_M^{i'}=\pi(\bar{K}^{r^*}_M, \bar{K}^{\tau, r^*}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` 4. Find the value of the firm in steady-state under the world interest rate as $\bar{V}^{r^*}_{M} = \frac{\pi(\bar{K}^{r^*}_M, \bar{K}^{\tau , r^*}_M, \bar{L}_M)}{(1+\bar{r}^*)}$ 7. Find total supply of equity, and the split between that from domestic and foreign equity holdings: $\bar{V}^{i'}$, $\bar{V}^d$, $\bar{V}^f$: @@ -185,9 +185,9 @@ The computational algorithm for solving for the steady-state follows the steps b ``` 1. Make sure that steady-state government spending is nonnegative $\bar{G}\geq 0$. If steady-state government spending is negative, that means the government is getting resources to supply the debt from outside the economy each period to stabilize the debt-to-GDP ratio. $\bar{G}<0$ is a good indicator of unsustainable policies. - 1. Make sure that the resource constraint (goods market clearing) {eq}`EqStnrzMarkClrGoods_M` is satisfied. It is redundant, but this is a good check as to whether everything worked correctly. - 2. Make sure that the government budget constraint {eq}`EqStnrzGovBC` binds. - 3. Make sure that all the $2JS$ household Euler equations are solved to a satisfactory tolerance. + 2. Make sure that the resource constraint (goods market clearing) {eq}`EqStnrzMarkClrGoods_M` is satisfied. It is redundant, but this is a good check as to whether everything worked correctly. + 3. Make sure that the government budget constraint {eq}`EqStnrzGovBC` binds. + 4. Make sure that all the $2JS$ household Euler equations are solved to a satisfactory tolerance. 2. If the distance metric of the original value of the outer-loop variables and the updated values is greater than the tolerance $toler_{ss,out}$, then an updated initial guess for the outer-loop variables is made as a convex combination of the first guess and the updated guess and steps (2) through (4) are repeated. From c6d646d6454d8f2751be6244ccad60605d333feb Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 7 Dec 2023 12:33:40 -0500 Subject: [PATCH 16/26] add adj cost deriv functions and tests --- ogcore/firm.py | 58 +++++++++++++++++++++++++++++++++++++++++++++- tests/test_firm.py | 43 ++++++++++++++++++++++++++++++---- 2 files changed, 95 insertions(+), 6 deletions(-) diff --git a/ogcore/firm.py b/ogcore/firm.py index d134f5528..10674fcef 100644 --- a/ogcore/firm.py +++ b/ogcore/firm.py @@ -684,7 +684,7 @@ def solve_L(Y, K, K_g, p, method, m=-1): def adj_cost(K, Kp1, p, method): r""" - Firm capital adjstment costs + Firm capital adjustment costs ..math:: \Psi(K_{t}, K_{t+1}) = \frac{\psi}{2}\biggr(\frac{\biggr(\frac{I_{t}}{K_{t}}-\mu\biggl)^{2}}{\frac{I_{t}}{K_{t}}}\biggl) @@ -707,3 +707,59 @@ def adj_cost(K, Kp1, p, method): Psi = ((p.psi / 2) * (Inv / K - p.mu) ** 2) / (Inv / K) return Psi + + +def adj_cost_dK(K, Kp1, p, method): + r""" + The derivative of firm capital adjustment costs with respect to the + capital stock. + + ..math:: + \frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t}} = \frac{-\psi}{2}\left(\frac{K_{m,t+1}}{I^2_{m,t}}\right)\left(\frac{I_{m,t}}{K_{m,t}}-\mu\right)\left(\frac{I_{m,t}}{K_{m,t}}+\mu\right) \forall m,t + + Args: + K (array-like): Current period capital stock + Kp1 (array-like): One-period ahead capital stock + p (OG-USA Parameters class object): Model parameters + method (str): 'SS' or 'TPI' + + Returns + dPsi (array-like): The derivative of capital adjustment costs + """ + if method == "SS": + ac_method = "total_ss" + else: + ac_method = "total_tpi" + Inv = aggr.get_I(None, Kp1, K, p, ac_method) + + dPsi = ((-1 * p.psi / 2) * (Kp1 / Inv ** 2) * (Inv / K - p.mu) * (Inv / K + p.mu)) + + return dPsi + + +def adj_cost_dKp1(K, Kp1, p, method): + r""" + The derivative of firm capital adjustment costs with respect to next + periods capital stock. + + ..math:: + \frac{\partial \Psi(I_{m,t},K_{m,t})}{\partial K_{m,t+1}} = \frac{\psi}{2}\frac{\left(\frac{I_{m,t}}{K_{m,t}}- \mu_{m}\right)}{I_{t}}\left[1 -\mu\frac{K_{m,t}}{I_{m,t}}\right] \forall m,t + + Args: + K (array-like): Current period capital stock + Kp1 (array-like): One-period ahead capital stock + p (OG-USA Parameters class object): Model parameters + method (str): 'SS' or 'TPI' + + Returns + dPsi (array-like): The derivative of capital adjustment costs + """ + if method == "SS": + ac_method = "total_ss" + else: + ac_method = "total_tpi" + Inv = aggr.get_I(None, Kp1, K, p, ac_method) + + dPsi = ((p.psi / 2) * ((Inv / K - p.mu) / Inv) * (1 - p.mu * (K / Inv))) + + return dPsi \ No newline at end of file diff --git a/tests/test_firm.py b/tests/test_firm.py index 3bcbc8553..36330475d 100644 --- a/tests/test_firm.py +++ b/tests/test_firm.py @@ -1,4 +1,3 @@ -from math import exp import pytest from ogcore import firm import numpy as np @@ -976,8 +975,8 @@ def test_solve_L(Y, K, Kg, p, method, expected): K_2 = 6 Kp1_2 = 6 expected_Psi_2 = 0.011527985 -expected_dPsidK_2 = -0.122196836 -expected_dPsidKp1_2 = 0.102296044 +expected_dPsidK_2 = -0.102296044 +expected_dPsidKp1_2 = 0.023880951 p3 = Specifications() @@ -991,8 +990,8 @@ def test_solve_L(Y, K, Kg, p, method, expected): K_3 = np.array([4, 4.5, 5.5]) Kp1_3 = np.array([4.5, 5.5, 5]) expected_Psi_3 = np.array([0.309124823, 0.534408906, -1.520508524]) -expected_dPsidK_3 = np.array([-0.805820108, -0.846107505, 2.657143029]) -expected_dPsidKp1_3 = np.array([0.479061039, 0.43588367, -62.31580895]) +expected_dPsidK_3 = np.array([-0.538943669, -0.532746708, 56.65073541]) +expected_dPsidKp1_3 = np.array([0.316298002, 0.329639281, 72.59138531]) @pytest.mark.parametrize( @@ -1010,3 +1009,37 @@ def test_adj_cost(K, Kp1, p, method, expected): """ test_val = firm.adj_cost(K, Kp1, p, method) assert np.allclose(test_val, expected) + + +@pytest.mark.parametrize( + "K,Kp1,p,method,expected", + [ + (K_1, Kp1_1, p1, "SS", expected_dPsidK_1), + (K_2, Kp1_2, p2, "SS", expected_dPsidK_2), + (K_3, Kp1_3, p3, "TPI", expected_dPsidK_3), + ], + ids=["Zero cost", "Non-zero cost", "TPI"], +) +def test_adj_cost_dK(K, Kp1, p, method, expected): + """ + Test of the firm capital adjustment cost function. + """ + test_val = firm.adj_cost_dK(K, Kp1, p, method) + assert np.allclose(test_val, expected) + + +@pytest.mark.parametrize( + "K,Kp1,p,method,expected", + [ + (K_1, Kp1_1, p1, "SS", expected_dPsidKp1_1), + (K_2, Kp1_2, p2, "SS", expected_dPsidKp1_2), + (K_3, Kp1_3, p3, "TPI", expected_dPsidKp1_3), + ], + ids=["Zero cost", "Non-zero cost", "TPI"], +) +def test_adj_cost_dKp1(K, Kp1, p, method, expected): + """ + Test of the firm capital adjustment cost function. + """ + test_val = firm.adj_cost_dKp1(K, Kp1, p, method) + assert np.allclose(test_val, expected) \ No newline at end of file From 4954a2dd4d9f9add4939f8dbfc90162c8fe88048 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 7 Dec 2023 12:34:15 -0500 Subject: [PATCH 17/26] fix typo --- docs/book/content/theory/equilibrium.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 73d46bbaa..30ab4ff56 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -164,7 +164,7 @@ The computational algorithm for solving for the steady-state follows the steps b 2. Use $\bar{Y}_M^{i'}$ and $\bar{L}_M^{i}$ in {eq}`EqStnrzFOC_L` to solve for updated value of the wage rate $\bar{w}^{i'}$. 3. Use $\bar{r}^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $\bar{r}_{gov}^{i'}$ 4. Use $\boldsymbol{\overline{\Pi}}^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{V}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ - 5. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updates vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ + 5. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updated vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ 6. Use $\bar{r}_{p}^{i'}$ and $\bar{b}_{j,s}$ in {eq}`EqStnrzMarkClrBQ` to solve for updated aggregate bequests $\overline{BQ}^{i'}$. 7. Use $\bar{Y}^{i'}$ in the long-run aggregate transfers assumption {eq}`EqStnrzTfer` to get an updated value for total transfers to households $\overline{TR}^{i'}$. 8. Use $\bar{r}^{i'}$, $\bar{r}_{p}^{i}$, $\bar{w}^{i'}$, $\bar{n}_{j,s}$, and $\bar{b}_{j,s+1}$ in equation {eq}`EqSS_factor` to get an updated value for the income factor $factor^{i'}$. From 97e299dbf1f08a6007ba7f61917ea06912c1e8a7 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 7 Dec 2023 12:34:31 -0500 Subject: [PATCH 18/26] update V excess supply --- docs/book/content/theory/stationarization.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/book/content/theory/stationarization.md b/docs/book/content/theory/stationarization.md index b3dbd54f6..7d19112d8 100644 --- a/docs/book/content/theory/stationarization.md +++ b/docs/book/content/theory/stationarization.md @@ -383,13 +383,13 @@ The stationarized version of the capital adjustment cost function and it's first The private capital market clearing equation {eq}`EqMarkClr_KtKdKf` is stationarized by dividing both sides by $e^{g_y t}\tilde{N}_t$, as is the expression for excess demand at the world interest rate {eq}`EqMarkClr_ExDemK` and the exogenous expression for foreign private capital flows {eq}`EqMarkClr_zetaK`. ```{math} - :label: EqStnrz_KtKdKf - \hat{K}_t = \hat{K}^d_t + \hat{K}^f_t \quad\forall t \quad\text{where}\quad \hat{K_t} \equiv \sum_{m=1}^M \hat{K}_{m,t} + :label: EqStnrz_VtVdVf + \hat{V}_t = \hat{V}^d_t + \hat{V}^f_t \quad\forall t \quad\text{where}\quad \hat{V_t} \equiv \sum_{m=1}^M \hat{V}_{m,t} ``` ```{math} :label: EqStnrz_ExDemK - \hat{ES}^{K,r^*}_t \equiv \hat{V}^{r^*}_t - \hat{V}^d_t \quad\forall t \quad\text{where}\quad \hat{V}^{r^*}_t \equiv \sum_{m=1}^M \hat{V}^{r^*}_{m,t} + \hat{ES}^{V,r^*}_t \equiv \hat{V}^{r^*}_t - \hat{V}^d_t \quad\forall t \quad\text{where}\quad \hat{V}^{r^*}_t \equiv \sum_{m=1}^M \hat{V}^{r^*}_{m,t} ``` ```{math} From 475ee215f072a97cd02d75966d28c61c2432fdb6 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 7 Dec 2023 15:15:30 -0500 Subject: [PATCH 19/26] add profit, update cost of capital --- ogcore/firm.py | 136 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 13 deletions(-) diff --git a/ogcore/firm.py b/ogcore/firm.py index 10674fcef..9f0108e87 100644 --- a/ogcore/firm.py +++ b/ogcore/firm.py @@ -497,7 +497,7 @@ def get_K(r, w, L, p, method, m=-1): return K -def get_cost_of_capital(r, p, method, m=-1): +def get_cost_of_capital(r, K, Kp1, Km1, p, method, m=-1): r""" Compute the cost of capital. @@ -517,43 +517,95 @@ def get_cost_of_capital(r, p, method, m=-1): if m is None: if method == "SS": tau_b = p.tau_b[-1, :] + tau_b_m1 = tau_b delta_tau = p.delta_tau[-1, :] + delta_tau_m1 = delta_tau tau_inv = p.inv_tax_credit[-1, :] + tau_inv_m1 = tau_inv else: tau_b = p.tau_b[: p.T, :] + # tau_b_m1 = p.tau_b[: p.T - 1, :] Append what to the front of this?? delta_tau = p.delta_tau[: p.T, :] tau_inv = p.inv_tax_credit[: p.T, :] r = r.reshape(p.T, 1) else: if method == "SS": tau_b = p.tau_b[-1, m] + tau_b_m1 = tau_b delta_tau = p.delta_tau[-1, m] + delta_tau_m1 = delta_tau tau_inv = p.inv_tax_credit[-1, m] + tau_inv_m1 = tau_inv else: tau_b = p.tau_b[: p.T, m] delta_tau = p.delta_tau[: p.T, m] tau_inv = p.inv_tax_credit[: p.T, m] r = r.reshape(p.T) - cost_of_capital = (r + p.delta - tau_b * delta_tau - tau_inv * p.delta) / ( + # cost_of_capital = (r + p.delta - tau_b * delta_tau - tau_inv * p.delta) / ( + # 1 - tau_b + # ) + dPsidKp1_t = adj_cost_dKp1(Km1, K, p, method) + dPsidK_t = adj_cost_dK(K, Kp1, p, method) + cost_of_capital = ( + (1 + r) * (((1-tau_b_m1) * dPsidKp1_t) + 1 - + tau_inv_m1 - tau_b_m1 * delta_tau_m1 * (1 - tau_inv_m1)) -1 + p.delta - tau_b * delta_tau * ((1 - tau_inv_m1) * (1 - delta_tau_m1) - (1 - p.delta) * (1 - tau_inv)) + tau_inv* (1 - p.delta)) / ( 1 - tau_b - ) + ) + dPsidK_t return cost_of_capital -def get_pm(w, Y_vec, L_vec, p, method): +# def get_pm(w, Y_vec, L_vec, p, method): +# r""" +# Find prices for outputs from each industry. + +# .. math:: +# p_{m,t}=\frac{w_{t}}{\left((1-\gamma_m-\gamma_{g,m}) +# \frac{\hat{Y}_{m,t}}{\hat{L}_{m,t}}\right)^{\varepsilon_m}} + +# Args: +# w (array_like): the wage rate +# Y_vec (array_like): output for each industry +# L_vec (array_like): labor demand for each industry +# p (OG-Core Specifications object): model parameters +# method (str): adjusts calculation dimensions based on 'SS' or 'TPI' + +# Returns: +# p_m (array_like): output prices for each industry +# """ +# if method == "SS": +# Y = Y_vec.reshape(1, p.M) +# L = L_vec.reshape(1, p.M) +# T = 1 +# else: +# Y = Y_vec.reshape((p.T, p.M)) +# L = L_vec.reshape((p.T, p.M)) +# T = p.T +# p_m = np.zeros((T, p.M)) +# for m in range(p.M): # TODO: try to get rid of this loop +# MPL = get_MPx( +# Y[:, m], L[:, m], 1 - p.gamma[m] - p.gamma_g[m], p, method, m +# ).reshape(T) +# p_m[:, m] = w / MPL +# if method == "SS": +# p_m = p_m.reshape(p.M) +# return p_m + + +def get_pm(w, Y_vec, K_vec, Kp1_vec, Km1_vec, p, method): r""" Find prices for outputs from each industry. .. math:: - p_{m,t}=\frac{w_{t}}{\left((1-\gamma_m-\gamma_{g,m}) - \frac{\hat{Y}_{m,t}}{\hat{L}_{m,t}}\right)^{\varepsilon_m}} + p_{m,t}=\frac{\left(\frac{\left(1+r_{t}\right)\left((1-\tau^{b}_{m,t-1})\frac{\partial \psi(K_{m,t}, K_{m,t-1})}{\partial K_{m,t}} + 1 - \tau^{inv}_{m,t-1}-\tau^{b}_{m,t-1}\delta^{\tau}_{m,t-1}(1-\tau^{inv}_{m,t})\right)-1 + \delta_m - \tau^{b}_{m,t}\delta^{\tau}_{m,t}\left((1-\tau^{inv}_{m,t-1})(1-\delta^{\tau}_{m,t-1})-(1-\delta_m)(1-\tau^{inv}_{m,t})\right) + \tau^{inv}_{m,t}(1-\delta_m)}{(1-\tau_{m,t}^{b})} \right) + \frac{\partial \psi(K_{m,t+1},K_{m,t})}{\partial K_{m,t}}}{Z_{m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}}\left(\gamma_m \frac{Y_{m,t}}{K_{m,t}}\right)^{\frac{1}{\varepsilon_m}}} Args: w (array_like): the wage rate Y_vec (array_like): output for each industry - L_vec (array_like): labor demand for each industry + K_vec (array_like): capital demand for each industry + K_vec (array_like): capital demand for each industry one period ahead + K_vec (array_like): capital demand for each industry one period prior p (OG-Core Specifications object): model parameters method (str): adjusts calculation dimensions based on 'SS' or 'TPI' @@ -562,18 +614,23 @@ def get_pm(w, Y_vec, L_vec, p, method): """ if method == "SS": Y = Y_vec.reshape(1, p.M) - L = L_vec.reshape(1, p.M) + K = K_vec.reshape(1, p.M) + Kp1 = Kp1_vec.reshape(1, p.M) + Km1 = Km1_vec.reshape(1, p.M) T = 1 else: Y = Y_vec.reshape((p.T, p.M)) - L = L_vec.reshape((p.T, p.M)) + K = K_vec.reshape((p.T, p.M)) + Kp1 = Kp1_vec.reshape((p.T, p.M)) + Km1 = Km1_vec.reshape((p.T, p.M)) T = p.T p_m = np.zeros((T, p.M)) for m in range(p.M): # TODO: try to get rid of this loop - MPL = get_MPx( - Y[:, m], L[:, m], 1 - p.gamma[m] - p.gamma_g[m], p, method, m + MPK = get_MPx( + Y[:, m], K[:, m], 1 - p.gamma[m] - p.gamma_g[m], p, method, m ).reshape(T) - p_m[:, m] = w / MPL + get_cost_of_capital = get_cost_of_capital(r, p, method, m) + p_m[:, m] = cost_of_capital / MPK if method == "SS": p_m = p_m.reshape(p.M) return p_m @@ -762,4 +819,57 @@ def adj_cost_dKp1(K, Kp1, p, method): dPsi = ((p.psi / 2) * ((Inv / K - p.mu) / Inv) * (1 - p.mu * (K / Inv))) - return dPsi \ No newline at end of file + return dPsi + + +def profits(r, w, K, L, Y, K_tau, p_m, p, method, m=-1): + """ + Accounting profits for the firm. + + ..math:: + \pi_{m,t} = (1 - tau_b) * \left(p_{m,t}Y_{m,t} - w_{t}L_{m,t} - + \Psi(I_{m,t},K_{m,t})\right) - I_{m,t} + + \tau^b_{m,t}\delta^{\tau}_{m,t}K^{\tau}_{m,t} + + \tau^{inv}_{m,t}I_{m,t} \forall m,t + + Args: + + Returns: + profits (array-like): Per period profits of the firm + """ + if m is None: + if method == "SS": + tau_b = p.tau_b[-1, :] + tau_b_m1 = tau_b + delta_tau = p.delta_tau[-1, :] + delta_tau_m1 = delta_tau + tau_inv = p.inv_tax_credit[-1, :] + tau_inv_m1 = tau_inv + else: + tau_b = p.tau_b[: p.T, :] + # tau_b_m1 = p.tau_b[: p.T - 1, :] Append what to the front of this?? + delta_tau = p.delta_tau[: p.T, :] + tau_inv = p.inv_tax_credit[: p.T, :] + r = r.reshape(p.T, 1) + else: + if method == "SS": + tau_b = p.tau_b[-1, m] + tau_b_m1 = tau_b + delta_tau = p.delta_tau[-1, m] + delta_tau_m1 = delta_tau + tau_inv = p.inv_tax_credit[-1, m] + tau_inv_m1 = tau_inv + else: + tau_b = p.tau_b[: p.T, m] + delta_tau = p.delta_tau[: p.T, m] + tau_inv = p.inv_tax_credit[: p.T, m] + r = r.reshape(p.T) + if method == "SS": + ac_method = "total_ss" + else: + ac_method = "total_tpi" + Psi = adj_cost(K, K, p, method) + Inv = aggr.get_I(None, Kp1, K, p, ac_method) + profits = (1 - tau_b) * (p_m * Y - w * L - Psi) - Inv + tau_b * delta_tau * K_tau + tau_inv * Inv + + return profits \ No newline at end of file From b041fbe5e705a3fbe4b0312f8a4c8659947eae23 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 7 Dec 2023 15:15:42 -0500 Subject: [PATCH 20/26] typos and pm eqn --- docs/book/content/theory/equilibrium.md | 17 ++++++++++++----- docs/book/content/theory/firms.md | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 30ab4ff56..402873047 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -152,10 +152,11 @@ The computational algorithm for solving for the steady-state follows the steps b 3. Aggregate demand for equities is then determined as $\bar{V}^{i'} = \bar{V}^{d,i} + \bar{V}^{f,i}$. 8. Use the equity market clearing condition, {eq}`EqStnrz_VtVdVf`, to find the value of the $M$th firm, $\bar{V}_M$: - ```{math} + ```{math} :label: EqSS_V_M \bar{V}_m = \bar{V}^{i'} - \sum_{m=1}^{M-1}\bar{V}_{m} - ``` + ``` + 18. Find an updated value for GDP, $\bar{Y}^{i'} = \sum_{m=1}^{M} \bar{p}_m \bar{Y}_m$. 19. Find a updated values for $\bar{I}_{g}$ and $\bar{K}_g$ using $\bar{Y}^{i'}$, equations {eq}`EqStnrz_Igt` and {eq}`EqStnrz_Kgmt` 3. Given updated inner-loop values based on initial guesses for outer-loop variables $\{\bar{r}_p^i, \bar{r}^i, \bar{w}^i, \boldsymbol{\bar{p}}, \overline{BQ}^i, \overline{TR}^i, factor^i\}$, solve for updated values of outer-loop variables $\{\bar{r}_p^{i'}, \bar{r}^{i'}, \bar{w}^{i'}, \boldsymbol{\bar{p}}^{i'}, \overline{BQ}^{i'}, \overline{TR}^{i'}, factor^{i'}\}$ using the remaining equations: @@ -165,6 +166,12 @@ The computational algorithm for solving for the steady-state follows the steps b 3. Use $\bar{r}^{i'}$ in equations {eq}`EqUnbalGBC_rate_wedge` to get $\bar{r}_{gov}^{i'}$ 4. Use $\boldsymbol{\overline{\Pi}}^{i'}$, $\bar{r}^{i'}$, $\bar{r}_{gov}^{i'}$, $\bar{D}^{i'}$, and $\bar{V}^{i'}$ to find the return on the households' investment portfolio, $\bar{r}_{p}^{i'}$ 5. Use $\bar{Y}_m$, $\bar{K}_m$ in {eq}`EqStnrzFOC_K` to solve for the updated vector of output prices, $\boldsymbol{\bar{p}}^{i'}$ + + ```{math} + :label: EqSS_p_m + p_{m,t}=\frac{\left(\frac{\left(1+r_{t}\right)\left((1-\tau^{b}_{m,t-1})\frac{\partial \psi(K_{m,t}, K_{m,t-1})}{\partial K_{m,t}} + 1 - \tau^{inv}_{m,t-1}-\tau^{b}_{m,t-1}\delta^{\tau}_{m,t-1}(1-\tau^{inv}_{m,t})\right)-1 + \delta_m - \tau^{b}_{m,t}\delta^{\tau}_{m,t}\left((1-\tau^{inv}_{m,t-1})(1-\delta^{\tau}_{m,t-1})-(1-\delta_m)(1-\tau^{inv}_{m,t})\right) + \tau^{inv}_{m,t}(1-\delta_m)}{(1-\tau_{m,t}^{b})} \right) + \frac{\partial \psi(K_{m,t+1},K_{m,t})}{\partial K_{m,t}}}{Z_{m,t}^{\frac{\varepsilon_m-1}{\varepsilon_m}}\left(\gamma_m \frac{Y_{m,t}}{K_{m,t}}\right)^{\frac{1}{\varepsilon_m}}} + ``` + 6. Use $\bar{r}_{p}^{i'}$ and $\bar{b}_{j,s}$ in {eq}`EqStnrzMarkClrBQ` to solve for updated aggregate bequests $\overline{BQ}^{i'}$. 7. Use $\bar{Y}^{i'}$ in the long-run aggregate transfers assumption {eq}`EqStnrzTfer` to get an updated value for total transfers to households $\overline{TR}^{i'}$. 8. Use $\bar{r}^{i'}$, $\bar{r}_{p}^{i}$, $\bar{w}^{i'}$, $\bar{n}_{j,s}$, and $\bar{b}_{j,s+1}$ in equation {eq}`EqSS_factor` to get an updated value for the income factor $factor^{i'}$. @@ -185,9 +192,9 @@ The computational algorithm for solving for the steady-state follows the steps b ``` 1. Make sure that steady-state government spending is nonnegative $\bar{G}\geq 0$. If steady-state government spending is negative, that means the government is getting resources to supply the debt from outside the economy each period to stabilize the debt-to-GDP ratio. $\bar{G}<0$ is a good indicator of unsustainable policies. - 2. Make sure that the resource constraint (goods market clearing) {eq}`EqStnrzMarkClrGoods_M` is satisfied. It is redundant, but this is a good check as to whether everything worked correctly. - 3. Make sure that the government budget constraint {eq}`EqStnrzGovBC` binds. - 4. Make sure that all the $2JS$ household Euler equations are solved to a satisfactory tolerance. + 1. Make sure that the resource constraint (goods market clearing) {eq}`EqStnrzMarkClrGoods_M` is satisfied. It is redundant, but this is a good check as to whether everything worked correctly. + 2. Make sure that the government budget constraint {eq}`EqStnrzGovBC` binds. + 3. Make sure that all the $2JS$ household Euler equations are solved to a satisfactory tolerance. 2. If the distance metric of the original value of the outer-loop variables and the updated values is greater than the tolerance $toler_{ss,out}$, then an updated initial guess for the outer-loop variables is made as a convex combination of the first guess and the updated guess and steps (2) through (4) are repeated. diff --git a/docs/book/content/theory/firms.md b/docs/book/content/theory/firms.md index b24a71c43..6fe6823e1 100644 --- a/docs/book/content/theory/firms.md +++ b/docs/book/content/theory/firms.md @@ -34,7 +34,7 @@ Industry $M$ in the model is unique in two respects. First, we will define indu ```{math} :label: EqFirmsProfit \pi(K_{m,t}, K^{\tau}_{m,t}, L_{m,t}) &= (1 - \tau^{corp}_{m,t})\Bigl[p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t}) - w_t L_{m,t} - \Psi(I_{m,t}, K_{m,t})\Bigr] - \\ - &\qquad\qquad\quad I_{m,t+1} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K^{\tau}_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t + &\qquad\qquad\quad I_{m,t} + \tau^{corp}_{m,t}\delta^\tau_{m,t}K^{\tau}_{m,t} + \tau^{inv}_{m,t}I_{m,t} \quad\forall m,t ``` Gross revenue for the firms is $p_{m,t}F(K_{m,t},K_{g,m,t},L_{m,t})$. Labor costs to the firm are $w_t L_{m,t}$, and investment, $I_{m,t}$ contributes to the capital stock through the following law of motion: From 2bb76d0cad998098ab0cc5a3be895b3c43577eaf Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 13 Mar 2024 10:08:18 -0400 Subject: [PATCH 21/26] add funcs to find Y/L and K --- ogcore/firm.py | 131 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 121 insertions(+), 10 deletions(-) diff --git a/ogcore/firm.py b/ogcore/firm.py index 029975799..cc750bf3c 100644 --- a/ogcore/firm.py +++ b/ogcore/firm.py @@ -536,10 +536,23 @@ def get_cost_of_capital(r, K, Kp1, Km1, p, method, m=-1): dPsidKp1_t = adj_cost_dKp1(Km1, K, p, method) dPsidK_t = adj_cost_dK(K, Kp1, p, method) cost_of_capital = ( - (1 + r) * (((1-tau_b_m1) * dPsidKp1_t) + 1 - - tau_inv_m1 - tau_b_m1 * delta_tau_m1 * (1 - tau_inv_m1)) -1 + p.delta - tau_b * delta_tau * ((1 - tau_inv_m1) * (1 - delta_tau_m1) - (1 - p.delta) * (1 - tau_inv)) + tau_inv* (1 - p.delta)) / ( - 1 - tau_b - ) + dPsidK_t + (1 + r) + * ( + ((1 - tau_b_m1) * dPsidKp1_t) + + 1 + - tau_inv_m1 + - tau_b_m1 * delta_tau_m1 * (1 - tau_inv_m1) + ) + - 1 + + p.delta + - tau_b + * delta_tau + * ( + (1 - tau_inv_m1) * (1 - delta_tau_m1) + - (1 - p.delta) * (1 - tau_inv) + ) + + tau_inv * (1 - p.delta) + ) / (1 - tau_b) + dPsidK_t return cost_of_capital @@ -670,7 +683,7 @@ def get_KY_ratio(r, p_m, p, method, m=-1): def solve_L(Y, K, K_g, p, method, m=-1): r""" - Solve for labor supply from the production function + Solve for labor demand from the production function .. math:: \hat{L}_{m,t} = \left(\frac{\left(\frac{\hat{Y}_{m,t}} @@ -692,7 +705,7 @@ def solve_L(Y, K, K_g, p, method, m=-1): compute L for all industries) Returns: - L (array_like): labor demand each industry + L (array_like): labor demand for each industry """ gamma = p.gamma[m] @@ -775,7 +788,9 @@ def adj_cost_dK(K, Kp1, p, method): ac_method = "total_tpi" Inv = aggr.get_I(None, Kp1, K, p, ac_method) - dPsi = ((-1 * p.psi / 2) * (Kp1 / Inv ** 2) * (Inv / K - p.mu) * (Inv / K + p.mu)) + dPsi = ( + (-1 * p.psi / 2) * (Kp1 / Inv**2) * (Inv / K - p.mu) * (Inv / K + p.mu) + ) return dPsi @@ -803,7 +818,7 @@ def adj_cost_dKp1(K, Kp1, p, method): ac_method = "total_tpi" Inv = aggr.get_I(None, Kp1, K, p, ac_method) - dPsi = ((p.psi / 2) * ((Inv / K - p.mu) / Inv) * (1 - p.mu * (K / Inv))) + dPsi = (p.psi / 2) * ((Inv / K - p.mu) / Inv) * (1 - p.mu * (K / Inv)) return dPsi @@ -856,6 +871,102 @@ def profits(r, w, K, L, Y, K_tau, p_m, p, method, m=-1): ac_method = "total_tpi" Psi = adj_cost(K, K, p, method) Inv = aggr.get_I(None, Kp1, K, p, ac_method) - profits = (1 - tau_b) * (p_m * Y - w * L - Psi) - Inv + tau_b * delta_tau * K_tau + tau_inv * Inv + profits = ( + (1 - tau_b) * (p_m * Y - w * L - Psi) + - Inv + + tau_b * delta_tau * K_tau + + tau_inv * Inv + ) + + return profits + + +def get_YL_from_w(w, p_m, p, method, m=-1): + r""" + Solve for the output-labor ratio given the wage rate w and output + prices p_m. + + .. math:: + \frac{K}{L} = Z_{m,t}^{\varepsilon_m - 1}\left(\frac{1-\gamma_m-\gamma+{g,m}}{p_{m,t}w_{t}}\right) + + Args: + w (array_like): the wage rate + p_m (array_like): output prices + p (OG-Core Specifications object): model parameters + method (str): adjusts calculation dimensions based on 'SS' or + 'TPI' + m (int): production industry index + + Returns: + YLratio (array_like): the capital-labor ratio + + """ + if method == "SS": + Z = p.Z[-1, m] + else: + Z = p.Z[: p.T, m] + YLratio = Z ** (p.epsilon[m] - 1) * ( + (1 - p.gamma[m] - p.gamma_g[m]) / (p_m[m] * w) + ) + + return YLratio + - return profits \ No newline at end of file +def solve_K(Y, L, K_g, p, method, m=-1): + r""" + Solve for capital demand from the production function + + .. math:: + \hat{K}_{m,t} = \left(\frac{\left(\frac{\hat{Y}_{m,t}} + {Z_{m,t}}\right)^{\frac{\varepsilon_m-1}{\varepsilon_m}} - + \gamma_{g,m}^{\frac{1}{\varepsilon_m}}\hat{K}_{g,m,t}^ + {\frac{\varepsilon_m-1}{\varepsilon_m}} - + (1-\gamma_{m}-\gamma_{g,m})^{\frac{1}{\varepsilon_m}}\hat{L}_{m,t}^ + {\frac{\varepsilon_m-1}{\varepsilon_m}}} + {(1-\gamma_m-\gamma_{g,m})^{\frac{1}{\varepsilon_m}}} + \right)^{\frac{\varepsilon_m}{\varepsilon_m-1}} + + Args: + Y (array_like): output for each industry + L (array_like): capital demand for each industry + K_g (array_like): public capital stock + p (OG-Core Specifications object): model parameters + method (str): adjusts calculation dimensions based on 'SS' or 'TPI' + m (int or None): index of industry to compute L for (None will + compute L for all industries) + + Returns: + K (array_like): capital demand each industry + + """ + gamma = p.gamma[m] + gamma_g = p.gamma_g[m] + epsilon = p.epsilon[m] + if method == "SS": + Z = p.Z[-1, m] + else: + Z = p.Z[: p.T, m] + try: + if K_g == 0: + K_g = 1.0 + gamma_g = 0 + except: + if np.any(K_g == 0): + K_g[K_g == 0] = 1.0 + gamma_g = 0 + if epsilon == 1.0: + K = (Y / (Z * K_g**gamma_g * L ** (1 - gamma - gamma_g))) ** ( + 1 / gamma + ) + else: + K = ( + ( + (Y / Z) ** ((epsilon - 1) / epsilon) + - gamma_g ** (1 / epsilon) * K_g ** ((epsilon - 1) / epsilon) + - (1 - gamma - gamma_g) ** (1 / epsilon) + * L ** ((epsilon - 1) / epsilon) + ) + / (gamma ** (1 / epsilon)) + ) ** (epsilon / (epsilon - 1)) + + return K From 6f6c704e5dd3540fc0b2249f9c27aff0fcbe76bb Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 13 Mar 2024 10:08:30 -0400 Subject: [PATCH 22/26] update SS algo --- ogcore/SS.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ogcore/SS.py b/ogcore/SS.py index 61da4a400..58cd1ddf1 100644 --- a/ogcore/SS.py +++ b/ogcore/SS.py @@ -327,17 +327,39 @@ def inner_loop(outer_loop_vars, p, client): # Find output, labor demand, capital demand for M-1 industries L_vec = np.zeros(p.M) K_vec = np.zeros(p.M) + K_tau_vec = np.zeros(p.M) + profit_vec = np.zeros(p.M) C_vec = np.zeros(p.I) K_demand_open_vec = np.zeros(p.M) for i_ind in range(p.I): C_vec[i_ind] = aggr.get_C(c_i[i_ind, :, :], p, "SS") Y_vec = np.dot(p.io_matrix.T, C_vec) for m_ind in range(p.M - 1): - KYrat_m = firm.get_KY_ratio(r, p_m, p, "SS", m_ind) - K_vec[m_ind] = KYrat_m * Y_vec[m_ind] - L_vec[m_ind] = firm.solve_L( - Y_vec[m_ind], K_vec[m_ind], K_g, p, "SS", m_ind + YL_rat_m = firm.get_YL_from_w(w, p_m, p, "SS", m_ind) + L_vec[m_ind] = Y_vec[m_ind] * YL_rat_m + K_vec[m_ind] = firm.solve_K( + Y_vec[m_ind], L_vec[m_ind], K_g, p, "SS", m_ind ) + K_tau_vec[m_ind] = ( + (1 - p.tau_inv[-1, m_ind]) * p.delta[m] * K_vec[m_ind] + ) / p.delta_tau[-1, m_ind] + profit_vec[m_ind] = firm.profits( + r, + w, + K_vec[m_ind], + L_vec[m_ind], + Y_vec[m_ind], + K_tau_vec[m_ind], + p_m, + p, + "SS", + m_ind, + ) + # KYrat_m = firm.get_KY_ratio(r, p_m, p, "SS", m_ind) + # K_vec[m_ind] = KYrat_m * Y_vec[m_ind] + # L_vec[m_ind] = firm.solve_L( + # Y_vec[m_ind], K_vec[m_ind], K_g, p, "SS", m_ind + # ) K_demand_open_vec[m_ind] = firm.get_K( p.world_int_rate[-1], w_open, L_vec[m_ind], p, "SS", m_ind ) From d2b01ee4e6e8a861ee0997d29eb0b8383cd3fc0e Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 13 Mar 2024 10:08:43 -0400 Subject: [PATCH 23/26] format --- tests/test_firm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_firm.py b/tests/test_firm.py index a35a7398b..857b346fd 100644 --- a/tests/test_firm.py +++ b/tests/test_firm.py @@ -1074,4 +1074,4 @@ def test_adj_cost_dKp1(K, Kp1, p, method, expected): Test of the firm capital adjustment cost function. """ test_val = firm.adj_cost_dKp1(K, Kp1, p, method) - assert np.allclose(test_val, expected) \ No newline at end of file + assert np.allclose(test_val, expected) From 55d7be40d70e3977bb09c7fd4dc8b562bb306590 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 13 Mar 2024 18:33:03 -0400 Subject: [PATCH 24/26] fix typo --- docs/book/content/theory/equilibrium.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/book/content/theory/equilibrium.md b/docs/book/content/theory/equilibrium.md index 402873047..06310320a 100644 --- a/docs/book/content/theory/equilibrium.md +++ b/docs/book/content/theory/equilibrium.md @@ -130,7 +130,7 @@ The computational algorithm for solving for the steady-state follows the steps b ``` 6. Find $\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` 7. Find the value of the firm in steady-state as: $\bar{V}_{m} = \frac{\pi(\bar{K}_m, \bar{K}^{\tau}_m, \bar{L}_m)}{(1+\bar{r})}$ - 8. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for the value of the firm the world interest rate $\bar{V}_m^{r^*}$: + 8. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_m$ to solve for the value of the firm at the world interest rate $\bar{V}_m^{r^*}$: 1. Use $\bar{Y}_{m}$, $\bar{r}^*$, and $\bar{L}_m$ in {eq}`EqStnrzFOC_K` to solve for $\bar{K}_m^{r^*}$. 2. Solve for $\bar{K}_m^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_m \bar{K}^{r^*}_{m}}{\delta^{\tau}_m}$ 3. Find $\pi(\bar{K}^{r^*}_m, \bar{K}^{\tau, r^*}_m, \bar{L}_m)$ using the steady-state version of {eq}`EqFirmsProfit` @@ -141,7 +141,7 @@ The computational algorithm for solving for the steady-state follows the steps b 3. Use the production function to find $\bar{Y}_M$. 4. Solve for $\bar{K}_M^{\tau} = \frac{(1-\tau^{inv})\delta_M \bar{K}_{M}}{\delta^{\tau}_M}$ 5. Find $\pi(\bar{K}_M, \bar{K}^{\tau}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` - 6. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_M$ to solve for the value of the firm the world interest rate $\bar{V}_M^{r^*}$: + 6. Use the steady-state world interest rate $\bar{r}^*$ and labor demand $\bar{L}_M$ to solve for the value of the firm at the world interest rate $\bar{V}_M^{r^*}$: 1. Use $\bar{L}_{M}$ and $\bar{r}^*$ {eq}`EqStnrzFOC_K` to solve for $\bar{K}_M^{r^*}$. NOTE: may not be an analytical solution here so might have to use a root finder... 2. Solve for $\bar{K}_M^{\tau, r^*} = \frac{(1-\tau^{inv})\delta_M \bar{K}^{r^*}_{M}}{\delta^{\tau}_M}$ 3. Find $\bar{pi}_M^{i'}=\pi(\bar{K}^{r^*}_M, \bar{K}^{\tau, r^*}_M, \bar{L}_M)$ using the steady-state version of {eq}`EqFirmsProfit` From 0ce39d82401046f8ca69cb4e70ef19fbda819dc1 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Wed, 13 Mar 2024 18:33:15 -0400 Subject: [PATCH 25/26] more on SS soln algo --- ogcore/SS.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ogcore/SS.py b/ogcore/SS.py index 58cd1ddf1..3dbeb858b 100644 --- a/ogcore/SS.py +++ b/ogcore/SS.py @@ -329,6 +329,8 @@ def inner_loop(outer_loop_vars, p, client): K_vec = np.zeros(p.M) K_tau_vec = np.zeros(p.M) profit_vec = np.zeros(p.M) + V_vec = np.zeros(p.M) + V_open_vec = np.zeros(p.M) C_vec = np.zeros(p.I) K_demand_open_vec = np.zeros(p.M) for i_ind in range(p.I): @@ -355,6 +357,7 @@ def inner_loop(outer_loop_vars, p, client): "SS", m_ind, ) + V_vec[m_ind] = profit_vec[m_ind] / (1 + r) # KYrat_m = firm.get_KY_ratio(r, p_m, p, "SS", m_ind) # K_vec[m_ind] = KYrat_m * Y_vec[m_ind] # L_vec[m_ind] = firm.solve_L( @@ -363,6 +366,22 @@ def inner_loop(outer_loop_vars, p, client): K_demand_open_vec[m_ind] = firm.get_K( p.world_int_rate[-1], w_open, L_vec[m_ind], p, "SS", m_ind ) + K_tau_open = ( + (1 - p.tau_inv[-1, m_ind]) * p.delta[m] * K_demand_open_vec[m_ind] + ) / p.delta_tau[-1, m_ind] + Y_vec_open = firm.get_Y(K_demand_open_vec[m_ind], K_g, L_vec[m_ind], p, "SS", m=m_ind) + profit_open = firm.profits( + p.world_int_rate[-1], w_open, + K_demand_open_vec[m_ind], + L_vec[m_ind], + Y_vec_open, + K_tau_open, + p_m, + p, + "SS", + m_ind, + ) + V_open_vec[m_ind] = profit_open / (1 + p.world_int_rate[-1]) # Find output, labor demand, capital demand for industry M L_M = max(0.001, L - L_vec.sum()) # make sure L_M > 0 K_demand_open_vec[-1] = firm.get_K( From 2af61cc875315a6ae7af9eff9d5ee61f85e71845 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Thu, 14 Mar 2024 10:56:55 -0400 Subject: [PATCH 26/26] add func --- ogcore/SS.py | 2 ++ ogcore/firm.py | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ogcore/SS.py b/ogcore/SS.py index 3dbeb858b..9a64e83b2 100644 --- a/ogcore/SS.py +++ b/ogcore/SS.py @@ -363,6 +363,7 @@ def inner_loop(outer_loop_vars, p, client): # L_vec[m_ind] = firm.solve_L( # Y_vec[m_ind], K_vec[m_ind], K_g, p, "SS", m_ind # ) + # TODO: update how solve for K below, need to use equation 125, probably with a root finder K_demand_open_vec[m_ind] = firm.get_K( p.world_int_rate[-1], w_open, L_vec[m_ind], p, "SS", m_ind ) @@ -384,6 +385,7 @@ def inner_loop(outer_loop_vars, p, client): V_open_vec[m_ind] = profit_open / (1 + p.world_int_rate[-1]) # Find output, labor demand, capital demand for industry M L_M = max(0.001, L - L_vec.sum()) # make sure L_M > 0 + # TODO: update how solve for K below, need to use equation 125, probably with a root finder K_demand_open_vec[-1] = firm.get_K( p.world_int_rate[-1], w_open, L_M, p, "SS", -1 ) diff --git a/ogcore/firm.py b/ogcore/firm.py index cc750bf3c..821af8e99 100644 --- a/ogcore/firm.py +++ b/ogcore/firm.py @@ -970,3 +970,30 @@ def solve_K(Y, L, K_g, p, method, m=-1): ) ** (epsilon / (epsilon - 1)) return K + + +def FOC_K(): + """ + The firm's FOC for it's choice of capital stock. Equibrium implies + equivalence between the interest rate and the after tax rate of return + on a unit of investment. + + .. math:: + r_{t+1} = \frac{(1 - \tau^{corp}_{m,t+1})\left(p_{m,t+1} + (Z_{m,t+1})^\frac{\varepsilon_m-1}{\varepsilon_m} + \left[\gamma_m\frac{\hat{Y}_{m,t+1}}{\hat{K}_{m,t+1}} + \right]^\frac{1}{\varepsilon_m} - \frac{\partial + \Psi(\hat{I}_{m,t+1},\hat{K}_{m,t+1})}{\partial + \hat{K}_{m,t+1}}\right) + 1 - \delta_{m} + + \tau^{corp}_{m,t+1}\delta^\tau_{m,t+1}\left[(1- + \tau^{inv}_{m,t})(1-\delta^\tau_{m,t})-(1-\delta_m)(1- + \tau^{inv}_{m,t+1})\right] - \tau^{inv}_{m,t+1}(1-\delta_{m})} + {(1-\tau^{corp}_{m,t})\frac{\partial + \Psi(\hat{I}_{m,t},\hat{K}_{m,t})}{\partial \hat{K}_{m,t+1}}+1 + -\tau^{inv}_{m,t}-\tau^{corp}_{m,t}\delta^{\tau}_{m,t}(1 + -\tau^{inv}_{m,t})} - 1 \quad\forall m,t + + Args: + + Returns: + """ \ No newline at end of file