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

Supply prices #42

Open
nk027 opened this issue Nov 12, 2019 · 5 comments
Open

Supply prices #42

nk027 opened this issue Nov 12, 2019 · 5 comments
Labels
bug Something isn't working enhancement New feature or request invalid This doesn't seem right

Comments

@nk027
Copy link
Collaborator

nk027 commented Nov 12, 2019

When calculating prices of supply we have some issues.

  • We have six occurrences of negative USD values and 34 of negative m3. All stem from forestry data.
  • There's 2824 NA values of USD, where tonnes are available (over 113 items)
  • Vice versa there's 42251 NAs of tonnes, where USD are available (products not measured in tonnes presumably)
  • There's 59 occurrences of Inf prices - all are related to Alcohol, since it is provided in litres instead of tonnes - we skipped estimating tonnes from prices so far
@nk027
Copy link
Collaborator Author

nk027 commented Nov 12, 2019

Estimating tonnes of Alcohol from prices is problematic -- we get:

     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
        0         0         0     38062         0 100498539 

Rplot001

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.

@nk027
Copy link
Collaborator Author

nk027 commented Nov 12, 2019

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.

nk027 added a commit that referenced this issue Nov 12, 2019
@nk027
Copy link
Collaborator Author

nk027 commented Nov 25, 2019

  • Also there are quite some occurrences of weird prices, i.e. tiny or huge, beside alcohol.
  • Also there's some Inf prices (just usd, no other info) for Fish, Seafood.
  • Also we know of a single Malian camelid in 1999, that has no additional information attached to it.

@nk027
Copy link
Collaborator Author

nk027 commented Nov 25, 2019

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.

@nk027
Copy link
Collaborator Author

nk027 commented Nov 26, 2019

To get really good price estimates we would need some other source - FAO, Worldbank, WTO or similar. E.g. the World Bank Commodity Prices.

@nk027 nk027 added bug Something isn't working enhancement New feature or request invalid This doesn't seem right on hold Work on this later Priority Better fix this! and removed on hold Work on this later labels Nov 26, 2019
@nk027 nk027 removed the Priority Better fix this! label Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant