<p>Short answer: no.</p>

<p>Dynare, and linearization/perturbation methods in general, are designed for solving</p>

<ul>
<li>smooth models</li>
<li>approximated around a single point in state space (the steady state).</li>
</ul>

<p>A model with fixed cost is typically non-smooth, and its behavior away from the steady state may be very different, if e.g. the firm switches from investing to not investing. On the most practical level, a model with fixed cost will typically include equation such as</p>

<p>$$
V = \max \left\{ V^{\text{invest}}, V^{\text{not invest}} \right\},
$$</p>

<p>which cannot be entered into Dynare, because max operator is not supported. On the other hand, first order conditions for convex (e.g. quadratic) adjustment cost are still smooth (one simply adds additional terms to Euler equation for investment) and thus can be easily solved with Dynare.</p>

<p>To actually compute optimal policy with fixed costs, one has typically to use global method, e.g. value function iteration. I'm not aware of any standardized toolbox for solving such problems, so you may need to code your own.</p>

<p>PS: there are some modelling tricks that make the problem smoother, typically in a setting with many, possibly heterogeneous agents/firms. For example, <a href="http://www.juliathomas.net/ThomasMay01.pdf">Thomas (2002)</a> keeps track of number of firms depending on how long they didn't invest, and solves the model with standard linearization on this extended state space. <a href="http://www.aubhik-khan.net/ecta5894.pdf">Khan &amp; Thomas (2007)</a> assume that the fixed cost is random and iid over time and across firms, so one can average over the realization of fixed cost to obtain smooth value functions. <a href="http://people.bu.edu/miaoj/MiaoWangET.pdf">Miao &amp; Wang (2014)</a> use a similar approach in a model with constant returns to scale and show how it aggregates to a version of representative-firm model with only convex adjustment costs.</p>

CC BY-SA 3.0
2015-01-13T23:24:18.887Z
@Bryce But in CEE, the cost is not binding in equilibrium (and as I understand it, its main purpose is to achieve zero average profits). What exactly do you have in mind by state-contingent cost?
ivansml
CC BY-SA 3.0
2015-01-13T23:44:13.697Z
I re-read the papers OP mentioned, and I agree with you now.  I think OP is misunderstanding the non-convex costs, because both papers incur a discontinuity in the adjustment cost functions.  This quote in the original post misrepresents what the papers are doing: "Non-convex has a specific mathematical meaning but the context of these papers it indicates adjustment costs that are not proportional to the amount of adjustment. Instead the adjustment costs have a fixed cost proportional to the current asset value."
Bryce
CC BY-SA 3.0
2015-01-13T23:57:02.383Z
@Bryce I hadn't really looked at those papers either, but I agree, it looks like they don't deal with fixed adj. cost as usually defined (though the latter has transaction cost proportionate to absolute value of adjustment, which is also non-smooth). Perhaps OP should clarify.
ivansml
CC BY-SA 3.0
2015-01-15T00:59:01.183Z
How about approximating the max-operator by a smooth funtion? $(x^n+y^n)^\frac{1}{n}$ is close to $\max\{x,y\}$ for nonnegative $x,y$ and large $n$.
Michael Greinecker
CC BY-SA 3.0
2015-01-16T01:48:06.770Z
@MichaelGreinecker  Formally this might be possible, but then still there's the issue whether a local approximation away from the switching point could capture the behavior of the function. For example, if I want to approximate $f(x) = \max \{ x^2, 1 \}$ with Taylor expansion around $x=2$, even if I replace max with its smooth version, I'd guess the approximation will likely be poor for $x < 1$.
ivansml
CC BY-SA 3.0
2015-01-16T16:03:36.953Z
I don't understand how the max operator could not be supported when the problem itself is a maximization problem. Isn't just about every maximization problem with multiple controls of the form Max(best you can do | changing stuff, best you can do |without changing stuff)? Is it possible that indicator functions rather than the max operator is the problem?
BKay
CC BY-SA 3.0
2015-01-16T17:59:13.647Z
@Bkay Yes, most models involve maximization, but in order to solve them on a computer, we usually need to derive first order conditions in the form of equations. Dynare expects that the model is described by conditions more-or-less in the form of $F(x_{t-1},x_t,x_{t+1},\epsilon_t) = 0$, where $F: \mathbb{R}^{3 n_x + n_\epsilon} \rightarrow \mathbb{R}^{n_x}$ should be differentiable function.
ivansml
CC BY-SA 3.0
2015-01-13T22:53:29.757Z
2015-01-13T22:53:29.757Z
ivansml
<p>It is generally not possible to make a sharp statement about the types of non-convex costs that Dynare can handle.  Many different factors come into play about whether a model can be "solved" by Dynare or not.  Is the steady-state correctly defined?  Is the model stationary?  Is the model differentiable everywhere in the ergodic set?  Are the number of endogenous and exogenous variables equal to the number of equations?  Is the model Blanchard-Kahn stable?</p>

