# FTSgof

This vignette provides an overview of how to perform exploratory data analysis, white noise hypothesis testing and the goodness-of-fit tests for functional time series (FTS) data using the functions `fport_eda`, `fport_wn`, `fport_gof`. Functional time series data consists of a sequence of curves, allowing for the analysis of complex data structures over time.

First, ensure you have the package installed and loaded:

    library(FTSgof)

# Exploratory Data Analysis with `fport_eda’

The `fport_eda` function provides a comprehensive exploratory data analysis for functional time series data.

    # Load example data
    data(Spanish_elec)  # Daily Spanish electricity price profiles

    # Perform exploratory data analysis
    fport_eda(Spanish_elec, H = 20, alpha = 0.05, wwn_bound = FALSE, M = NULL)

    #> Hit <Return> to see next plot:

    #> Hit <Return> to see next plot:

# White Noise Hypothesis Testing with `fport_wn`

The `fport_wn` function computes various white noise tests for functional time series data. The available tests are “autocovariance”, “spherical”, and “arch”.

    # Perform white noise hypothesis testing
    fport_wn(Spanish_elec, test = "autocovariance", H = 10)
    #> Autocovariance Test
    #>
    #> Null hypothesis: the series is a weak white noise (sequentially uncorrelated).
    #> sample size = 365
    #> maximum lag H = 10
    #> p-value = 0.000000
    fport_wn(Spanish_elec, test = "spherical", H = 10, pplot = TRUE)

    #> Spherical Test
    #>
    #> Null hypothesis: the series is a strong white noise (iid).
    #> sample size = 365
    #> maximum lag H = 10
    #> p-value = 0.000000

    # Generate fGARCH(1) data for testing
    yd_garch <- dgp.fgarch(J = 50, N = 200, type = "garch")$garch_mat
    fport_wn(yd_garch, test = "ch", H = 10, stat_Method = "norm")
    #> Test for Conditional Heteroscedasticity
    #>
    #> Null hypothesis: the series is a strong white noise (iid).
    #> sample size = 200
    #> maximum lag H = 10
    #> test type = norm
    #> p-value = 0.000000

# Goodness-of-fit Tests with `fport_gof`

The `fport_gof` function conducts goodness-of-fit tests for functional time series data. The available tests are “far”, “arch”, and “garch”.

    # Perform goodness-of-fit tests
    fport_gof(Spanish_elec, test = "far", H = 10)
    #> Goodness-of-fit test for FAR(1)
    #>
    #> Null hypothesis: FAR(1) model is adequate for the series.
    #> sample size = 365
    #> maximum lag H = 10
    #> p-value = 0.000000

    # Example with SP500 data
    data(sp500)
    fport_gof(OCIDR(sp500), test = "arch", M = 1, H = 5)
    #> Warning in nloptr::cobyla(x0 = stav, fn = function_to_minimize2, lower =
    #> c(rep(10^-20, : The old behavior for hin >= 0 has been deprecated. Please
    #> restate the inequality to be <=0. The ability to use the old behavior will be
    #> removed in a future release.
    #> Goodness-of-fit test for fARCH(1)
    #>
    #> Null hypothesis: fARCH(1) model is adequate for the series.
    #> sample size = 251
    #> maximum lag H = 5
    #> p-value = 0.010181
    fport_gof(OCIDR(sp500), test = "garch", M = 1, H = 5)
    #> Warning in nloptr::cobyla(x0 = stav, fn = function_to_minimize2, lower =
    #> c(rep(10^-20, : The old behavior for hin >= 0 has been deprecated. Please
    #> restate the inequality to be <=0. The ability to use the old behavior will be
    #> removed in a future release.
    #> Goodness-of-fit test for fGARCH(1,1)
    #>
    #> Null hypothesis: fGARCH(1,1) model is adequate for the series.
    #> sample size = 251
    #> maximum lag H = 5
    #> p-value = 0.670733