Package 'FTSgof'

Title: White Noise and Goodness-of-Fit Tests for Functional Time Series
Description: It offers comprehensive tools for the analysis of functional time series data, focusing on white noise hypothesis testing and goodness-of-fit evaluations, alongside functions for simulating data and advanced visualization techniques, such as 3D rainbow plots. These methods are described in Kokoszka, Rice, and Shang (2017) <doi:10.1016/j.jmva.2017.08.004>, Yeh, Rice, and Dubin (2023) <doi:10.1214/23-EJS2112>, Kim, Kokoszka, and Rice (2023) <doi:10.1214/23-ss143>, and Rice, Wirjanto, and Zhao (2020) <doi:10.1111/jtsa.12532>.
Authors: Mihyun Kim [aut, cre], Chi-Kuang Yeh [aut] , Yuqian Zhao [aut], Gregory Rice [ctb]
Maintainer: Mihyun Kim <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2024-11-06 05:45:14 UTC
Source: https://github.com/veritasmih/ftsgof

Help Index


FAR(p) Data Generator

Description

It generates functional data that follows a functional autoregressive process of order pp, denoted as FAR(p). The generated data consists of curves evaluated at discrete grid points.

Usage

dgp.far(J, N, S = 0.5, p = 1, kernel = "Gaussian", burn_in = 50)

Arguments

J

The number of grid points for each curve observation.

N

The sample size, representing the number of curves to be generated.

S

The serial dependence factor for the kernel used in the FAR(p) process. Default is 0.5.

p

The order of the autoregressive process. Default is 1.

kernel

The type of kernel function ψ\psi used for the autoregressive process. Can be "Gaussian" or "Wiener". Default is "Gaussian".

burn_in

The number of initial points discarded to eliminate transient effects. Default is 50.

Details

The functional autoregressive model of order pp is given by:

Xi(t)μ(t)=j=1pΨ(Xijμ)(t)+ϵi(t),X_i(t) -\mu(t) = \sum_{j=1}^{p} \Psi(X_{i-j}-\mu)(t) + \epsilon_i(t),

where Ψ(X)(t)=ψ(t,s)X(s)dt\Psi(X)(t) = \int \psi(t,s)X(s) dt is the kernel operator, and ϵi(t)\epsilon_i(t) are i.i.d. errors generated from a standard Brownian motion process. The mean function μ\mu is assumed to be zero in the generating process.

Value

A J×NJ \times N matrix where each column contains a curve evaluated at JJ grid points, generated from the FAR(p) model.

Examples

# Generate discrete evaluations of 200 curves, each observed at 50 grid points.
yd_far = dgp.far(J = 50, N = 200, S = 0.7, p = 2, kernel = "Gaussian", burn_in = 50)

Functional ARCH/GARCH Process Generator

Description

It generates functional curve data following the functional ARCH(1) or GARCH(1,1) process.

Usage

dgp.fgarch(J, N, type, alpha_par = NULL, beta_par = NULL)

Arguments

J

The number of grid point in each curve observation.

N

The sample size.

type

A string to switch data generating process between "arch" - functional ARCH and "garch" - functional GARCH.

alpha_par

The ARCH kernel coefficient function in the conditional volatility equation. If it is missing, "12t(1t)s(1s)12 t (1-t) s (1-s)" is used to generate FGARCH, and "16t(1t)s(1s)16 t (1-t) s (1-s)" is used to generate FARCH, for t[0,1]t\in[0,1] and s[0,1]s\in[0,1].

beta_par

The GARCH kernel coefficient function in the conditional volatility equation. If it is missing, "12t(1t)s(1s)12 t (1-t) s (1-s)" is used to generate FGARCH, for t[0,1]t\in[0,1] and s[0,1]s\in[0,1].

Details

If Xi(t)X_i(t) follows an FARCH(1) process,
Xi(t)=σi(t)εi(t)X_i(t)=\sigma_i(t)\varepsilon_i(t), t[0,1]t \in [0,1],
σi2(t)=ω(t)+α(t,s)Xi12(s)ds\sigma_i^2(t)=\omega(t)+\int \alpha(t,s) X^2_{i-1}(s)ds.

If Xi(t)X_i(t) follows an FGARCH(1,1) process,
Xi(t)=σi(t)εi(t)X_i(t)=\sigma_i(t)\varepsilon_i(t), t[0,1]t \in [0,1],
σi2(t)=ω(t)+α(t,s)Xi12(s)ds+β(t,s)σi12(s)ds\sigma_i^2(t)=\omega(t)+\int \alpha(t,s) X^2_{i-1}(s)ds+\int \beta(t,s) \sigma^2_{i-1}(s)ds,
where the innovation εi(t)\varepsilon_i(t) follows an Ornstein–Uhlenbeck process dgp.ou, and the constant coefficient ω(t)=0.1t(1t)\omega(t)=0.1t(1-t).

