Title: | Inflators for Australian Policy Analysis |
---|---|
Description: | Using Australian Bureau of Statistics indices, provides functions that convert historical, nominal statistics to real, contemporary values without worrying about date input quality, performance, or the ABS catalogue. |
Authors: | Hugh Parsonage [aut, cre] |
Maintainer: | Hugh Parsonage <[email protected]> |
License: | GPL-2 |
Version: | 0.5.4 |
Built: | 2024-11-20 06:43:12 UTC |
Source: | CRAN |
The package uses the catalogue mirrored at https://github.com/HughParsonage/ABS-Catalogue. These functions expose the guts of the package's method to connect to this mirror.
Each inflator, plus the 'adjustment', is associated with an ABS Series ID.
content2series_id( broad_cat = c("cpi", "lfi", "wpi"), adjustment = c("original", "seasonal", "trend", "trimmed-mean", "monthly-original", "monthly-seasonal", "monthly-excl-volatile") ) download_data(series_id = NULL) when_last_updated()
content2series_id( broad_cat = c("cpi", "lfi", "wpi"), adjustment = c("original", "seasonal", "trend", "trimmed-mean", "monthly-original", "monthly-seasonal", "monthly-excl-volatile") ) download_data(series_id = NULL) when_last_updated()
broad_cat , adjustment
|
Definitions to identify the Series ID. If any are multiple, the result is of the cartesian join, not the component-wise values. |
series_id |
The Series ID desired. For |
content2series_id
A character vector, the Series ID identified by 'broad_cat' and 'adjustment'
download_data
Called for its side-effect, downloading the data required. If successful, returns zero.
when_last_updated
The date the downloaded data was last retrieved, or
the string "Never"
if the file does not exist.
CPI inflator
cpi_inflator( from = NULL, to = NULL, series = c("seasonal", "original", "trimmed.mean", "monthly-original", "monthly-seasonal", "monthly-excl-volatile"), fy_month = 3L, x = NULL, check = 1L, nThread = getOption("grattanInflators.nThread", 1L) ) cpi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") cpi_original(..., FORECAST = FALSE, LEVEL = "mean") cpi_trimmed_mean(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_original(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_seasonal(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_excl_volatile(..., FORECAST = FALSE, LEVEL = "mean")
cpi_inflator( from = NULL, to = NULL, series = c("seasonal", "original", "trimmed.mean", "monthly-original", "monthly-seasonal", "monthly-excl-volatile"), fy_month = 3L, x = NULL, check = 1L, nThread = getOption("grattanInflators.nThread", 1L) ) cpi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") cpi_original(..., FORECAST = FALSE, LEVEL = "mean") cpi_trimmed_mean(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_original(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_seasonal(..., FORECAST = FALSE, LEVEL = "mean") cpi_monthly_excl_volatile(..., FORECAST = FALSE, LEVEL = "mean")
from , to
|
Times for which the inflator is desired. If |
series |
Which CPI series to use. |
fy_month |
An integer 1-12, the month to be used for
years and financial years in |
x |
(Advanced) A vector that will be inflated in-place. If |
check |
|
nThread |
Number of threads to use. |
... |
Set of date-rate pairs for custom CPI series in the future. |
FORECAST |
Whether the series should be extended via an ETS forecast. |
LEVEL |
If 'FORECAST = TRUE' what prediction interval should be used. ('LEVEL = 20' means the lower end of an 80% prediction interval.) If 'LEVEL = "mean"' (the default), the central estimate is used. |
If 'x' is 'NULL', the default, a numeric vector matching the lengths of 'from' and 'to' equal to the inflators by which nominal prices dated 'from' must be multiplied so that they are in 'to' real terms.
If 'x' is numeric, it is taken to be prices dated 'from' and the value returned is 'x' in 'to' real terms.
cpi_inflator(1995, 2019) # Inflation from 1995 to 2019 cpi_inflator("2015-16", "2016-17") cpi_inflator("2015-01-01", "2016-01-01") if (Sys.Date() < as.Date("2029-01-01")) { cpi_inflator("2030-01-01", "2031-01-01", series = cpi_original(2030, 0.1)) cpi_inflator("2030-01-01", "2031-01-01", series = cpi_original(0.1)) cpi_inflator("2030-01-01", "2032-01-01", series = cpi_original(2030, 0.1, 2031, 0.1, 2032, 0)) }
cpi_inflator(1995, 2019) # Inflation from 1995 to 2019 cpi_inflator("2015-16", "2016-17") cpi_inflator("2015-01-01", "2016-01-01") if (Sys.Date() < as.Date("2029-01-01")) { cpi_inflator("2030-01-01", "2031-01-01", series = cpi_original(2030, 0.1)) cpi_inflator("2030-01-01", "2031-01-01", series = cpi_original(0.1)) cpi_inflator("2030-01-01", "2032-01-01", series = cpi_original(2030, 0.1, 2031, 0.1, 2032, 0)) }
Used when the true series is not appropriate, as when a forecast is desired and the series is required beyond the original series.
dr2index(index, d1, r1, ...)
dr2index(index, d1, r1, ...)
index |
An index (i.e. a data.table with columns |
d1 |
A single date or value representing a date. |
r1 |
The desired rate of increase for the index from the last date in |
... |
A set of date-rate pairs. |
index
with dates extended until the last supported date. The final rate
supplied is the rate for all dates after the final date.
Faster conversion to IDate for common dates
fast_as_idate( x, incl_day = TRUE, check = 0L, nThread = 1L, format = "%Y-%m-%d" )
fast_as_idate( x, incl_day = TRUE, check = 0L, nThread = 1L, format = "%Y-%m-%d" )
x |
The character vector to convert, in |
incl_day |
Whether or not the day is necessary to convert. Set to |
check |
|
nThread |
Number of threads to use. |
format |
The expected format of the input. |
A 10M vector of dates was observed to be parsed in 0.1s whereas
as.IDate
took 9.0s, and lubridate::ymd
, 1.6s.
Note that false dates (such as Feb 30)
will be naively parsed without warning or error (unless 'check' is
changed from its default argument).
A vector of class IDate
, Date
the same length as x
.
# For ABS data, we only need to care (and check) # the year and month fast_as_idate("2015-12-13", incl_day = FALSE)
# For ABS data, we only need to care (and check) # the year and month fast_as_idate("2015-12-13", incl_day = FALSE)
Generic inflator
Inflate( from, to, index, x = NULL, fy_month = 3L, check = 2L, nThread = getOption("grattanInflators.nThread", 1L) )
Inflate( from, to, index, x = NULL, fy_month = 3L, check = 2L, nThread = getOption("grattanInflators.nThread", 1L) )
from , to
|
Times for which the inflator is desired. If |
index |
A table of at least two columns, named |
x |
(Advanced) A vector that will be inflated in-place. If |
fy_month |
An integer 1-12, the month to be used for
years and financial years in |
check |
|
nThread |
Number of threads to use. |
If 'x' is 'NULL', the default, a numeric vector matching the lengths of 'from'
and 'to' equal to the ratio between the corresponding values in the column
value
.
If 'x' is numeric, those values are multiplied by the inflators, in-place.
Uses the Labour Force Index to provide equivalent sizes of the labour force over different times by multiplying by the simple ratio of the sizes on those dates.
lf_inflator( from = NULL, to = NULL, check = 1L, series = lfi_original(), fy_month = 3L, x = NULL, nThread = getOption("grattanInflators.nThread", 1L) ) lfi_original(..., FORECAST = FALSE, LEVEL = "mean") lfi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") lfi_trend(..., FORECAST = FALSE, LEVEL = "mean")
lf_inflator( from = NULL, to = NULL, check = 1L, series = lfi_original(), fy_month = 3L, x = NULL, nThread = getOption("grattanInflators.nThread", 1L) ) lfi_original(..., FORECAST = FALSE, LEVEL = "mean") lfi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") lfi_trend(..., FORECAST = FALSE, LEVEL = "mean")
from , to
|
Times for which the inflator is desired. If |
check |
|
series |
A call to 'lfi_original()', 'lfi_seasonal()', or 'lfi_trend()'. |
fy_month |
The month to be used in 'series' for financial years. |
x |
(Advanced) A vector that will be inflated in-place. If |
nThread |
Number of threads to use. |
... |
Set of date-rate pairs for custom labour force series in the future. |
FORECAST |
Whether the series should be extended via an ETS forecast. |
LEVEL |
If 'FORECAST = TRUE' what prediction interval should be used. ('LEVEL = 20' means the lower end of an 80% prediction interval.) If 'LEVEL = "mean"' (the default), the central estimate is used. |
If 'x' is 'NULL', the default, a numeric vector matching the lengths of 'from' and 'to' equal to the relative size of the labour force of 'from' and 'to'.
If 'x' is numeric, it is taken to be the sizes of the labour force on dates 'from' and the value returned is the equivalent size of 'x' on dates 'to' (by simple multiplication).
# The relative size of the labour force in FY 2016-17 # compared to FY 2015-16 lf_inflator("2015-16", "2016-17")
# The relative size of the labour force in FY 2016-17 # compared to FY 2015-16 lf_inflator("2015-16", "2016-17")
Uses the Wage Price Index
wage_inflator( from = NULL, to = NULL, check = 1L, series = wpi_original(), fy_month = 3L, x = NULL, nThread = getOption("grattanInflators.nThread", 1L) ) wpi_original(..., FORECAST = FALSE, LEVEL = "mean") wpi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") wpi_trend(..., FORECAST = FALSE, LEVEL = "mean")
wage_inflator( from = NULL, to = NULL, check = 1L, series = wpi_original(), fy_month = 3L, x = NULL, nThread = getOption("grattanInflators.nThread", 1L) ) wpi_original(..., FORECAST = FALSE, LEVEL = "mean") wpi_seasonal(..., FORECAST = FALSE, LEVEL = "mean") wpi_trend(..., FORECAST = FALSE, LEVEL = "mean")
from , to
|
Times for which the inflator is desired. If |
check |
|
series |
A call to 'wpi_original()', 'wpi_seasonal()', or 'wpi_trend()', defining which wage price index series to use. |
fy_month |
The month to be used in 'series' for financial years. |
x |
(Advanced) A vector that will be inflated in-place. If |
nThread |
Number of threads to use. |
... |
Set of date-rate pairs for custom WPI series in the future. |
FORECAST |
Whether the series should be extended via an ETS forecast. |
LEVEL |
If 'FORECAST = TRUE' what prediction interval should be used. ('LEVEL = 20' means the lower end of an 80% prediction interval.) If 'LEVEL = "mean"' (the default), the central estimate is used. |
If 'x' is 'NULL', the default, a numeric vector matching the lengths of 'from' and 'to' equal to the inflators by which nominal wages dated 'from' must be multiplied so that they are in 'to' real terms.
If 'x' is numeric, it is taken to be wages dated 'from' and the value returned is 'x' in 'to' real terms.