Ask Your Question
1

Smoother Derivations of Hicksian Demands in Sage

asked 2020-07-16 07:04:52 +0200

EconJohn gravatar image

updated 2020-07-17 01:29:32 +0200

The problem I'm solving is an economics one relating to solving for hicksian demands,given my difficulty solving for them directly, Im trying to tackle this same problem indirectly and it works for the most part however I'd like it to run smoother.

Setting up the problem we have:

x1, x2, l, p1, p2, a, b,  R= var('x1, x2, l, p1, p2, a, b,  R')
U = x1^a*x2^b
m = p1*x1+p2*x2;
L = U+ l * (R-m);
dLdx = L.diff(x1);
dLdy = L.diff(x2);
dLdl = L.diff(l);
solve([dLdx == 0, dLdy == 0, dLdl == 0], x1, x2, l)

Out: [[x1 == R*a/((a + b)*p1), x2 == R*b/((a + b)*p2), l == (a + b)*(R*a/((a + b)*p1))^a*(R*b/((a + b)*p2))^b/R]]

I then manually plug in the values for $x_1$ and and $x_2$ into $U$ to get the indirect utility function and solve for the expenditure function:

 expend=solve(U==(R*a/((a + b)*p1))^a*(R*b/((a + b)*p2)^b),R);expend
 Out: [R == ((a + b)*p2)^b*x1^a*x2^b/(b*(R*a/((a + b)*p1))^a)]

I again need to plug in this exact functional form to get the hicksian demands using shephard's lemma:

expend1=((a + b)*p2)^b*x1^a*x2^b/(b*(R*a/((a + b)*p1))^a)
expend1.diff(p1) #the hicksian demand for x1
Out:  ((a + b)*p2)^(b - 1)*(a + b)*x1^a*x2^b/(R*a/((a + b)*p1))^a

expend1.diff(p2) #the hicksian demand for x2
Out: ((a + b)*p2)^(b - 1)*(a + b)*x1^a*x2^b/(R*a/((a + b)*p1))^a

I'm interested in getting my code to run more parsimoniously as I find myself having to manually pull out solved values to move to next stages of the problem. This is frustrating because I'd have to do this each time if i change my functional form.

Note: I see that this method actually does not work as I didnt notice R on the Left hand side of this problem.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-07-17 02:45:43 +0200

EconJohn gravatar image

updated 2020-07-17 19:54:18 +0200

Thanks to Juanjo's answer to my question here I've managed to get a script which gives us an analytical solution for our hicksian demand equations. This is:

x1, x2, l, p1, p2, a, b,  R= var('x1, x2, l, p1, p2, a, b,  R')
U = x1^a*x2^b 
m = p1*x1+p2*x2;
L = m+ l * (R-U);
dLdx = L.diff(x1);
dLdy = L.diff(x2);
dLdl = L.diff(l);
step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, R)
step2=solve((p1/p2).subs(step1)==p1/p2, x1)
good2step3 = solve((U/R).subs(step2).log().log_expand()==0, x2)
good1step4=solve(step2[0].subs(good2step3).canonicalize_radical(),x1)

where good1step4 is our hicksiand demand for $x_1$ and good2step3 is our hicksian demand for $x_2$.

Its interesting how you need a different procedure when your constraint is non-linear.

edit flag offensive delete link more
0

answered 2020-07-16 12:37:41 +0200

Emmanuel Charpentier gravatar image

This answer may be relevant : the "manual" solution proposed can be programmed (although the relevant simplifications may vary). Sage will give you a mathematically sound solution, that you may have to simplify "manually" (easy with Sage's help...).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-16 07:04:52 +0200

Seen: 400 times

Last updated: Jul 17 '20