Value

List of generated processes:

garch_mat: FARCH/GARCH sequences, where the finite realization of curves are stored in columns;

sigma_mat: Conditional volatility sequences, where the finite realization of curves are stored in columns.

References

[1] Hormann, S., Horvath, L., Reeder, R. (2013). A functional version of the ARCH model. Econometric Theory. 29(2), 267-288. <doi:10.1017/S0266466612000345>.
[2] Aue, A., Horvath, L., F. Pellatt, D. (2017). Functional generalized autoregressive conditional heteroskedasticity. Journal of Time Series Analysis. 38(1), 3-21. <doi:10.1111/jtsa.12192>.

See Also

dgp.ou

Examples

# Generate discrete evaluations of 100 fGARCH curves that
# each curve is realized on 50 grid points.
yd = dgp.fgarch(J = 50, N = 100, type = "garch")
yd_garch = yd$garch_mat

Ornstein–Uhlenbeck Process Generator

Description

It generates iid functional curve data following the Ornstein–Uhlenbeck process.

Usage

dgp.ou(J, N)

Arguments

J

The number of grid points in each curve observation.

N

The sample size.

Details

The Ornstein–Uhlenbeck process is given by: xi(t)=et/2Wi(et)x_i(t)=e^{-t/2}W_i(e^t), t[0,1]t \in [0,1],
where Wi(t)W_i(t) is a standard Brownian Motion.

Value

A (grid points) x (number of observations) matrix for iid sequences, where the finite realization of curves are stored in columns.

Examples

# Generate discrete evaluations of 100 iid curves
# that each curve is realized on 50 grid points.
yd_ou = dgp.ou(J = 50, N = 100)

Daily Eurodollar Futures Curves

Description

This dataset contains daily Eurodollar futures curves from February 9, 1998 to June 5, 1998 (N=82N=82). A Eurodollar futures contract represents an obligation to deliver 1,000,000 USD to a bank outside the United States at a specified time. The Eurodollar futures curves consist of daily settlement prices for these contracts, available at monthly delivery dates for the first six months and quarterly delivery dates up to 10 years into the future. These curves are preprocessed using cubic splines, following Kargin and Onatski (2008), to transform the raw data into smooth curves on a grid of 114 equally spaced points (J=114J=114).

Usage

data(EF)

Format

A matrix with columns representing the daily settlement prices as observed functions.

References

Kargin V, Onatski A (2008). Curve forecasting by functional autoregression. Journal of Multivariate Analysis, 99, 2508–2526.


Functional Autocorrelation Function (fACF) Plot

Description

This function provides a graphical summary of the fACF of a functional time series (FTS) across different time lags h=1:Hh = 1:H. It also plots the 100(1α)%100 (1-\alpha)\% confidence bounds, developed under both weak white noise (WWN) and strong white noise (SWN) assumptions for all lags h=1:Hh = 1:H.

Usage

fACF(f_data, H = 20, alpha = 0.05, wwn_bound = FALSE, M = NULL)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer value. The maximum lag for which to compute the coefficients and confidence bounds.

alpha

A numeric value between 0 and 1 specifying the significance level to be used for the confidence bounds.

wwn_bound

A Boolean value allowing the user to turn on the WWN bound. FALSE by default. Speeds down computation when TRUE.

M

A positive integer value. The number of Monte-Carlo simulations used to compute the confidence bounds under the WWN assumption. If M=NULL,M=floor((max(150N,0)+max(100J,0)+(J/2)))M = NULL, M = \text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring that the number of Monte Carlo simulations is adequate based on the dataset size.

Details

This function computes and plots functional autocorrelation coefficients at lag hh, for h1:Hh \in 1:H. Given functional observations, X1,,XNX_1,\ldots, X_N, the sample autocovariance kernel at lag hh can be computed by

γ^N,h(t,s)=1Ni=1Nh(Xi(t)XˉN(t))(Xi+h(s)XˉN(s)),    0h<N,\hat{\gamma}_{N,h}(t,s)=\frac{1}{N}\sum_{i=1}^{N-h} (X_i(t)-\bar{X}_N(t))(X_{i+h}(s)-\bar{X}_N(s)),\ \ \ \ 0 \le h < N,

where XˉN(t)=1Ni=1NXi(t)\bar{X}_N(t) = \frac{1}{N} \sum_{i=1}^N X_i(t). Then, the fACF at lag hh is defined by measuring the magnitude (L2L^2-norm) of the lagged autocovariance kernel γ^N,h\hat\gamma_{N,h}:

ρ^h=γ^N,hγ^N,0(t,t)dt,    γ^N,h2=γ^N,h2(t,s)dtds.\hat\rho_h =\frac{\|\hat{\gamma}_{N,h}\|}{\int \hat{\gamma}_{N,0}(t,t)dt}, \ \ \ \ \|\hat{\gamma}_{N,h}\|^2=\iint \hat{\gamma}_{N,h}^2(t,s) dtds.

