rangemean.tstat: Range-Mean Regression

View source: R/differencing.R

rangemean.tstatR Documentation

Range-Mean Regression

Description

Function to perform a range-mean regression, trimmed to avoid outlier distortion. The slope is used in TRAMO to select whether the original series will be transformed into log or maintain in level.

Usage

rangemean.tstat(data, period = 0, groupsize = 0, trim = 0)

Arguments

data

data to test.

period

periodicity of the data.

groupsize

number of observations per group (before being trimmed). The default group size (groupsize = 0) is computed as followed:

  • if period = 12 or period = 6, it is equal to 12;

  • if period = 4 it is equal to 12 if the data has at least 166 observations, 8 otherwise;

  • if period = 3 or period = 2 it is equal to 12 if the data has at least 166 observations, 6 otherwise;

  • if period = 1 it is equal to 9 if the data has at least 166 observations, 5 otherwise;

  • it is equal to period otherwise.

trim

number of trimmed observations.

Details

First, the data is divided into n groups of successive observations of length l (groupsize). That is, the first group is formed with the first l observations, the second group is formed with observations 1+l to 2l, etc. Then, for each group i, the observations are sorted and the trim smallest and largest observations are rejected (to avoid outlier distortion). With the other observations, the range (noted y_i) and mean (noted m_i) are computed.

Finally, the following regression is performed :

y_t = α + β m_t + u_t.

The function rangemean.tstat returns the T-statistic associated to β. If it is significantly higher than 0, log transformation is recommended.

Value

T-Stat of the slope of the range-mean regression.

Examples

y = rjd3toolkit::ABS$X0.2.09.10.M
# Multiplicative pattern
plot(y)
period = 12
rm_t = rangemean.tstat(y, period = period, groupsize = period)
rm_t # higher than 0
# Can be tested:
pt(rm_t, period - 2, lower.tail = FALSE)
# Or :
1-rjd3toolkit::cdfT(period-2, rm_t)

# Close to 0
rm_t_log = rangemean.tstat(log(y), period = period, groupsize = period)
rm_t_log
pt(rm_t_log, period - 2, lower.tail = FALSE)

palatej/rjd3modelling documentation built on Jan. 3, 2023, 10:19 p.m.