Open bpbond opened 7 years ago
Fixed in #278
i think there are two "good practices" to go about this issue. but the current practice fits neither of them. we should standardize one single "good practice" and stick to it throughout dsr.
CURRENT PRACTICE:
usda_gdp_mer %>%
...
mutate(value = value * CONV_BIL_MIL * gdp_deflator(1990, base_year = 2010)
ISSUE: this reads like "convert gdp FROM billion TO million, convert gdp FROM 1990$ TO 2010$" but this is exactly the opposite. it converts FROM 2010$ TO 1990$. the original sin is that the economist created a "deflator" to be a divisor, not a multiplier.
GOOD PRACTICE 1: this keeps the economics convention of a deflator as a divisor.
usda_gdp_mer %>%
...
mutate(value = value * CONV_BIL_MIL / gdp_deflator(2010, base_year = 1990)
GOOD PRACTICE 2: this creates a new function "CONV_REAL_DOLLAR" which is the inverse of the gdp_deflator. This keeps coding convention of using multiplier for a converter.
usda_gdp_mer %>%
...
mutate(value = value * CONV_BIL_MIL * CONV_REAL_DOLLAR(from.year=2010, to.year = 1990)
I agree that it's a wart that the conversion constants have the FROM and TO in the opposite order that the gdp_deflator function does. Unfortunately, by the time I took a look at it, people had already started using it, and that makes it dicey to change, particularly while we have so many people actively developing. If we want to fix this we should probably wait until this first round of development calms down. Changing the name of the function to conv_dollar_year
or something like that could help here, since any use of the old convention would fail outright, instead of producing incorrect results.
I am opposed to using the conventions of economics where they are at variance with the conventions of mathematics or computational science. Economists use a lot of weird conventions (like putting the abcissa on the vertical axis), and I don't think we should be bound to them. Very few economists will actually look at this code anyhow. However, I do agree that we shouldn't misuse economics jargon. If a "deflator" is normally a divisor, then we should call our conversion factors something else.
RESOLVED: we wait until the end of the dsr, then we replace all: GOOD PRACTICE 2: this creates a new function "CONV_REAL_DOLLAR" which is the inverse of the gdp_deflator. This keeps coding convention of using multiplier for a converter.
@rplzzz requested assignment to this as I remember. See discussion in #247 .