This function plots estimated asymptotic 100(1α)%100 (1-\alpha)\% confidence bounds under the WWN assumption. Additionally, it computes similar (constant) bounds under the SWN assumption.

Value

Plot of the estimated functional autocorrelation coefficients for lags h1:Hh \in 1:H with the WWN 100(1α)%100 (1-\alpha)\% upper confidence bound for each lag, as well as the constant SWN 100(1α)%100 (1-\alpha)\% upper confidence bound.

References

[1] Kokoszka P., Rice G., Shang H.L. (2017). Inference for the autocovariance of a functional time series under conditional heteroscedasticity. Journal of Multivariate Analysis, 162, 32-50.

[2] Mestre G., Portela J., Rice G., Roque A. M. S., Alonso E. (2021). Functional time series model identification and diagnosis by means of auto-and partial autocorrelation analysis. Computational Statistics & Data Analysis, 155, 107108.

Examples

data(Spanish_elec) # Daily Spanish electricity price profiles
fACF(Spanish_elec)
fACF(Spanish_elec, H=10, wwn_bound=TRUE)

Test based on fACF

Description

This function performs a hypothesis test using a test statistic computed from functional autocovariance kernels of a FTS.

Usage

fACF_test(
  f_data,
  H = 10,
  iid = FALSE,
  M = NULL,
  pplot = FALSE,
  alpha = 0.05,
  suppress_raw_output = FALSE,
  suppress_print_output = FALSE
)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer specifying the maximum lag for which test statistic is computed.

iid

A Boolean value. If given TRUE, the hypothesis test will use the strong-white noise (SWN) assumption instead of the weak white noise (WWN) assumption.

M

A positive integer specifying the number of Monte Carlo simulations used to approximate the null distribution under the WWN assumption. If M=NULL,M=floor((max(150N,0)+max(100J,0)+(J/2)))M = NULL, M = \text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring that the number of Monte Carlo simulations is adequate based on the dataset size.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

alpha

A numeric value between 0 and 1 indicating the significance level for the test.

suppress_raw_output

A Boolean value. If TRUE, the function will not return the list containing the p-value, quantile, and statistic.

suppress_print_output

A Boolean value. If TRUE, the function will not print any output to the console.

Details

The test statistic is the sum of the squared L2L^2-norm of the sample autocovariance kernels:

KRSN,H=Nh=1Hγ^N,h2,KRS_{N,H} = N \sum_{h=1}^H \|\hat{\gamma}_{N,h}\|^2,

where γ^N,h(t,s)=N1i=1Nh(Xi(t)XˉN(t))(Xi+h(s)XˉN(s))\hat{\gamma}_{N,h}(t,s)=N^{-1}\sum_{i=1}^{N-h} (X_i(t)-\bar{X}_N(t))(X_{i+h}(s)-\bar{X}_N(s)), XˉN(t)=N1i=1NXi(t)\bar{X}_N(t) = N^{-1} \sum_{i=1}^N X_i(t). This test assesses the cumulative significance of lagged autocovariance kernels, up to a user-selected maximum lag HH. A higher value of KRSN,HKRS_{N,H} suggests a potential departure of the observed series from white noise process. The approximated null distribution of this statistic is developed under both the strong and weak white noise assumptions.

Value

If suppress_raw_output = FALSE, a list that includes the test statistic, the (1α)(1-\alpha) quantile of the limiting distribution, and the p-value from the specified hypothesis test. Additionally, if suppress_print_output = FALSE, a summary is printed with a brief explanation of the test, the p-value, and relevant details about the test procedure.

References

[1] Kokoszka P., Rice G., Shang H.L. (2017). Inference for the autocovariance of a functional time series under conditional heteroscedasticity. Journal of Multivariate Analysis, 162, 32-50.

Examples

data(sp500) # S&P500 index
fACF_test(OCIDR(sp500), H = 10, pplot=TRUE)

Test for Conditional Heteroscedasticity of Functional Time Series

Description

It tests the null hypothesis that the objective functional curve data is not conditionally heteroscedastic. If a small p-value rejects the null hypothesis, the curves exhibit conditional heteroscedasticity.

Usage

fCH_test(f_data, H = 10, stat_Method = "functional", pplot = FALSE)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer specifying the maximum lag for which test statistic is computed.

stat_Method

A string specifying the test method to be used in the "ch" test. Options include:

"norm"

Uses VN,HV_{N,H}.

"functional"

Uses MN,HM_{N,H}.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

Details

Given the objective curve data Xi(t)X_i(t), for 1iN1\leq i \leq N, t[0,1]t\in[0,1], the test aims at distinguishing the hypotheses:

H0H_0: the sequence Xi(t)X_i(t) is IID;
H1H_1: the sequence Xi(t)X_i(t) is conditionally heteroscedastic.