<p>But, to answer your question, can Dynare solve a model with a state-contingent fixed cost?  Yes.  This is not difficult, you should try to create one yourself.  Try modifying a simple RBC model with capital and bonds.  The trouble is not inducing the cost, but rather finding the steady state, which can be quite onerous if not done cleverly.</p>

<p>Dynare, however, cannot solve Iacoviello and Pavan 2013 because of the min function found in a borrowing constraint.  This min function induces a point in the ergodic set which is not differentiable.  Dynare numerically approximates optimal policy functions about a steady state using perturbation methods.  This requires employing the implicit function theorem to build out Taylor expansions of the optimal policies, hence you must be able to take derivatives everywhere within the ergodic set.</p>

CC BY-SA 3.0
2015-01-13T18:21:48.227Z
Can you provide guidance on changes to the mod files to implement an example of a non-convex transaction cost? I looked for a while for an example of how to do this in Dynare before posting. I not only didn't find out how to do this I couldn't even find documentation that it was possible to do so, thus the question.
BKay
CC BY-SA 3.0
2015-01-13T18:08:18.447Z
2015-01-13T19:18:06.033Z
2015-01-13T19:18:06.033Z
Bryce
<p>I know that Dynare (which sits on top of Matlab) can solve many kinds of dynamic stochastic general equilibrium (DSGE) and overlapping generations (OLG) models. I also know that Dynare can handle some sorts of adjustment costs. For example, I have seen convex adjustment cost examples in Dynare. In particular, <a href="http://www.macromodelbase.com/" rel="nofollow noreferrer">The Macroeconomic Model Data Base</a> provides on the order of 50 models compatible with Dynare and <a href="http://www.monfispol.eu/reports/the-macroeconomic-model-data-base-user-manual" rel="nofollow noreferrer">the user manual</a> indicates several models (e.g. NK_IR04 and US_NFED0) with quadratic (a type of convex) adjustment costs. </p>

<p>Can Dynare solve models with non-convex adjustment costs like <a href="https://www2.bc.edu/matteo-iacoviello/research_files/RPE.pdf" rel="nofollow noreferrer">An equilibrium model of lumpy housing investment</a> (Iacoviello and Pavan (2008)) or <a href="http://www.sciencedirect.com/science/article/pii/S0304393212001353#" rel="nofollow noreferrer">Housing and debt over the life cycle and over the business cycle</a> (Iacoviello and Pavan (2013))? Non-convex has a specific mathematical meaning, but in the context of these papers it indicates that adjustment costs that are not proportional to the amount of adjustment. Instead, the adjustment costs have a fixed-cost proportional to the current asset value.  However, there are other forms of non-convex adjustment cost. If Dynare can solve any model with any sort of non-convex adjustment costs that is of interest. </p>

