Title: | Statistical Tests for Functional Time Series |
---|---|
Description: | A collection of statistical hypothesis tests of functional time series. While it will include more tests when the related literature are enriched, this package contains the following key tests: functional stationarity test, functional trend stationarity test, functional unit root test, to name a few. |
Authors: | Yichao Chen [aut], Chi Seng Pun [cre, aut] |
Maintainer: | Chi Seng Pun <[email protected]> |
License: | GPL-2 |
Version: | 0.1.0 |
Built: | 2025-03-01 04:05:49 UTC |
Source: | https://github.com/cran/STFTS |
Generate a dataset of independent simulated values of , where
is a standard Brownian bridge on [0,1].
Generate a dataset of independent simulated values of , where
is a standard Brownian bridge on [0,1].
dataset_bb(NUM) dataset_bb(NUM)
dataset_bb(NUM) dataset_bb(NUM)
NUM |
Number of simulated values generated in the dataset. |
A vector with length equals to NUM.
A vector with length equals to NUM.
dataset_bb(10) dataset_bb(10)
dataset_bb(10) dataset_bb(10)
Generate a dataset of independent simulated values of , where
is a standard Brownian motion on [0,1].
dataset_bm(NUM)
dataset_bm(NUM)
NUM |
Number of simulated values generated in the dataset. |
A vector with length equals to NUM.
dataset_bm(10)
dataset_bm(10)
Generate a dataset of independent simulated values of , where
is a standard Brownian bridge on [0,1].
dataset_dbb(NUM)
dataset_dbb(NUM)
NUM |
Number of simulated values generated in the dataset. |
A vector with length equals to NUM.
dataset_dbb(10)
dataset_dbb(10)
Generate a dataset of independent simulated values of , where
is a standard Brownian motion on [0,1].
dataset_sbb(NUM)
dataset_sbb(NUM)
NUM |
Number of simulated values generated in the dataset. |
A vector with length equals to NUM.
dataset_sbb(10)
dataset_sbb(10)
Default kernel function used in calculating the estimated long-run covariance function.
default_kernel(x)
default_kernel(x)
x |
The variable. |
The kernel value.
default_kernel(1) default_kernel(0)
default_kernel(1) default_kernel(0)
Calculate the eigenvalues of an estimated long-run covariance function.
est_eigenvalue(este, K, h_power, estev)
est_eigenvalue(este, K, h_power, estev)
este |
Estimated errors in the long-run covariance function, inputted in a matrix form with each row representing each observation of the functional error values on equidistant points of any prespecified interval. |
K |
Kernel function in the estimation of the long-run covariance function. |
h_power |
Power of sample size 'N' (valued in (0,1)) for the smoothing bandwidth in the kernel function. |
estev |
Number of the largest eigenvalues chosen in the output. |
A vector of first 'estev' largest eigenvalues in descending order.
N<-100 EE<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EE[i,1]<-temp[1] for (j in 2:100) { EE[i,j]<-EE[i,j-1]+temp[j] } } est_eigenvalue(este=EE,K=default_kernel,h_power=1/2,estev=10)
N<-100 EE<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EE[i,1]<-temp[1] for (j in 2:100) { EE[i,j]<-EE[i,j-1]+temp[j] } } est_eigenvalue(este=EE,K=default_kernel,h_power=1/2,estev=10)
Calculate test statistic R_N for functional KPSS test, which Was constructed in Kokoszka and Young (2016) and Chen and Pun (2019).
FKPSS_teststat(X)
FKPSS_teststat(X)
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
The value of test statistic R_N for functional KPSS test.
Chen, Y., & Pun, C. S. (2019). A bootstrap-based KPSS test for functional time series. Journal of Multivariate Analysis, 174, 104535.
Kokoszka, P., & Young, G. (2016). KPSS test for functional time series. Statistics, 50(5), 957-973.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_TN(EX)
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_TN(EX)
KPSS test for functional time series with different methods on determining the critical values of the test statistic. The Monte Carlo method (for a large sample size) was constructed in Kokoszka and Young (2016) and the bootstrap-based methods (both the simple bootstrap method and moving block bootstrap method, for a small/moderate sample size) were constructed in Chen and Pun (2019).
fkpsst( X, ALPHA = 0.05, METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X), MCNsim = 10000, sbb_set = NULL, M = 1000, b = ceiling((2 * nrow(X))^(1/3)) )
fkpsst( X, ALPHA = 0.05, METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X), MCNsim = 10000, sbb_set = NULL, M = 1000, b = ceiling((2 * nrow(X))^(1/3)) )
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
ALPHA |
Significance level of the test. The default value is 5%. |
METHOD |
Method to determine the critical value of the test statistic. The default value 'METHOD="MC"' represents the Monte Carlo method. 'METHOD="SB"' represents the simple bootstrap method and 'METHOD="MBB"' represents the moving block bootstrap method. |
K |
Kernel function in the estimation of the long-run covariance function, which is only effective in the Monte Carlo method. The default function is 'default_kernel' function in this package. |
h_power |
Power of sample size 'N' (valued in (0,1)) for the smoothing bandwidth, which is only effective in the Monte Carlo method. The default value is 2/5. |
est_ev |
Number of the largest eigenvalues chosen to estimate the limiting distribution, which is only effective in the Monte Carlo method. The default value is the sample size 'N'. |
MCNsim |
Number of Monte Carlo datasets generated in the Monte Carlo method, which is only effective in Monte Carlo method. The default value is 10000. |
sbb_set |
A vector of independent simulated data generated from the function 'dataset_sbb', which is only effective and essential in Monte Carlo method. |
M |
Number of bootstrap datasets generated in the bootstrap method, which is only effective in bootstrap methods. The default value is 1000. |
b |
Block length used in the moving block bootstrap method, which is only effective in the moving block bootstrap method. The default value is ceiling((2N)^(1/3)), where 'N' is the sample size. |
The result of the test is presented with the value of test statistic and its p-value under the null hypothesis of trend stationarity.
Chen, Y., & Pun, C. S. (2019). A bootstrap-based KPSS test for functional time series. Journal of Multivariate Analysis, 174, 104535.
Kokoszka, P., & Young, G. (2016). KPSS test for functional time series. Statistics, 50(5), 957-973.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) EXI<-rep(0,100) set.seed(1) EXI[1]<-rnorm(1,0,1) for (j in 2:100) {EXI[j]<-EXI[j-1]+rnorm(1,0,1)} for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } fkpsst(X=EX,METHOD="SB")
N<-100 EX<-matrix(rep(0,N*100),ncol=100) EXI<-rep(0,100) set.seed(1) EXI[1]<-rnorm(1,0,1) for (j in 2:100) {EXI[j]<-EXI[j-1]+rnorm(1,0,1)} for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } fkpsst(X=EX,METHOD="SB")
Stationarity test for functional time series with different methods on determining the critical values of the test statistic. The Monte Carlo method was constructed in Horvath et al. (2014), while the bootstrap-based methods have not been validated in the literature (although such an option is provided, please use them at your own risk).
fst( X, STAT = 1, ALPHA = 0.05, METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X), MCNsim = 10000, bb_set = NULL, dbb_set = NULL, M = 1000, b = ceiling((2 * nrow(X))^(1/3)) )
fst( X, STAT = 1, ALPHA = 0.05, METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X), MCNsim = 10000, bb_set = NULL, dbb_set = NULL, M = 1000, b = ceiling((2 * nrow(X))^(1/3)) )
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
STAT |
Test statistic used in the stationarity test. The default value 'STAT=1' represents 'T_N' and 'STAT=2' represents 'M_N' in original paper. |
ALPHA |
Significance level of the test. The default value is 5%. |
METHOD |
Method to determine the critical value of the test statistic. The default value 'METHOD="MC"' represents the Monte Carlo method. 'METHOD="SB"' represents the simple bootstrap method and 'METHOD="MBB"' represents the moving block bootstrap method. |
K |
Kernel function in the estimation of the long-run covariance function, which is only effective in the Monte Carlo method. The default function is 'default_kernel' function in this package. |
h_power |
Power of sample size 'N' (valued in (0,1)) for the smoothing bandwidth, which is only effective in the Monte Carlo method. The default value is 2/5. |
est_ev |
Number of the largest eigenvalues chosen to estimate the limiting distribution, which is only effective in the Monte Carlo method. The default value is the sample size 'N'. |
MCNsim |
Number of Monte Carlo datasets generated in the Monte Carlo method, which is only effective in Monte Carlo method. The default value is 10000. |
bb_set |
A vector of independent simulated data generated from the function 'dataset_bb', which is only effective and essential in Monte Carlo method with 'STAT=1'. |
dbb_set |
A vector of independent simulated data generated from the function 'dataset_dbb', which is only effective and essential in Monte Carlo method with 'STAT=2'. |
M |
Number of bootstrap datasets generated in the bootstrap method, which is only effective in bootstrap methods. The default value is 1000. |
b |
Block length used in the moving block bootstrap method, which is only effective in the moving block bootstrap method. The default value is ceiling((2N)^(1/3)), where 'N' is the sample size. |
The result of the test is presented with the value of test statistic and its p-value under the null hypothesis of local stationarity.
Horvath, L., Kokoszka, P., & Rice, G. (2014). Testing stationarity of functional time series. Journal of Econometrics, 179(1), 66-82.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } fst(X=EX,METHOD="SB")
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } fst(X=EX,METHOD="SB")
Calculate test statistic M_N for functional stationarity test, which was constructed in Horvath et al. (2014).
FST_teststat_MN(X)
FST_teststat_MN(X)
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
The value of test statistic M_N calculated for functional stationarity test.
Horvath, L., Kokoszka, P., & Rice, G. (2014). Testing stationarity of functional time series. Journal of Econometrics, 179(1), 66-82.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_MN(EX)
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_MN(EX)
Calculate test statistic T_N for functional stationarity test, which was constructed in Horvath et al. (2014).
FST_teststat_TN(X)
FST_teststat_TN(X)
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
The value of test statistic T_N calculated for functional stationarity test.
Horvath, L., Kokoszka, P., & Rice, G. (2014). Testing stationarity of functional time series. Journal of Econometrics, 179(1), 66-82.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_TN(EX)
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } FST_teststat_TN(EX)
Unit root test for functional time series with different methods on determining the critical values of the test statistic. The Monte Carlo method was constructed in Chen and Pun (2021), while the bootstrap-based methods have not been validated in the literature (although such an option is provided, please use them at your own risk).
furt( X, ALPHA = 0.05, TYPE = "R", METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X) - 1, MCNsim = 10000, bm_set = NULL, M = 1000, b = ceiling((2 * (nrow(X) - 1))^(1/3)) )
furt( X, ALPHA = 0.05, TYPE = "R", METHOD = "MC", K = default_kernel, h_power = 2/5, est_ev = nrow(X) - 1, MCNsim = 10000, bm_set = NULL, M = 1000, b = ceiling((2 * (nrow(X) - 1))^(1/3)) )
X |
The functional time series being tested, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
ALPHA |
Significance level of the test. The default value is 5%. |
TYPE |
Type of hypothesis test. The default value 'TYPE="R"' represents the right-tailed test, which is used when the alternative hypothesis is trend stationarity model. 'TYPE="L"' represents the left-tailed test, which is used when the alternative hypothesis is simple stationarity model or AR(1) model. |
METHOD |
Method to determine the critical value of the test statistic. The default value 'METHOD="MC"' represents the Monte Carlo method. 'METHOD="SB"' represents the simple bootstrap method and 'METHOD="MBB"' represents the moving block bootstrap method. |
K |
Kernel function in the estimation of the long-run covariance function, which is only effective in the Monte Carlo method. The default function is 'default_kernel' function in this package. |
h_power |
Power of sample size 'N' (valued in (0,1)) for the smoothing bandwidth, which is only effective in the Monte Carlo method. The default value is 2/5. |
est_ev |
Number of the largest eigenvalues chosen to estimate the limiting distribution, which is only effective in the Monte Carlo method. The default value is the sample size 'N'. |
MCNsim |
Number of Monte Carlo datasets generated in the Monte Carlo method, which is only effective in Monte Carlo method. The default value is 10000. |
bm_set |
A vector of independent simulated data generated from the function 'dataset_bm', which is only effective and essential in Monte Carlo method. |
M |
Number of bootstrap datasets generated in the bootstrap method, which is only effective in bootstrap methods. The default value is 1000. |
b |
Block length used in the moving block bootstrap method, which is only effective in the moving block bootstrap method. The default value is ceiling((2N)^(1/3)), where 'N' is the sample size. |
The result of the test is presented with the value of test statistic and its p-value under the null hypothesis of functional random walk.
Chen, Y., & Pun, C. S. (2021). Functional Unit Root Test. Available at SSRN.
N<-100 EE<-matrix(rep(0,N*100),ncol=100) EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EE[i,1]<-temp[1] for (j in 2:100) { EE[i,j]<-EE[i,j-1]+temp[j] } } EX[1,]<-EE[1,] for (i in 2:N) {EX[i,]<-EX[i-1]+EE[i,]} furt(X=EX,METHOD="SB")
N<-100 EE<-matrix(rep(0,N*100),ncol=100) EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EE[i,1]<-temp[1] for (j in 2:100) { EE[i,j]<-EE[i,j-1]+temp[j] } } EX[1,]<-EE[1,] for (i in 2:N) {EX[i,]<-EX[i-1]+EE[i,]} furt(X=EX,METHOD="SB")
Calculate the partial sum matrix of a functional time series.
partial_sum(X)
partial_sum(X)
X |
The functional time series being calculated, inputted in a matrix form with each row representing each observation of the functional data values on equidistant points of any prespecified interval. |
A square matrix of partial sums of the functional time series. The column (row) dimension of the output matrix is equal to the column dimension of the input matrix.
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } partial_sum(EX)
N<-100 EX<-matrix(rep(0,N*100),ncol=100) set.seed(1) for (i in 1:N) { temp<-rnorm(100,0,1) EX[i,1]<-temp[1] for (j in 2:100) { EX[i,j]<-EX[i,j-1]+temp[j] } } partial_sum(EX)