Title: | Working with Index Numbers |
---|---|
Description: | A set of utilities for manipulating index numbers series including chain-linking, re-referencing, and computing growth rates. |
Authors: | Miguel Serrano [aut, cre] |
Maintainer: | Miguel Serrano <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.1 |
Built: | 2025-03-04 05:37:55 UTC |
Source: | https://github.com/mserrano-ine/indexnumbertools |
Helper function to repeat the aggregate annual value of a series on each period, and possibly lag it.
aggr_rep_lag(x, fun = mean, k = 0)
aggr_rep_lag(x, fun = mean, k = 0)
x |
(ts) Any time series |
fun |
(function) Aggregation function, mean by default |
k |
(int) Units to lag. |
Applies aggregate.ts
to the series to get the annual values
and then repeats those values for every subyear period.
The k
parameter is passed to stats::lag
.
description
aggr_rep_lag(gdp_volume) |> plot()
aggr_rep_lag(gdp_volume) |> plot()
This function applies a function for univariate series ("ts") to a multivariate series ("mts").
apply_to_columns(x, f, ...)
apply_to_columns(x, f, ...)
x |
(mts) A multivariate time series. |
f |
(function) A function that takes an univariate series as input. |
... |
Arguments for |
Changes the reference year of a chain-linked series (with annual overlap).
change_ref_year(x, new_ref_year)
change_ref_year(x, new_ref_year)
x |
(ts) A chain-linked series with annual overlap. |
new_ref_year |
(num) New reference year. |
The re-referenced index series.
change_ref_year(gdp_volume, 2015) plot(gdp_volume) lines(change_ref_year(gdp_volume, 2015))
change_ref_year(gdp_volume, 2015) plot(gdp_volume) lines(change_ref_year(gdp_volume, 2015))
Function that computes the growth-rate series of a given time series.
compute_gr(x, s)
compute_gr(x, s)
x |
(ts) A time series. |
s |
(int) Lag at which the growth-rate is computed. |
Series of growth-rates.
compute_gr(gdp_current, 4)
compute_gr(gdp_current, 4)
Spanish GDP from 1995 Q1 to 2024 Q4.
A univariate time series object.
https://ine.es/jaxiT3/Tabla.htm?t=67823&L=1 Spanish National Statistics Institute.
Quantity chain-linked indices of the Spanish GDP from 1995 Q1 to 2024 Q4 with reference year 2020.
A univariate time series object
https://ine.es/jaxiT3/Tabla.htm?t=67824&L=1 Spanish National Statistics Institute.
Computes chain-linked index series from a pyp series.
get_chain_linked(x, ref_year, x_a = NULL)
get_chain_linked(x, ref_year, x_a = NULL)
x |
(ts) A pyp series. |
ref_year |
(num) Reference year for the chain-linked series. |
x_a |
(ts) Annual pyp series. If not given, it's computed by taking the average of each year. |
The chain-linked series x_chain is computed with the annual overlap method. Suppose the x series runs from (y0, p0 = 0) to (y1, p1), where pi is a subyear period. Then the chain-linked series at (y2, p2) is given by the cumulative product of the annual series from y0 to y2-1 times x at (y2, p2).
The chain-linked series.
gdp_pyp <- get_pyp(gdp_volume) get_chain_linked(gdp_pyp, 2015)
gdp_pyp <- get_pyp(gdp_volume) get_chain_linked(gdp_pyp, 2015)
Computes the pyp index series from a chain-linked series.
get_pyp(x, x_a = NULL)
get_pyp(x, x_a = NULL)
x |
(ts) Chain-linked series with annual overlap. |
x_a |
(ts) Annual chain-linked series. If not given, it's computed by taking the average of each year. |
The time series should start at (y,1) where y is any year.
The pyp series.
get_pyp(gdp_volume)
get_pyp(gdp_volume)
Returns the series of quantity indices in previous year prices from a current prices and
get_q_index(current, constant)
get_q_index(current, constant)
current |
(ts) Values at current prices. |
constant |
(ts) Values at previous year prices. |
Series of quantity indices for previous year prices.
gdp_pyp <- get_pyp(gdp_volume) gdp_constant <- gdp_current / gdp_pyp * 100 get_q_index(gdp_current, gdp_constant)
gdp_pyp <- get_pyp(gdp_volume) gdp_constant <- gdp_current / gdp_pyp * 100 get_q_index(gdp_current, gdp_constant)
Returns the (not chain-linked) series of value indices from a series of current prices.
get_v_index(current)
get_v_index(current)
current |
(ts) Series of current prices series. |
The value of the resulting series x at (y,s), where y is the year and s is the subyear period, is current(y,s)/current(y)
(ts) Series of value indices.
get_v_index(gdp_current)
get_v_index(gdp_current)