Two portmanteau type statistics are applied:

1. the norm-based statistic: VN,H=Nh=1Hγ^X22(h)V_{N,H}=N\sum_{h=1}^H\hat{\gamma}^2_{X^2}(h), where γ^X22(h)\hat{\gamma}^2_{X^2}(h) is the sample autocorrelation of the time series X12,,XN2||X_1||^2,\dots,||X_N||^2, and HH is a pre-set maximum lag length.

2. the fully functional statistic MN,H=Nh=1Hγ^X2,N,h2M_{N,H}=N\sum_{h=1}^H||\hat{\gamma}_{X^2,N,h}||^2, where the autocovariance kernel γ^X2,N,h(t,s)=N1i=1Nh[Xi2(t)Xˉ2(t)][Xi+h2(s)Xˉ(s)]\hat{\gamma}_{X^2,N,h}(t,s)=N^{-1}\sum_{i=1}^{N-h}[X_i^2(t)-\bar{X}^2(t)][X^2_{i+h}(s)-\bar{X}(s)], for ||\cdot || is the L2L^2 norm, and Xˉ2(t)=N1i=1NXi2(t)\bar{X}^2(t)=N^{-1}\sum_{i=1}^N X^2_i(t).

Value

A list that includes the test statistic and the p-value will be returned.

References

Rice, G., Wirjanto, T., Zhao, Y. (2020). Tests for conditional heteroscedasticity of functional data. Journal of Time Series Analysis. 41(6), 733-758. <doi:10.1111/jtsa.12532>.

Examples

# generate discrete evaluations of the iid curves under the null hypothesis.
yd_ou = dgp.ou(50, 100)

# test the conditional heteroscedasticity.
fCH_test(yd_ou, H=5, stat_Method="functional")

Exploratory Data Analysis for Functional Time Series.

Description

This function sequentially displays the fACF plot, the fSACF and the rainbow plot of a functional time series (FTS) for comprehensive exploratory data analysis.

Usage

fport_eda(f_data, H = 20, alpha = 0.05, wwn_bound = FALSE, M = NULL)

Arguments

f_data

A J×NJ \times N matrix of FTS data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer representing the maximum lag for computing the coefficients and confidence bounds. This value determines the range of lags included in the fACF and fSACF plots.

alpha

A numeric value between 0 and 1 indicating the significance level for the confidence bounds in the fACF and fSACF plots.

wwn_bound

A Boolean value allowing the user to turn on the WWN bound in the fACF plot. FALSE by default. Speeds down computation when TRUE.

M

A positive integer value. The number of Monte-Carlo simulations used to compute the confidence bounds under the WWN assumption. If M=NULL,M=floor((max(150N,0)+max(100J,0)+(J/2)))M = NULL, M = \text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring that the number of Monte Carlo simulations is adequate based on the dataset size.

Details

This function sequentially displays the rainbow plot, the fACF plot, and the fSACF of an FTS for comprehensive exploratory data analysis. See the help page of rainbow3D, fACF, fSACF, for more details.

Value

A 3D rainbow plot, a fACF plot for lags h1:Hh \in 1:H with the WWN (1α)100%(1-\alpha)100 \% upper confidence bound and the constant strong white noise (SWN) (1α)100%(1-\alpha)100 \% upper confidence bound, and a fSACF plot for lags h1:Hh \in 1:H with the SWN (1α)100%(1-\alpha)100 \% upper and lower confidence bounds.

References

[1] Kokoszka P., Rice G., Shang H.L. (2017). Inference for the autocovariance of a functional time series under conditional heteroscedasticity. Journal of Multivariate Analysis, 162, 32-50.

[2] Mestre G., Portela J., Rice G., Roque A. M. S., Alonso E. (2021). Functional time series model identification and diagnosis by means of auto-and partial autocorrelation analysis. Computational Statistics & Data Analysis, 155, 107108.

[3] Yeh CK, Rice G, Dubin JA (2023). “Functional spherical autocorrelation: A robust estimate of the autocorrelation of a functional time series.” Electronic Journal of Statistics, 17, 650–687.

Examples

data(Spanish_elec) # Daily Spanish electricity price profiles
fport_eda(Spanish_elec)

Goodness-of-fit Tests for Functional Times Series

Description

It computes three different goodness-of-fit tests for functional time series. All goodness-of-fit tests in this package are accessible through this function.

Usage

fport_gof(
  f_data,
  test = "far",
  H = 10,
  M = NULL,
  pplot = FALSE,
  residual = FALSE
)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

test

A string specifying the goodness-of-fit test. Currently available tests are referred to by their string handles: "far", "arch" and "garch". Please see the Details section of the documentation.

H

A positive integer specifying the maximum lag for which test statistics are computed.

M

