Type: | Package |
Title: | Coincident Profile |
Version: | 0.1.9 |
Date: | 2019-08-22 |
Author: | Wilmer Martinez <womartin@asu.edu> |
Maintainer: | Wilmer Martinez <womartin@asu.edu> |
License: | GPL-2 |
Encoding: | UTF-8 |
LazyData: | TRUE |
Imports: | zoo, stats, plyr, coin, Rdpack, exactRankTests (≥ 0.8-29), ggplot2 (≥ 1.0.1) |
RdMacros: | Rdpack |
Description: | Builds the coincident profile proposed by Martinez, W and Nieto, Fabio H and Poncela, P (2016) <doi:10.1016/j.spl.2015.11.008>. This methodology studies the relationship between a couple of time series based on the the set of turning points of each time series. The coincident profile establishes if two time series are coincident, or one of them leads the second. |
RoxygenNote: | 6.1.1 |
Suggests: | knitr, rmarkdown |
URL: | https://github.com/WilmerMartinezR/Coinprofile |
BugReports: | https://github.com/WilmerMartinezR/Coinprofile/issues |
NeedsCompilation: | no |
Packaged: | 2019-08-24 16:27:09 UTC; wilmermartinezrivera |
Repository: | CRAN |
Date/Publication: | 2019-08-25 07:20:09 UTC |
Turning points
Description
Calculates turning points of a time series using the Bry and Boschan (1971) methodology
Usage
TP_BryBoschan(x, frequ = 12, year = 1, month = 1)
Arguments
x |
univariate time series |
frequ |
Frequency of the x, 12 monthly or 4 quarterly. Default value 12. |
year |
The start year of the time series. Default value 1. |
month |
The start month of the time series. Default value 1. |
Value
The dates of the turning points
Author(s)
Wilmer O Martinez R
References
Bry, G. and Boschan, C. (1971) Cyclical Analysis of Time Series: Selected Procedures and Computer Programs, National Bureau of Economic Research, Inc 71(1), 7-63.
Burns, A.F. and Mitchell, W. (1946) Measuring Business Cycles, National Bureau of Economic Research, NBER, New York.
Examples
x <- rnorm(100)
TP_BryBoschan(x)
Coincident Profile
Description
Returns the coincident profile developed by Martinez et al. (2016). The ideal result is finding the maximum p-value for the lag = 0; otherwise maximum p-value for negative lags suggest leading from x to y, or maximum p-value for positive lags suggest leading from y to x.
Usage
coincident_profile(x, y, frequ = 12, MLag = 6, nvar1 = "name.x",
nvar2 = "name.y", print.graf = FALSE, iyear = 1,
lyear = numeric(), imonth = 12, lmonth = numeric(),
tit1 = "Title.x", tit2 = "Title.y", tit3 = "Title.x.y")
Arguments
x |
Univariate time series |
y |
Univariate time series |
frequ |
Frequency of x and y. x and y must have the same frequency |
MLag |
Maximum lag for the coincident profile |
nvar1 |
Name of x |
nvar2 |
Name of y |
print.graf |
If TRUE returns a panel 2x2 where the superior panel has both plots of x and y with their turning points (maximums black dots lines and minimums red dots lines). The inferior left panel has the matplot of x and y standardized, respectively (x-mean(x))/sd(x). The inferior right panel has the coincident profile where TP shows the number of turning points used. |
iyear |
The year of the first observation. A single number |
lyear |
The year of the last observation. A single number |
imonth |
The amount of months for the first year. A single number |
lmonth |
The amount of months for the last year. A single number |
tit1 |
Title for the plot x |
tit2 |
Title for the plot y |
tit3 |
Title for the plot x and y |
Details
The main output contains two objects: the coincident profile (Profile) and both the lag which has the highest probability and the number of turning points considered to the calculus of the coincident profile (MainLag).
Value
The coincident profile
Author(s)
Wilmer O Martinez R
References
Martinez, W and Nieto, Fabio H and Poncela, P (2016) "Choosing a dynamic common factor as a coincident index", Statistics and Probability Letters, (109), 89-98. http://dx.doi.org/10.1016/j.spl.2015.11.008.
Banerji, A., (1999) "The lead profile and others non-parametrics tools to evaluate survey series as leading indicators", Survey Data for Industry, Research and Economic Policy, selected papers presented at the 24th CIRET Conference, Willington, New Zealand.
Examples
set.seed(123)
w <- seq(-3, 7, length.out = 100)
x1 <- sin(pi*w)+rnorm(100,0,0.1)
x2 <- sin(pi*w-0.1)+rnorm(100,0,0.1)
coincident_profile(x1, x2, 4, 5, "name.x", "name.y", TRUE, 1991, 2015, 4, 4)
# In this example x leads y three periods
set.seed(123)
w <- seq(-3, 7, length.out = 100)
x <- sin(pi*w)+rnorm(100,0,0.1)
y <- sin(pi*w-1)+rnorm(100,0,0.1)
coincident_profile(x, y, 4, 6, "name.x", "name.y", TRUE, 1991, 2015, 4, 4)
Closest differences
Description
Finds closest differences between two sets of turning points
Usage
dif_TP(dato1, dato2, minmax = 1)
Arguments
dato1 |
A vector of data |
dato2 |
A vector of data2 |
minmax |
Indicator variable 1 minimum, 2 maximum |
Details
From Martinez et al. (2016): "When the number of turning points in the two time series that are being compared is not the same, we recommend choosing the pairs of turning points, i.e. peak–peak and trough–trough, in the following way: take the first peak of the first time series, then compute the chronological difference with each one of the peaks of the second time series and choose the peak in this time series that leaves the smallest algebraic difference. Now, consider the second peak of the first time series and compute the differences with all the peaks of the second one but the peaks that precedes the one chosen in the previous step. Take from the second time series that for which the difference is the smallest. This procedure for pairing peaks is repeated until either all the peaks in the first time series have been considered or all the peaks in the second series have been exhausted."
Value
Differences between turning points
Examples
x <- rnorm(100)
y <- rnorm(100)
dif_TP(TP_BryBoschan(x),TP_BryBoschan(y))