# Derive utility function with both substitutes and complements

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.

The general way to do this would be using a nested CES Function. CES Wikipedia

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.

• 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? Feb 23 '18 at 5:55
• Hm, since using projected gradient ascent is pretty easy, I will go ahead with that one. Feb 23 '18 at 6:38
• Take a look at section 3.1 of these notes. There are some tricks dealing with CES that aren't obvious at first. Feb 23 '18 at 16:42
• 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. Feb 26 '18 at 23:03