A positive integer specifying the number of Monte Carlo simulations used to approximate the null distribution in the "far" test, and the number of basis functions used in the "arch" and "garch" tests. If M=NULLM = NULL, then for the "far" test, MM is calculated as floor((max(150N,0)+max(100J,0)+(J/2)))\text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring the number of Monte Carlo simulations is adequate based on the dataset size. For the "arch" or "garch" test, MM is set to 1.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

residual

A data frame. If TRUE, the function will provide the residuals obtained from fitting the FAR(1) model.

Details

This function conducts goodness-of-fit tests for functional time series data, providing several testing options:

1. When test = "far", it tests the goodness-of-fit of the FAR(1) model. The function fits the FAR(1) model to the input data and then applies the test statistic KRSN,HKRS_{N,H}, as described in fport_wn, to the residuals. The null distribution of the test statistic accounts for the dependence structure present in the residuals. The optional parameters for this test are 'fdata', 'test', 'H', 'M', 'pplot' and 'residual'.

2. When test = "arch" or "garch", it tests the goodness-of-fit of the fARCH(1) or fGARCH(1,1) models. It fits the model to the input data and applies the test MN,HM_{N,H} in fport_wn to the model residuals. The asymptotic distribution is adjusted to account for the estimation effect, because the model residual depends on the joint asymptotics of the innovation process and the estimated parameters. We assume that the kernel parameters are consistently estimated by the Least Squares method proposed in Aue et al. (2017). Then, the asymptotic distribution of the statistic MN,HM_{N,H} is given in Theorem 3.1 in Rice et al. (2020). The optional parameters for this test are 'fdata', 'test', 'H', 'M', and 'pplot'.

Value

A summary is printed with a brief explanation of the test and the p-value.

References

[1] Kim, M., Kokoszka, P., & Rice, G. (2023). White noise testing for functional time series. Statistic Surveys, 17, 119-168.

[2] Aue, A., Horvath, L., F. Pellatt, D. (2017). Functional generalized autoregressive conditional heteroskedasticity. Journal of Time Series Analysis. 38(1), 3-21. <doi:10.1111/jtsa.12192>.

[3] Rice, G., Wirjanto, T., Zhao, Y. (2020). Tests for conditional heteroscedasticity of functional data. Journal of Time Series Analysis. 41(6), 733-758. <doi:10.1111/jtsa.12532>.

Examples

data(Spanish_elec)
fport_gof(Spanish_elec, test = "far", H = 20, pplot=TRUE)

data(sp500)
fport_gof(OCIDR(sp500), test = "arch", M = 1, H = 5)
fport_gof(OCIDR(sp500), test = "garch", M = 1, H = 10)

White Noise Hypothesis Tests for Functional Times Series

Description

It computes a variety of white noise tests for functional times series (FTS) data. All white noise tests in this package are accessible through this function.

Usage

fport_wn(
  f_data,
  test = "autocovariance",
  H = 10,
  iid = FALSE,
  M = NULL,
  stat_Method = "functional",
  pplot = FALSE
)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

test

A string specifying the hypothesis test. Currently available tests are referred to by their string handles: "autocovariance", "spherical" and "ch". Please see the Details section of the documentation.

H

A positive integer specifying the maximum lag for which test statistics are computed.

iid

A Boolean value used in the "autocovariance" test. If given TRUE, the hypothesis test will use the strong-white noise (SWN) assumption instead of the weak white noise (WWN) assumption.

M

A positive integer specifying the number of Monte Carlo simulations used to approximate the null distribution in the "autocovariance" test under the WWN assumption. If M=NULL,M=floor((max(150N,0)+max(100J,0)+(J/2)))M = NULL, M = \text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring that the number of Monte Carlo simulations is adequate based on the dataset size.

stat_Method

A string specifying the test method to be used in the "ch" test. Options include:

"norm"

Uses VN,HV_{N,H}.

"functional"

Uses MN,HM_{N,H}.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

Details

This function performs white noise hypothesis testing for functional time series (FTS) data. It offers several types of tests:

1. Test based on fACF (test = "autocovariance"): This test evaluates the sum of the squared L2L^2-norm of the sample autocovariance kernels:

KRSN,H=Nh=1Hγ^N,h2,KRS_{N,H} = N \sum_{h=1}^H \|\hat{\gamma}_{N,h}\|^2,

where γ^N,h(t,s)=1Ni=1Nh(Xi(t)XˉN(t))(Xi+h(s)XˉN(s))\hat{\gamma}_{N,h}(t,s)=\frac{1}{N}\sum_{i=1}^{N-h} (X_i(t)-\bar{X}_N(t))(X_{i+h}(s)-\bar{X}_N(s)), XˉN(t)=1Ni=1NXi(t)\bar{X}_N(t) = \frac{1}{N} \sum_{i=1}^N X_i(t) It assesses the cumulative significance of lagged autocovariance kernels up to a user-specified maximum lag HH. A higher value of KRSN,HKRS_{N,H} suggests a potential departure from a white noise process. The null distribution is approximated under both strong and weak white noise assumptions. Optional parameters include 'f_data', 'test', 'H', 'iid', 'M', and 'pplot'.