<p>If models with these adjustment costs can be solved with Dynare, please provide an example or a link to an example (if possible).  If Dynare currently cannot solve these models is there any published code that can do so? Even sample code for a specific model solution rather than a general product like Dynare would be helpful.  </p>

<p><strong>More details on non-convex adjustment costs</strong>: </p>

<p>I draw my language here from a 
<a href="http://econweb.ucsd.edu/~mflavin/pdfs/AERhabit.pdf" rel="nofollow noreferrer">A Model of Housing in the Presence of Adjustment Costs: A Structural Interpretation of Habit Persistence</a> (Flavin and Nakagawa (2008)) </p>

<blockquote>
  <p>At the instant the house is sold, the household pays a transactions
  cost proportional to the value of the house sold, so that wealth also
  changes discontinuously....The housing model developed in Section I
  invokes a fourth set of assumptions: utility depends nonseparably on
  nondurable consumption and on housing, nondurable consumption is
  costlessly adjustable, but housing is subject to a nonconvex
  adjustment cost (<span class="math-container">$\lambda &gt; 0 $</span>).</p>
</blockquote>

<p>Perhaps this language is non-standard but that's a quote from a paper in the AER, and when I've discussed it with others people seem to know what I'm talking about. The two mentioned papers don't use that language but do have the same rough form, that transaction costs are <strong>not</strong> increasing in the degree of the adjustment but rather that any use of adjustment (other than a small bit, perhaps for depreciation or unit improvement perhaps) triggers a cost related to the state variables instead of the control variables. The paper <a href="http://econweb.umd.edu/~haltiwan/Coak111105.pdf" rel="nofollow noreferrer">On the Nature of Capital Adjustment Costs</a> (Cooper and Haltiwanger (2005)) seems to use nonconvex adjustment costs in the same way in a firm capital setting. </p>

<blockquote>
  <p>Building upon the analysis of Abel and Eberly [1999], Cooper,
  Haltiwanger and Power [1999] and Caballero and Engel [1999], during
  periods of investment plants incur a fixed adjustment cost. Generally,
  these non-convex costs of adjustment are intended to capture
  indivisibilities in capital, increasing returns to the installation of
  new capital and increasing returns to retraining and restructuring of
  production activity. These fixed adjustment costs represent the need
  for plant restructuring, worker retraining and organizational
  restructuring during periods of intensive investment</p>
</blockquote>

CC BY-SA 3.0
2015-01-14T01:00:58.337Z
Upon closer reading, Iacoviello and Pavan do indeed have fixed adjustment cost, sorry for confusion.
ivansml
<macroeconomics><computation><dsge><dynare>
Can Dynare solve general equilibrium (GE) models with non-convex adjustment costs?
BKay
# Can Dynare solve general equilibrium (GE) models with non-convex adjustment costs?

(Asked by: username_0 on 2015-01-12)

