We present a novel approach called Spatial Multivariate Functional Principal Component Analysis (SMFPCA), specifically designed for analyzing spatially multivariate data. This package focuses on reducing the dimensions of datasets with multiple variables. The data handled by this package are spatially indexed and exhibit weak stationarity. Unlike the traditional Multivariate Karhunen-Loève method, SMFPCA efficiently captures spatial relationships within multiple functions. By performing spectral functional component analysis on multivariate spatial data, SMFPCA analyzes data points distributed over a regular grid.
Install Rtools if not already installed. It can be downloaded from https://cran.r-project.org/bin/windows/Rtools/ The development version of MFSD can be installed as follows:
if (!require(devtools)) install.packages("devtools")
require(devtools)
if (!find_rtools()) stop("Please install Rtools first.")
install_github("kuenzer/fsd")converting each NOAA study variable into functional spatial data using the fsd.fd function. In our context, we opted for variables delineating the progression of sea surface temperature for the years 1999 and 2000. Following the application of the fsd.fd function, we acquired functional spatial variables designated as X1999 and X2000, respectively. The two functional spatial variables are available in the MFSD package, and can be loaded using the following R code:
library(MFSD)
#> Registered S3 methods overwritten by 'MFSD':
#> method from
#> %/%.fsd.fd fsd
#> *.fsd.fd fsd
#> +.fsd.fd fsd
#> -.fsd.fd fsd
#> /.fsd.fd fsd
#> [.fsd.fd fsd
#> as.fd.fsd.fd fsd
#> diff.fsd.fd fsd
#> mean.fsd.fd fsd
#> plot.fsd.fd fsd
data("X1999")
data("X2000")We load the ‘Lliste’ variables from the MFSD package, which include two variables indicating the maximum lag for the filters applied to X1999 and X2000. Additionally, we load ‘qlist’, which contains tuning parameters for estimating the spectral density of X1999 and X2000 variables.
data("qlist")
data("Llist")We structure the variables in the X, q and L lists, then we apply the mfsd() function with the SM_Npc parameter set to 4. Then we perform multivariate spatial FPCA on the years 1999 (X00[,,17]) and 2000 (X00[,,18]) :
X = list(X1999, X2000)
q = list(qlist[,17], qlist[,18])
L = list(L1 = Llist[17], L2 = Llist[18])
Xspecc <- mfsd(X = X, L = L, q = q, SM_Npc = 4)
#> Warning in fsd.spca.filters(F, Npc, L): The chosen clipping parameter L is low.
#> Summed squared norms for the PC filters are only 0.95, 0.87, 0.794, 0.758, 0.711, 0.718, 0.701, 0.697, 0.693, 0.695, 0.717, 0.735, 0.769, 0.779, 0.789
#> Warning in fsd.spca.filters(F, Npc, L): The chosen clipping parameter L is low.
#> Summed squared norms for the PC filters are only 0.915, 0.842, 0.769, 0.714, 0.686, 0.696, 0.642, 0.63, 0.634, 0.646, 0.656, 0.7, 0.728, 0.751, 0.851
Xspec <- mfsd(X = X, L = L, q = 0, SM_Npc = 4)The variable Xspec, with the q parameter set to zero, indicates that the mfsd function does not consider the spatial aspect, compared with the Xspecc variable.
To visualize the evolution of the four functional spatial filters of the variable Xspec, we use the function plot.fsd.filter.
fsd.plot.filters(Xspec[["filter"]][[1]], Npc = 4, Lmax = 2)fsd.plot.filters(Xspecc[["filter"]][[1]], Npc = 4, Lmax = 2)The following R code shows the evolution of the four fonctional spatial filters of the variable Xpecc.
fsd.plot.filters(Xspec[["filter"]][[2]], Npc = 4, Lmax = 2)fsd.plot.filters(Xspecc[["filter"]][[2]], Npc = 4, Lmax = 2)We assess the effectiveness of dimensionality reduction by computing the NMSE and NMSE* for univariate components with the function mfsd.evaluation.
X00 <- list(X1999, X2000)
result = mfsd.evaluation(Xspec, Xspecc, X00, Npc = 4 )
#> PC 1 PC 2 PC 3 PC 4
#> ADVANTAGE 0.06239868 0.1004192 0.1042668 0.09948148
#> NMSE_spat 0.35232024 0.2818504 0.2024973 0.16270440
#> NMSE_ord 0.41471892 0.3822696 0.3067641 0.26218589
#> NMSE_spat* 0.42540660 0.2739412 0.1889977 0.13191276
#> NMSE_ord* 0.47445535 0.3520799 0.2778462 0.21232158
#> PC 1 PC 2 PC 3 PC 4
#> ADVANTAGE 0.04920428 0.06739567 0.1614425 0.1065269
#> NMSE_spat 0.54606980 0.37840956 0.2655430 0.2047076
#> NMSE_ord 0.59527409 0.44580523 0.4269855 0.3112345
#> NMSE_spat* 0.43564017 0.25969140 0.1664391 0.1120781
#> NMSE_ord* 0.51567289 0.33421271 0.2695860 0.2086840The results are shown in Table 1.
result
#> NULLThe results shown also details of explained cumulative variance of FPCA after applying SMFPCA to TMP-1999 and TMP-2000.
Xspecc[["vm"]]
#> [1] 58.85594 71.06221 81.25402 87.34009 91.01089 93.46554 95.15372
#> [8] 96.23395 97.22491 97.93748 98.39807 98.71391 98.99927 99.20915
#> [15] 99.36222 99.49048 99.57933 99.66158 99.72081 99.77526 99.81341
#> [22] 99.84942 99.88515 99.91066 99.93498 99.95432 99.96818 99.98092
#> [29] 99.99196 100.00000
Xspec[["vm"]]
#> [1] 46.96172 57.30220 64.63431 69.02982 73.07528 76.99652 80.11821
#> [8] 82.65983 84.77960 86.60027 88.16848 89.60531 90.97761 92.16197
#> [15] 93.24352 94.23263 95.16237 95.89696 96.54831 97.14045 97.67191
#> [22] 98.14597 98.57784 98.88723 99.14165 99.37138 99.58083 99.76840
#> [29] 99.90769 100.00000