2. Test based on fSACF (test = "spherical"): This test evaluates the sum of the squared L2L^2-norm of the sample spherical autocorrelation coefficients:

SN,H=Nh=1Hρ~h2,S_{N,H} = N \sum_{h=1}^H \|\tilde{\rho}_{h}\|^2,

where ρ~h=1Ni=1NhXiμ~Xiμ~,Xi+hμ~Xi+hμ~\tilde\rho_h=\frac{1}{N}\sum_{i=1}^{N-h} \langle \frac{X_i - \tilde{\mu}}{\|X_i - \tilde{\mu}\|}, \frac{X_{i+h} - \tilde{\mu}}{\|X_{i+h} - \tilde{\mu}\|} \rangle, and μ~\tilde{\mu} is the estimated spatial median of the series. It assesses the cumulative significance of lagged spherical autocorrelation coefficients up to a user-specified maximum lag HH. A higher value of SN,HS_{N,H} suggests a potential departure from a white noise process. The null distribution is approximated under strong white noise assumptions. Optional parameters include 'f_data', 'test', 'H', and 'pplot'.

3. Test for Conditional Heteroscedasticity (test = "ch"): This test investigates whether the functional time series exhibits conditional heteroscedasticity. Two portmanteau-type statistics are used:

  • Norm-based statistic: VN,H=Nh=1Hγ^X22(h)V_{N,H} = N \sum_{h=1}^H \hat{\gamma}^2_{X^2}(h), where γ^X22(h)\hat{\gamma}^2_{X^2}(h) is the sample autocorrelation of the time series X12,,XN2||X_1||^2, \dots, ||X_N||^2, with HH as the maximum lag length.

  • Fully functional statistic: MN,H=Nh=1Hγ^X2,N,h2M_{N,H} = N \sum_{h=1}^H \|\hat{\gamma}_{X^2,N,h}\|^2, where γ^X2,N,h(t,s)=1Ni=1Nh[Xi2(t)Xˉ2(t)][Xi+h2(s)Xˉ(s)]\hat{\gamma}_{X^2,N,h}(t,s) = \frac{1}{N} \sum_{i=1}^{N-h} [X_i^2(t) - \bar{X}^2(t)][X^2_{i+h}(s) - \bar{X}(s)], with \|\cdot\| representing the L2L^2 norm and Xˉ2(t)=1Ni=1NXi2(t)\bar{X}^2(t) = \frac{1}{N} \sum_{i=1}^N X_i^2(t).

Optional parameters for this test include 'f_data', 'test', 'H', 'stat_Method', and 'pplot'.

Value

A summary is printed with a brief explanation of the test and the p-value.

References

[1] Kokoszka P., Rice G., Shang H.L. (2017). Inference for the autocovariance of a functional time series under conditional heteroscedasticity. Journal of Multivariate Analysis, 162, 32-50.

[2] Yeh CK, Rice G, Dubin JA (2023). “Functional spherical autocorrelation: A robust estimate of the autocorrelation of a functional time series.” Electronic Journal of Statistics, 17, 650–687.

[3] Rice, G., Wirjanto, T., Zhao, Y. (2020). Tests for conditional heteroscedasticity of functional data. Journal of Time Series Analysis. 41(6), 733-758. <doi:10.1111/jtsa.12532>.

Examples

data(Spanish_elec)
fport_wn(Spanish_elec, test = "autocovariance", pplot = TRUE)
fport_wn(Spanish_elec, test = "spherical", H = 15, pplot = TRUE)

# generate fARCH(1)
yd_arch <- dgp.fgarch(J = 50, N = 200, type = "arch")$garch_mat
fport_wn(yd_arch, test = "ch", H = 20, stat_Method = "norm", pplot = TRUE)
fport_wn(yd_arch, test = "ch", H = 20, stat_Method = "functional", pplot = TRUE)

Functional Spherical Autocorrelation Function (fSACF) Plot

Description

This function offers a graphical summary of the fSACF of a functional time series (FTS) across different time lags h=1:Hh = 1:H. It also plots 100×(1α)%100 \times (1-\alpha)\% confidence bounds developed under strong white noise (SWN) assumption for all lags h=1:Hh = 1:H.

Usage

fSACF(f_data, H = 20, alpha = 0.05)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer value. The maximum lag for which to compute the coefficients and confidence bounds.

alpha

A numeric value between 0 and 1 specifying the significance level to be used for the confidence bounds.

Details

This function computes and plots functional spherical autocorrelation coefficients at lag hh, for h=1:Hh = 1:H. The fSACF at lag hh is computed by the average of the inner product of lagged pairs of the series XiX_i and Xi+hX_{i+h} that have been centered and scaled:

