Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent output of FoodExpanditure() and consumptionValue(..., type="food") functions #2

Closed
mishkos opened this issue Dec 17, 2019 · 7 comments
Assignees

Comments

@mishkos
Copy link
Contributor

mishkos commented Dec 17, 2019

Ideally this should be the same. For the difference between the output of FoodExpenditure() and consumptionValue(..., type="food"), it basically comes from usage of different approaches for calculation of prices and quantities, the former using prices per kcal and caloric intake and the latter using prices per tones DM and tDM consumption. Since prices in both case are calculated as Lagrangian multipliers, it could be that the difference in output of functions comes from a general equation system setup in magpie and related interplay between demand variables.

@mishkos mishkos changed the title Inconsistent output of FoodExpanditure() and consumptionValue(..., type="food") functions Inconsistent output of FoodExpanditure() and consumptionValue(..., type="food") functions Dec 17, 2019
@mishkos mishkos changed the title Inconsistent output of FoodExpanditure() and consumptionValue(..., type="food") functions Inconsistent output of FoodExpanditure() and consumptionValue(..., type="food") functions Dec 17, 2019
@tscheypidi
Copy link
Member

has this been fixed yet?

@bodirsky
Copy link
Member

I do not understand the issue, and miskos answer..

@bodirsky
Copy link
Member

bodirsky commented Apr 21, 2020

ok, this is the issue:

a=FoodExpenditure("../../inputdata/fulldata.gdx")[,2050,]
sum(a)
[1] 7855.305
b=consumptionValue("../../inputdata/fulldata.gdx", type="food")[,"y2050",]
sum(b)
[1] 5660919

@bodirsky
Copy link
Member

the food expenditure function calculates expenditure based on calories and calorie-prices:
price = readGDX(gdx,"p15_prices_kcal")
which in the gams code is the equation

p15_prices_kcal(t,iso,kfo)=sum(i_to_iso(i,iso), q15_food_demand.m(i,kfo));
q15_food_demand(i2,kfo) ..
(vm_dem_food(i2,kfo) + sum(ct, f15_household_balanceflow(ct,i2,kfo,"dm")))
* sum(ct,(f15_nutrition_attributes(ct,kfo,"kcal") * 10**6)) =g=
sum(ct,im_pop(ct,i2) * p15_kcal_pc_calibrated(ct,i2,kfo)) * 365
;
the calories come from the parameter
readGDX(gdx=gdx,"p15_kcal_pc_iso")

the consumption value function receives its prices from the equation:
d <- readGDX(gdx,"ov_supply",select = list(type="level"),react = "warning")
and the quantities from the variable
readGDX(gdx, "ov_dem_food", select=list(type="level"))

@bodirsky
Copy link
Member

So i see one bug in the food expenditure function, because it omits the multiplication by 365.
This still does not close the gap (still ~50%)

@bodirsky
Copy link
Member

ah, no. the multiplication by 365 is done.

@bodirsky
Copy link
Member

ah, the food expenditure is by default as per-capita.
if you switch it to per-capita = FALSE, it provides similar values as the consumption value

a = FoodExpenditure(gdx,per_capita=FALSE)[,2050,]

sum(a)
[1] 5787212

b=consumptionValue("../../inputdata/fulldata.gdx", type="food")[,"y2050",]
sum(b)
[1] 5660919

so everything is fine, no bugs :)

flohump added a commit that referenced this issue Nov 15, 2024
flohump added a commit that referenced this issue Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants