The Rfssa R package implementation of the functional singular spectrum analysis (FSSA) algorithm begins with the computer representation of functional time series (FTS) which may be univariate or multivariate. Furthermore, the variables of the FTS may be observed over one or two-dimensional domains allowing for analysis of functional curves or images or both jointly. We refer the reader to Haghbin et al. (2021) for information on FTS and the FSSA algorithm, we refer to Trinka, Haghbin, and Maadooliat (2022) for information on multivariate FTS and multivariate FSSA, and we refer to Trinka et al. ({in press}) for more information on the univariate FSSA-based forecasting techniques.
We use an S3 object of class funts to implement the computer representation and we note that the constructor of such objects leverages a variety of techniques that may be used to define a funts object. We also offer custom validity checking to help guide the user through the different methods used to create funts objects. We illustrate the use of the constructor by way of call center data from a bank and satellite images of vegetation near the Saint Mary, Montana coupled with intraday temperature curves observed from a weather station near the same location. The data is hosted on GitHub which can be accessed using the Rfssa R package.
## Load packages ##
require(Rfssa)
require(fda)
The call center data is a collection of 365 functions (curves) observed between January 1, 1999 and December 31, 1999 where the domain of each function is intraday time between 12:00 AM and 11:59 PM and the range of each function is the square root of the number of calls to a call center. The data is observed in a 240 by 365 matrix where the first dimension captures the number of sampling points for each function and the second dimension captures the length of the FTS. The following code preprocesses the data and constructs the funts object.
## Call center data ##
loadCallcenterData()
D <- matrix(sqrt(callcenter$calls), nrow = 240)
bs1 <- create.bspline.basis(c(0, 23), 22)
u <- seq(0, 23, len = nrow(D))
Y <- funts(X = D, basisobj = bs1, start = as.Date("1999-1-1"),
vnames = "Sqrt of Call Numbers",
dnames = "Time (6 minutes aggregated)",
tname = "Date" )
print(Y)
##
## Functional time series (funts) object:
## Number of variables: 1
## Lenght: 365
## Start: 10592
## End: 10956
## Time: Date[1:365], format: "1999-01-01" "1999-01-02" "1999-01-03" "1999-01-04" "1999-01-05" ...
Now that the funts object has been defined, we may visualize the FTS using the corresponding plotting functions. The plotly_funts plotting function is a wrapper of plotly codes which has been specially designed for FTS data. The following code shows various plots of the call center funts object.
## Line plot ##
plotly_funts(Y,
main = "Callcenter Data",
xlab = "Time (6 minutes aggregated)",
ylab = "Sqrt of Call Numbers", type = "line",xticklabels = list(c("00:00","06:00","12:00","18:00","24:00")),xticklocs =
list(c(1,60,120,180,240))
)
## Heatmap plot ##
plotly_funts(Y,
main = "Callcenter Data",
xlab = "Time (6 minutes aggregated)",
ylab = "Sqrt of Call Numbers", type = "heatmap",,xticklabels = list(c("00:00","06:00","12:00","18:00","24:00")),xticklocs =
list(c(1,60,120,180,240))
)
## 3Dsurface plot ##
plotly_funts(Y,
main = "Callcenter Data",
xlab = "Time Point",
ylab = "Sqrt of Call Numbers", type = "3Dsurface"
)
## 3Dline plot ##
plotly_funts(Y,
main = "Callcenter Data",
xlab = "Time Point",
ylab = "Sqrt of Call Numbers", type = "3Dline"
)