<p>The general way to do this would be using a nested CES Function.  <a href="https://en.wikipedia.org/wiki/Constant_elasticity_of_substitution" rel="nofollow noreferrer">CES Wikipedia</a></p>

<p>For your example you could define the utility of sandwiches (S) and condiments (C) to be </p>

<p>$$ U(D,H,M,Y) = (a_1 S^{\frac{s-1}{s}} + a_2 C^{\frac{s-1}{s}})^{\frac{s}{s-1}} $$
then you can define $S$ and $C$ "nests" as
$$ S = (b_1 D^{\frac{\rho-1}{\rho}} + b_2 H^{\frac{\rho-1}{\rho}})^{\frac{\rho}{\rho-1}} $$
$$ C = (c_1 M^{\frac{\eta-1}{\eta}} + c_2 Y^{\frac{\eta-1}{\eta}})^{\frac{\eta}{\eta-1}} $$</p>

<p>$s$ determines whether S and C are complements ($s \rightarrow 0$) or substitutes ($s \rightarrow \infty$), or neither ($s=1$).</p>

<p>The same holds for $\rho$ and $\eta$ in the "nests".  $a$, $b$, and $c$ establish the relative importance of each item within a nest. </p>

<p>Extending this to $N$ you can have an arbitrary number of nests and an arbitrary number of elements within each nest.  This way may look complicated, but it has a lot of flexibility and gives you nice derivatives when solving maximization problems.</p>

CC BY-SA 3.0
2018-02-23T05:55:22.473Z
Ah, great idea, thanks! Didn't think to nest the CES functions. I'm fiddling around with the equations now and am having some quirks finding closed-form demand functions. Do you know if it is possible to find them and I should keep trying? Or should I use numerical methods?
robbrit
CC BY-SA 3.0
2018-02-23T06:38:30.100Z
Hm, since using projected gradient ascent is pretty easy, I will go ahead with that one.
robbrit
CC BY-SA 3.0
2018-02-23T16:42:16.557Z
Take a look at section 3.1 of [these notes](http://www.econ.yale.edu/~ka265/teaching/GradTrade/notes/ClassNotes.pdf).  There are some tricks dealing with CES that aren't obvious at first.
dsmithecon
CC BY-SA 3.0
2018-02-26T23:03:36.303Z
I took a look at those notes, unfortunately the step where they divide the FOCs for two separate goods doesn't work with nested CES. There's a summed term that cancels out in the non-nested case, but not with nested.
robbrit
CC BY-SA 3.0
2018-02-23T05:07:06.773Z
2018-02-23T05:07:06.773Z
dsmithecon
<p>I know that in the 2-good world it is easy to derive the demand functions from a utility function for imperfect substitutes or complements, but what if I have N goods that include many combinations of substitutes and complements?</p>

<p>For example if you have hot dogs $D$, hamburgers $H$ (substitutes of each other), and mustard $M$, mayo $Y$ (substitutes of each other, complements with hot dogs and hamburgers), I can try something like this:</p>

<p>$$
U(D, H, M, Y) = (D^{0.5} + H^{0.5})(M^{0.5} + Y^{0.5})
$$</p>

<p>Unfortunately the math gets pretty hairy for this one pretty quickly. Before I dive in much further with solving these equations, is there a well-known function that is used in the literature for this type of analysis?</p>

<p>Note: I am interested in the more general N-good case, not just the 4-good one.</p>

<utility>
Derive utility function with both substitutes and complements
robbrit
# Derive utility function with both substitutes and complements

(Asked by: username_0 on 2018-02-23)

I know that in the 2-good world it is easy to derive the demand functions from a utility function for imperfect substitutes or complements, but what if I have N goods that include many combinations of substitutes and complements?

For example if you have hot dogs $D$, hamburgers $H$ (substitutes of each other), and mustard $M$, mayo $Y$ (substitutes of each other, complements with hot dogs and hamburgers), I can try something like this:

$$
U(D, H, M, Y) = (D^{0.5} + H^{0.5})(M^{0.5} + Y^{0.5})
$$

Unfortunately the math gets pretty hairy for this one pretty quickly. Before I dive in much further with solving these equations, is there a well-known function that is used in the literature for this type of analysis?

Note: I am interested in the more general N-good case, not just the 4-good one.

**Tags:** utility

---

## 1 answers

### Answer by username_1 on 2018-02-23. Score: 3 | Accepted answer

The general way to do this would be using a nested CES Function. [CES Wikipedia](https://en.wikipedia.org/wiki/Constant_elasticity_of_substitution)

For your example you could define the utility of sandwiches (S) and condiments (C) to be

$$ U(D,H,M,Y) = (a\_1 S^{\frac{s-1}{s}} + a\_2 C^{\frac{s-1}{s}})^{\frac{s}{s-1}} $$
then you can define $S$ and $C$ "nests" as
$$ S = (b\_1 D^{\frac{\rho-1}{\rho}} + b\_2 H^{\frac{\rho-1}{\rho}})^{\frac{\rho}{\rho-1}} $$
$$ C = (c\_1 M^{\frac{\eta-1}{\eta}} + c\_2 Y^{\frac{\eta-1}{\eta}})^{\frac{\eta}{\eta-1}} $$

$s$ determines whether S and C are complements ($s \rightarrow 0$) or substitutes ($s \rightarrow \infty$), or neither ($s=1$).

The same holds for $\rho$ and $\eta$ in the "nests". $a$, $b$, and $c$ establish the relative importance of each item within a nest.

Extending this to $N$ you can have an arbitrary number of nests and an arbitrary number of elements within each nest. This way may look complicated, but it has a lot of flexibility and gives you nice derivatives when solving maximization problems.

> **Comments:**
> **username_0**: Ah, great idea, thanks! Didn't think to nest the CES functions. I'm fiddling around with the equations now and am having some quirks finding closed-form demand functions. Do you know if it is possible to find them and I should keep trying? Or should I use numerical methods?  
> **username_0**: Hm, since using projected gradient ascent is pretty easy, I will go ahead with that one.  
> **username_1**: Take a look at section 3.1 of [these notes](http://www.econ.yale.edu/~ka265/teaching/GradTrade/notes/ClassNotes.pdf).  There are some tricks dealing with CES that aren't obvious at first.  
> **username_0**: I took a look at those notes, unfortunately the step where they divide the FOCs for two separate goods doesn't work with nested CES. There's a summed term that cancels out in the non-nested case, but not with nested.  

---