ρ~h=1Ni=1NhXiμ~Xiμ~,Xi+hμ~Xi+hμ~,    0h<N,\tilde\rho_h=\frac{1}{N}\sum_{i=1}^{N-h} \langle \frac{X_i - \tilde{\mu}}{\|X_i - \tilde{\mu}\|}, \frac{X_{i+h} - \tilde{\mu}}{\|X_{i+h} - \tilde{\mu}\|} \rangle,\ \ \ \ 0 \le h < N,

where μ~\tilde{\mu} is the estimated spatial median of the series. It also computes estimated asymptotic (1α)100%(1-\alpha)100 \% confidence lower and upper bounds, under the SWN assumption.

Value

Plot of the estimated autocorrelation coefficients for lags hh in 1:H1:H with the SWN (1α)100%(1-\alpha)100 \% upper and lower confidence bounds for each lag.

References

[1] Yeh C.K., Rice G., Dubin J.A. (2023). Functional spherical autocorrelation: A robust estimate of the autocorrelation of a functional time series. Electronic Journal of Statistics, 17, 650–687.

Examples

data(Spanish_elec) # Daily Spanish electricity price profiles
fSACF(Spanish_elec)

Test based on fSACF

Description

This function performs a hypothesis test using a test statistic computed from functional spherical autocorrelation coefficients of a FTS.

Usage

fSACF_test(
  f_data,
  H = 10,
  alpha = 0.05,
  pplot = FALSE,
  suppress_raw_output = FALSE,
  suppress_print_output = FALSE
)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ represents the number of discrete points in a grid and NN represents the sample size.

H

A positive integer specifying the maximum lag for which test statistic is computed.

alpha

A numeric value between 0 and 1 indicating the significance level for the test.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

suppress_raw_output

A Boolean value. If TRUE, the function will not return the list containing the p-value, quantile, and statistic.

suppress_print_output

A Boolean value. If TRUE, the function will not print any output to the console.

Details

The test statistic is the sum of the squared L2L^2-norm of the sample spherical autocorrelation coefficients:

SN,H=Nh=1Hρ~h2,S_{N,H} = N \sum_{h=1}^H \|\tilde{\rho}_{h}\|^2,

where ρ~h=1Ni=1NhXiμ~Xiμ~,Xi+hμ~Xi+hμ~\tilde\rho_h=\frac{1}{N}\sum_{i=1}^{N-h} \langle \frac{X_i - \tilde{\mu}}{\|X_i - \tilde{\mu}\|}, \frac{X_{i+h} - \tilde{\mu}}{\|X_{i+h} - \tilde{\mu}\|} \rangle, and μ~\tilde{\mu} is the estimated spatial median of the series. This test assesses the cumulative significance of lagged spherical autocorrelation coefficients, up to a user-selected maximum lag HH. A higher value of SN,HS_{N,H} suggests a potential departure of the observed series from white noise process. The approximated null distribution of this statistic is developed under the strong white noise assumptions.

Value

If suppress_raw_output = FALSE, a list containing the test statistic, the (1α)(1-\alpha) quantile of the limiting distribution, and the p-value computed from the specified hypothesis test. Also prints output containing a short description of the test, the p-value, and additional information about the test if suppress_print_output = FALSE.

References

[1] Yeh CK, Rice G, Dubin JA (2023). “Functional spherical autocorrelation: A robust estimate of the autocorrelation of a functional time series.” Electronic Journal of Statistics, 17, 650–687.

Examples

data(Spanish_elec)
fACF_test(Spanish_elec, H = 20)

Goodness-of-fit test for FAR(1)

Description

It fits a FAR(1) model and then assesses the cumulative significance of lagged autocovariance operators from the model residuals, up to a user-selected maximum lag HH.

Usage

gof_far(
  f_data,
  H = 10,
  M = NULL,
  alpha = 0.05,
  pplot = FALSE,
  residual = FALSE,
  suppress_raw_output = FALSE,
  suppress_print_output = FALSE
)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

H

A positive integer specifying the maximum lag for which test statistics are computed.

M

A positive integer specifying the number of Monte Carlo simulations used to approximate the null distribution. If M=NULL,M=floor((max(150N,0)+max(100J,0)+(J/2)))M = NULL, M = \text{floor}((\max(150 - N, 0) + \max(100 - J, 0) + (J / \sqrt{2}))), ensuring that the number of Monte Carlo simulations is adequate based on the dataset size.

alpha

A numeric value between 0 and 1 specifying the significance level.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

residual

A data frame. If TRUE, the function will provide the residuals obtained from fitting the FAR(1) model.

suppress_raw_output

A Boolean value, FALSE by default. If TRUE, the function will not return the list containing the p-value, quantile, and statistic.

suppress_print_output

