Open nk027 opened 4 years ago
Estimating tonnes of Alcohol from prices is problematic -- we get:
Min. 1st Qu. Median Mean 3rd Qu. Max.
0 0 0 38062 0 100498539
Maybe it make more sense to convert from litres to tonnes -- the density of ethanol is about 789kg/m^3, water is at 997kg/m^3 (thanks Wikipedia). While most alcoholic beverages are anecdotally more dense than water it might make sense to estimate conservatively -- for now I'll assume a density of 1000kg/m^3, since I am lazy and we'll have to think this through anyways.
When estimating prices value are capped at 20% / 500% of the world's mean. Quantile values may be considerably more robust. See here e.g. (grouped by items):
q1 q5 q9
Min. :0.000045 Min. :0.000122 Min. : 0.0003
1st Qu.:0.000180 1st Qu.:0.000495 1st Qu.: 0.0015
Median :0.000444 Median :0.000963 Median : 0.0026
Mean :0.000555 Mean :0.001786 Mean : 4.6960
3rd Qu.:0.000896 3rd Qu.:0.002416 3rd Qu.: 0.0065
Max. :0.002500 Max. :0.013352 Max. :557.8133
NA's :4 NA's :4 NA's :4
mean
Min. : 0
1st Qu.: 0
Median : 0
Mean : 2698
3rd Qu.: 0
Max. :321084
NA's :4
Apparently this capping is done irrespectively of item, country or year. This might be a stretch.
Fish, Seafood
.For now we calculate price with (after converting litres of alcohol to tonnes):
ifelse(tonnes != 0, usd / tonnes, head != 0, usd / head, usd / m3))
Head applies to livestock and m3 to forestry.
Note that for the worldprices we sum using:
na_sum <- function(x) {ifelse(all(is.na(x)), NA_real_, sum(x, na.rm = TRUE))}
If we just use a sum with na.rm = TRUE
we run into an issue when all values are NA
-- we get a 0.
To get really good price estimates we would need some other source - FAO, Worldbank, WTO or similar. E.g. the World Bank Commodity Prices.
When calculating prices of supply we have some issues.
Inf
prices - all are related to Alcohol, since it is provided in litres instead of tonnes - we skipped estimating tonnes from prices so far