Description Usage Arguments Value Examples
Take (mostly) the same inputs as the FEWS function and return the decomposition on the multilateral scale.
1 2 | TPD_decomp(times, logprice, id, weight, custom_time = c(),
window_length = NULL, verbose = FALSE)
|
times |
vector of the times at which price observations were made. |
logprice |
vector of log of prices at the given time |
id |
vector of distinct identification number of consumer goods |
weight |
vector of expenditure weights used in the regressions |
custom_time |
either empty (will assume latest periods) or a vector of length two relating to times compared where [1] is the 'from' time and [2] is the 'to' time e.g Comparing contribution from "1973-04-01" to "1973-05-01" would be c("1973-04-01", "1973-05-01") |
window_length |
optional. Single number for length of window for the data that regressions are fit on. Note if window_length is present it assumes custom time is latest two periods in window. |
A dataframe containing the numeric contribution (contrib
) of every price observation
in the window, the product of which will equal the index movement between the two time periods.
p_contrib
is the standardised percentage contribution of the observation, the sum of which will equal 1.
id_p_contrib
is the standardised percentage contribution of the total id, the sum of which will equal 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library(TPDdecomp)
load("Turvey.RData")
contributions <- with(
turvey,
TPD_decomp(times = month,
logprice = log(price),
id = commodity,
weight = price*quantity,
custom_time = c("1973-04-30","1973-05-31"),
window_length = NULL)
)
#Comparing 1973-05-31 to 1973-04-30
str(contributions)
Classes ‘data.table’ and 'data.frame': 176 obs. of 8 variables:
$ times : Date, format: "1973-07-31" "1973-06-30" "1973-05-31" ...
$ price : num 5.19 4.53 7.17 4.3 3.98 6.21 3.78 3.72 5.68 3.27 ...
$ weight : num 14932 18505 7407 10892 14495 ...
$ id : chr "Strawberries" "Strawberries" "Strawberries" "Strawberries" ...
$ exp_share : num 0.36 0.413 0.238 0.342 0.41 ...
$ contrib : num 0.965 0.967 1.545 0.97 0.97 ...
$ p_contrib : num -0.208 -0.201 2.58 -0.181 -0.184 ...
$ id_p_contrib: num 0.663 0.663 0.663 0.663 0.663 ...
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.