A Boolean value, FALSE by default. If TRUE, the function will not print any output to the console.

Value

If suppress_raw_output = FALSE, a list containing the test statistic, the (1α)(1-\alpha) quantile of the limiting distribution, and the p-value computed from the specified hypothesis test. Also prints output containing a short description of the test, the p-value, and additional information about the test if suppress_print_output = FALSE.

References

[1] Kim, M., Kokoszka, P., & Rice, G. (2023). White noise testing for functional time series. Statistic Surveys, 17, 119-168.

Examples

yd_far <- dgp.far(J=50, N=100, S=0.7, p=2, kernel = "Gaussian", burn_in = 50)
gof_far(yd_far, H=5, pplot=TRUE)

Goodness-of-fit Test for Functional ARCH/GARCH Model

Description

It tests the goodness-of-fit of functional ARCH/GARCH models by accounting for the effect of functional GARCH parameter estimation.

Usage

gof_fGARCH(f_data, M, model, H = 10, pplot = NULL, max_eval = 10000)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

M

A positive integer specifying the number of basis functions.

model

A string to indicate which model will be estimated: "arch" - FARCH(1); "garch" - FGARCH(1,1).

H

A positive integer specifying the maximum lag for which test statistics are computed.

pplot

A Boolean value. If TRUE, the function will produce a plot of p-values of the test as a function of maximum lag HH, ranging from H=1H=1 to H=20H=20, which may increase the computation time.

max_eval

The maximum number of evaluations of the optimization function, used in the "arch" and "garch" tests.

Details

It tests the goodness-of-fit of the fARCH(1) or fGARCH(1,1) models. It fits the model to the input data and applies the test MN,HM_{N,H} in fport_wn to the model residuals. The asymptotic distribution is adjusted to account for the estimation effect, because the model residual depends on the joint asymptotics of the innovation process and the estimated parameters. We assume that the kernel parameters are consistently estimated by the Least Squares method proposed in Aue et al. (2017). Then, the asymptotic distribution of the statistic MN,HM_{N,H} is given in Theorem 3.1 in Rice et al. (2020).

Value

p-value.

References

[1] Aue, A., Horvath, L., F. Pellatt, D. (2017). Functional generalized autoregressive conditional heteroskedasticity. Journal of Time Series Analysis. 38(1), 3-21. <doi:10.1111/jtsa.12192>.

[2] Rice, G., Wirjanto, T., Zhao, Y. (2020). Tests for conditional heteroscedasticity of functional data. Journal of Time Series Analysis. 41(6), 733-758. <doi:10.1111/jtsa.12532>.

Examples

# generate discrete evaluations of the FGARCH process.
set.seed(42)
yd = dgp.fgarch(J=50, N=200, type = "garch")$garch_mat

# test the adequacy of the FARCH(1) model.
gof_fGARCH(yd, M=2, model = "arch", H=10, pplot=TRUE)

Convert Original Price Data to OCIDRs

Description

This function converts original price data into over-night cumulative intraday return curves (OCIDRs).

Usage

OCIDR(f_data)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in a grid and NN is the sample size.

Value

A matrix of OCIDRs with dimensions J×(N1)J \times (N-1), where JJ is the number of discrete grid points and N1N-1 is the adjusted sample size.

Examples

data(sp500)
OCIDR(sp500)

3D Rainbow Plot for Functional Time Series

Description

This function creates a 3D rainbow plot of a functional time series (FTS) using the rgl package. The data is color-coded using a rainbow color scheme, with earlier curves in red and later curves in violet. A 360-degree interactive view is available through an embedded widget.

Usage

rainbow3D(f_data)

Arguments

f_data

A J×NJ \times N matrix of functional time series data, where JJ is the number of discrete points in the grid and NN is the sample size.

Value

A 3D rainbow plot of the functional time series data.

Examples

data(Spanish_elec) # Daily Spanish electricity price profiles
rainbow3D(Spanish_elec)

data(sp500) # S&P500 index data
rainbow3D(OCIDR(sp500))

S&P 500 Index Price Data

Description

This dataset contains S&P 500 index prices, given in percentages, for all full trading days between January 3, 2017 and January 2, 2018, observed at a 1-minute frequency (390 grid points per day).

Usage

data(sp500)

Format

A matrix with rows representing minute-by-minute time points and columns representing intraday prices.

Source

https://finance.yahoo.com/


Spanish electricity daily price profiles

Description

This dataset contains daily electricity price profiles from the Day-Ahead Spanish Electricity Market. The original data consists of hourly electricity spot prices, which have been transformed into daily functional profiles. The dataset covers the period from January 1, 2014, to December 31, 2014.

Usage

data(Spanish_elec)

Format

A matrix with rows representing hourly time points and columns representing the daily price profiles as observed functions.

Source

fdaACF, https://www.esios.ree.es/es/analisis/600