I know that Dynare (which sits on top of Matlab) can solve many kinds of dynamic stochastic general equilibrium (DSGE) and overlapping generations (OLG) models. I also know that Dynare can handle some sorts of adjustment costs. For example, I have seen convex adjustment cost examples in Dynare. In particular, [The Macroeconomic Model Data Base](http://www.macromodelbase.com/) provides on the order of 50 models compatible with Dynare and [the user manual](http://www.monfispol.eu/reports/the-macroeconomic-model-data-base-user-manual) indicates several models (e.g. NK\_IR04 and US\_NFED0) with quadratic (a type of convex) adjustment costs.

Can Dynare solve models with non-convex adjustment costs like [An equilibrium model of lumpy housing investment](https://www2.bc.edu/matteo-iacoviello/research_files/RPE.pdf) (Iacoviello and Pavan (2008)) or [Housing and debt over the life cycle and over the business cycle](http://www.sciencedirect.com/science/article/pii/S0304393212001353#) (Iacoviello and Pavan (2013))? Non-convex has a specific mathematical meaning, but in the context of these papers it indicates that adjustment costs that are not proportional to the amount of adjustment. Instead, the adjustment costs have a fixed-cost proportional to the current asset value. However, there are other forms of non-convex adjustment cost. If Dynare can solve any model with any sort of non-convex adjustment costs that is of interest.

If models with these adjustment costs can be solved with Dynare, please provide an example or a link to an example (if possible). If Dynare currently cannot solve these models is there any published code that can do so? Even sample code for a specific model solution rather than a general product like Dynare would be helpful.

**More details on non-convex adjustment costs**:

I draw my language here from a
[A Model of Housing in the Presence of Adjustment Costs: A Structural Interpretation of Habit Persistence](http://econweb.ucsd.edu/~mflavin/pdfs/AERhabit.pdf) (Flavin and Nakagawa (2008))

> At the instant the house is sold, the household pays a transactions
> cost proportional to the value of the house sold, so that wealth also
> changes discontinuously....The housing model developed in Section I
> invokes a fourth set of assumptions: utility depends nonseparably on
> nondurable consumption and on housing, nondurable consumption is
> costlessly adjustable, but housing is subject to a nonconvex
> adjustment cost ($\lambda > 0 $).

Perhaps this language is non-standard but that's a quote from a paper in the AER, and when I've discussed it with others people seem to know what I'm talking about. The two mentioned papers don't use that language but do have the same rough form, that transaction costs are **not** increasing in the degree of the adjustment but rather that any use of adjustment (other than a small bit, perhaps for depreciation or unit improvement perhaps) triggers a cost related to the state variables instead of the control variables. The paper [On the Nature of Capital Adjustment Costs](http://econweb.umd.edu/~haltiwan/Coak111105.pdf) (Cooper and Haltiwanger (2005)) seems to use nonconvex adjustment costs in the same way in a firm capital setting.

> Building upon the analysis of Abel and Eberly [1999], Cooper,
> Haltiwanger and Power [1999] and Caballero and Engel [1999], during
> periods of investment plants incur a fixed adjustment cost. Generally,
> these non-convex costs of adjustment are intended to capture
> indivisibilities in capital, increasing returns to the installation of
> new capital and increasing returns to retraining and restructuring of
> production activity. These fixed adjustment costs represent the need
> for plant restructuring, worker retraining and organizational
> restructuring during periods of intensive investment

**Tags:** macroeconomics, computation, dsge, dynare

> **Comments:**
> **username_1**: Upon closer reading, Iacoviello and Pavan do indeed have fixed adjustment cost, sorry for confusion.  

---

## 2 answers

### Answer by username_1 on 2015-01-13. Score: 5

Short answer: no.

Dynare, and linearization/perturbation methods in general, are designed for solving

* smooth models
* approximated around a single point in state space (the steady state).

A model with fixed cost is typically non-smooth, and its behavior away from the steady state may be very different, if e.g. the firm switches from investing to not investing. On the most practical level, a model with fixed cost will typically include equation such as

$$
V = \max \left\{ V^{\text{invest}}, V^{\text{not invest}} \right\},
$$

which cannot be entered into Dynare, because max operator is not supported. On the other hand, first order conditions for convex (e.g. quadratic) adjustment cost are still smooth (one simply adds additional terms to Euler equation for investment) and thus can be easily solved with Dynare.

To actually compute optimal policy with fixed costs, one has typically to use global method, e.g. value function iteration. I'm not aware of any standardized toolbox for solving such problems, so you may need to code your own.

PS: there are some modelling tricks that make the problem smoother, typically in a setting with many, possibly heterogeneous agents/firms. For example, [Thomas (2002)](http://www.juliathomas.net/ThomasMay01.pdf) keeps track of number of firms depending on how long they didn't invest, and solves the model with standard linearization on this extended state space. [Khan & Thomas (2007)](http://www.aubhik-khan.net/ecta5894.pdf) assume that the fixed cost is random and iid over time and across firms, so one can average over the realization of fixed cost to obtain smooth value functions. [Miao & Wang (2014)](http://people.bu.edu/miaoj/MiaoWangET.pdf) use a similar approach in a model with constant returns to scale and show how it aggregates to a version of representative-firm model with only convex adjustment costs.

> **Comments:**
> **username_1**: @username_2 But in CEE, the cost is not binding in equilibrium (and as I understand it, its main purpose is to achieve zero average profits). What exactly do you have in mind by state-contingent cost?  
> **username_2**: I re-read the papers OP mentioned, and I agree with you now.  I think OP is misunderstanding the non-convex costs, because both papers incur a discontinuity in the adjustment cost functions.  This quote in the original post misrepresents what the papers are doing: "Non-convex has a specific mathematical meaning but the context of these papers it indicates adjustment costs that are not proportional to the amount of adjustment. Instead the adjustment costs have a fixed cost proportional to the current asset value."  
> **username_1**: @username_2 I hadn't really looked at those papers either, but I agree, it looks like they don't deal with fixed adj. cost as usually defined (though the latter has transaction cost proportionate to absolute value of adjustment, which is also non-smooth). Perhaps OP should clarify.  
> **username_3**: How about approximating the max-operator by a smooth funtion? $(x^n+y^n)^\frac{1}{n}$ is close to $\max\{x,y\}$ for nonnegative $x,y$ and large $n$.  
> **username_1**: @username_3  Formally this might be possible, but then still there's the issue whether a local approximation away from the switching point could capture the behavior of the function. For example, if I want to approximate $f(x) = \max \{ x^2, 1 \}$ with Taylor expansion around $x=2$, even if I replace max with its smooth version, I'd guess the approximation will likely be poor for $x < 1$.  
> **username_0**: I don't understand how the max operator could not be supported when the problem itself is a maximization problem. Isn't just about every maximization problem with multiple controls of the form Max(best you can do | changing stuff, best you can do |without changing stuff)? Is it possible that indicator functions rather than the max operator is the problem?  
> **username_1**: @username_0 Yes, most models involve maximization, but in order to solve them on a computer, we usually need to derive first order conditions in the form of equations. Dynare expects that the model is described by conditions more-or-less in the form of $F(x_{t-1},x_t,x_{t+1},\epsilon_t) = 0$, where $F: \mathbb{R}^{3 n_x + n_\epsilon} \rightarrow \mathbb{R}^{n_x}$ should be differentiable function.  

---

### Answer by username_2 on 2015-01-13. Score: 3

It is generally not possible to make a sharp statement about the types of non-convex costs that Dynare can handle. Many different factors come into play about whether a model can be "solved" by Dynare or not. Is the steady-state correctly defined? Is the model stationary? Is the model differentiable everywhere in the ergodic set? Are the number of endogenous and exogenous variables equal to the number of equations? Is the model Blanchard-Kahn stable?

But, to answer your question, can Dynare solve a model with a state-contingent fixed cost? Yes. This is not difficult, you should try to create one yourself. Try modifying a simple RBC model with capital and bonds. The trouble is not inducing the cost, but rather finding the steady state, which can be quite onerous if not done cleverly.

Dynare, however, cannot solve Iacoviello and Pavan 2013 because of the min function found in a borrowing constraint. This min function induces a point in the ergodic set which is not differentiable. Dynare numerically approximates optimal policy functions about a steady state using perturbation methods. This requires employing the implicit function theorem to build out Taylor expansions of the optimal policies, hence you must be able to take derivatives everywhere within the ergodic set.

> **Comments:**
> **username_0**: Can you provide guidance on changes to the mod files to implement an example of a non-convex transaction cost? I looked for a while for an example of how to do this in Dynare before posting. I not only didn't find out how to do this I couldn't even find documentation that it was possible to do so, thus the question.  

---

