Skip to content

Instantly share code, notes, and snippets.

@trialsolution
Created November 14, 2013 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trialsolution/7465475 to your computer and use it in GitHub Desktop.
Save trialsolution/7465475 to your computer and use it in GitHub Desktop.
Example in Rutherford's Lecture Notes on CES functions, page 4 http://www.gamsworld.eu/mpsge/debreu/ces.pdf
*<%REGION File header%>
*=============================================================================
* File : rutherford_ex1.gms
* Author : mihalyh
* Version : 1.0
* Date : 13.11.2013 10:58:08
* Changed : 13.11.2013 13:13:56
* Changed by: mihalyh
* Remarks :
$ontext
Example in Rutherford's Lecture Notes on CES functions, page 4
http://www.gamsworld.eu/mpsge/debreu/ces.pdf
$offtext
*=============================================================================
*<%/REGION File header%>
set
goods /rent, food, skiing/
places /Boulder, Georgetown/;
;
parameter
p_price(goods, places)
p_valueShare(goods, places)
p_theta(goods) "value share parameter"
p_dem0(goods) "benchmark demand"
p_exp0 "benchmark expenditure"
p_price0(goods) "benchmark prices"
;
variable
v_rho "rho parameter (subst. elast.)"
v_sigma "substitution elasticity"
v_utility "utility"
v_p "price index, aka unit expenditure function"
v_cons(goods) "consumption of goods, normalized to unity in benchmark"
v_price(goods) "prices of goods"
v_exp "expenditure"
v_expShare(goods) "expenditure shares"
;
p_price(goods, "Boulder") = 1;
p_price(goods, "Georgetown") = 1;
p_price("skiing", "Georgetown") = 10;
p_price0(goods) = p_price(goods, "Boulder") ;
p_valueShare("rent", "Boulder") = .3;
p_valueShare("food", "Boulder") = .1;
p_valueShare("skiing", "Boulder") = .6;
p_theta(goods) = p_valueShare(goods, "Boulder");
* benchmark utility is normalized to one (and the price index also equals to one) => V = M / e => M = 1
p_exp0 = 1;
* normalization => the benchmark demand equals to the value shares
p_dem0(goods) = p_valueShare(goods, "Boulder");
equations
sigma_rho_
utility_
unit_exp_
indirect_u_ "indirect utility function"
expenditure_
demand_(goods) "demand functions"
expenditure_share_(goods)
;
sigma_rho_ ..
v_sigma =e= 1 / ( 1 - v_rho );
utility_ ..
v_utility =e= sum(goods, p_theta(goods) * v_cons(goods) ** v_rho) ** ( 1 / v_rho );
unit_exp_ ..
v_p =e= sum(goods, p_theta(goods) * (v_price(goods) / p_price0(goods)) ** ( 1 - v_sigma ))
** ( 1 / (1 - v_sigma) );
expenditure_ ..
v_exp =e= sum(goods, v_price(goods) * v_cons(goods) * p_dem0(goods));
expenditure_share_(goods) ..
v_expShare(goods) =e= v_price(goods) * v_cons(goods) * p_dem0(goods) / v_exp;
indirect_u_ ..
v_utility =e= v_exp / [sum(goods, p_price0(goods) * p_dem0(goods)) * v_p];
* note that v_cons is relative to the benchmark, so the benchmark value is missing from the formula below
demand_ (goods) ..
v_cons(goods) =e= v_utility * [ v_p * p_price0(goods) / v_price(goods) ] ** v_sigma;
* variable budget
v_exp.L = 1;
* fixed utility
v_utility.FX = 1;
* exogenous prices
v_price.fx(goods) = p_price(goods, "Georgetown");
* she spends 30% of her income on skiing in the optimum
v_cons.L(goods) = p_dem0(goods);
v_expShare.L(goods) = p_valueShare(goods, "Boulder");
* with fixing one of the expenditure shares you free up one degree of freedom that will be used by v_sigma
v_expShare.fx("skiing") = .3;
* initialization
v_sigma.L = 2;
v_rho.L = ( v_sigma.L - 1 ) / v_sigma.L ;
v_p.L = sum(goods, p_theta(goods) * (v_price.L(goods) / p_price0(goods)) ** ( 1 - v_sigma.L ))
** ( 1 / (1 - v_sigma.L) );
model m_mikki_calib /demand_, unit_exp_, expenditure_, expenditure_share_/;
* calibration of the subst. elasticity
solve m_mikki_calib using CNS;
display "Mikki's substitution elasticity: ", v_sigma.L;
* Let's test with a 'full' model if we calculated sigma correctly
v_sigma.fx = v_sigma.L;
v_rho.fx = ( v_sigma.L - 1 ) / v_sigma.L ;
v_exp.UP = inf;
v_exp.LO = 0;
v_expShare.up("skiing") = inf;
v_expShare.lo("skiing") = 0;
* prices remained fixed from the calibration step (exogenous price developmentx)
model m_mikki /demand_, unit_exp_, expenditure_, expenditure_share_/;
solve m_mikki using CNS;
* What fraction of Mikki's income does she spend on rent in G. ?
display "new value shares: ", v_expShare.L;
* Compensating variation
parameter p_compensate;
* note that both utility and the price index was normalized to one in the benchmark => expenditure in benchmark is also one
p_compensate = v_exp.L - 1;
display p_compensate;
*============================ End Of File ================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment