r, arima, space-time, time series, package
The stcor
package provides functions for correlograms of the advanced time series model, the Space-Time Autoregressive Integrated Moving Average (STARIMA). These functions are the Space-Time Autocorrelation Function (stacf
) and Space-Time Partial Autocorrelation Function (stpacf
). Including function for centralizing (stcenter
) the data to its mean.
This package is not yet on CRAN, and still under development on github. Run the following to install the latest development:
if (!require("devtools"))
install.packages("devtools")
devtools::install_github("stcor", "alstat")
stacf
- estimates the autocorrelation function of the space-time series.
stacf(data, max.timelag = 15, wmatrices = list(NULL, ...), conf.level = 0.95)
list
function, where the first entry NULL designates the spatial lag 0, and (. . .) for higher order weights matrices. Note that, NULL should not be omitted, otherwise, the function will treat the first weights matrix as entries for spatial lag 0; and stpacf
- estimates the partial autocorrelation function of the space-time series.
stpacf(data, max.timelag = 15, wmatrices = list(NULL, ...), conf.level = 0.95)
stacf
function.stcenter
- centralizes the space-time data to its mean.
stcenter(data)
The package contains dataset named palay which is the volume of the rice production from the Cordillera Administrative Region (CAR) of the Philippines. Run ?palay
to get more details about the data. There are 6 regions in the dataset that can be assigned into the following weights matrices using the equal weighting of spatial order.
First spatial order weights matrix
W1 <- rbind(c(0, 1/2, 1/2, 0, 0, 0),
c(1/2, 0, 1/2, 0, 0, 0),
c(1/3, 1/3, 0, 1/3, 0, 0),
c(0, 0, 1/2, 0, 1/2, 0),
c(0, 0, 0, 1/2, 0, 1/2),
c(0, 0, 0, 1/2, 1/2, 0))
Second spatial order weights matrix
W2 <- rbind(c(0, 0, 0, 1, 0, 0),
c(0, 0, 0, 1, 0, 0),
c(0, 0, 0, 0, 1, 0),
c(0, 0, 0, 0, 0, 1),
c(0, 0, 1, 0, 0, 0),
c(0, 0, 1, 0, 0, 0))
Third spatial order weights matrix
W3 <- rbind(c(0, 0, 0, 0, 1, 0),
c(0, 0, 0, 0, 1/2, 1/2),
c(0, 0, 0, 0, 0, 1),
c(1, 0, 0, 0, 0, 0),
c(1/2, 1/2, 0, 0, 0, 0),
c(0, 1, 0, 0, 0, 0))
It is required to centralize the data to its mean for STARIMA modeling, but before doing so, the Year column must be removed since we do not have to centralize this,
palay1 <- subset(palay, select = -c(Year))
Now, centralize the data
palay.cen <- stcenter(palay1)
Finally, compute the STACF and STPACF
stacf(data = palay.cen, wmatrices = list(NULL, W1, W2, W3))
Spatial Lag 0 Spatial Lag 1 Spatial Lag 2 Spatial Lag 3
[1,] -0.4992931 -0.3768003 0.103059733 0.07686560
[2,] 0.6379861 0.6286114 0.013944315 -0.02638101
[3,] -0.4907843 -0.3636884 0.046419684 0.07925981
[4,] 0.9050261 0.5807629 0.019897096 0.09256568
[5,] -0.4804457 -0.3743855 0.094946729 0.06465131
[6,] 0.5895664 0.5862548 0.007210034 -0.02778151
[7,] -0.4769501 -0.3559720 0.041717828 0.06999287
[8,] 0.8321032 0.5432305 0.015287949 0.08079311
[9,] -0.4626080 -0.3692359 0.089099718 0.05182974
[10,] 0.5400462 0.5396841 -0.001916337 -0.03069186
[11,] -0.4607559 -0.3461168 0.041789698 0.06116461
[12,] 0.7589304 0.5078718 0.008028795 0.07026631
[13,] -0.4446532 -0.3634106 0.081175576 0.03902433
[14,] 0.5030049 0.5120928 -0.003504128 -0.02963862
[15,] -0.4451392 -0.3396895 0.037675321 0.05017871
stpacf(data = palay.cen, wmatrices = list(NULL, W1, W2, W3))
Spatial Lag 0 Spatial Lag 1 Spatial Lag 2 Spatial Lag 3
[1,] -0.14304647 0.511218868 0.55682738 0.19981610
[2,] -0.25539678 0.473270591 0.14747855 0.10362970
[3,] -0.10146576 0.359960022 -0.37010962 0.17611802
[4,] 0.38601724 0.035951653 0.06345174 0.11231104
[5,] -0.07615717 -0.209693181 -0.09118031 -0.01877791
[6,] 0.25073879 -0.166778338 -0.03325437 -0.07793400
[7,] 0.08483755 -0.096729707 -0.05191220 -0.10225812
[8,] 0.20206063 0.005777546 -0.01424020 -0.03562691
[9,] 0.14492995 -0.285797604 -0.09654800 -0.09723394
[10,] 0.18184525 -0.576182623 -0.13934442 -0.16191452
[11,] 0.15801674 -0.074907370 0.09285817 -0.01390365
[12,] 0.22796914 -0.048807113 -0.09257688 -0.04854238
[13,] 0.12255899 -0.130296912 -0.17546381 -0.10870668
[14,] -0.05799165 0.313754236 0.06080497 0.07436464
[15,] -0.09576009 -0.238561758 0.13853781 -0.06222810
The findings suggest that the STACF is decaying spatially but not temporally, and as observed, the spikes with high magnitude repeats every four lags, which is the seasonal lag since the data is quarterly. Hence, first order seasonal differencing is needed for transformation,
palay.dif <- diff(as.ts(palay.cen), lag = 4)
lag=4
since the data is quarterly; then we compute again the STACF and STPACF for the differenced series,
stacf(palay.dif, wmatrices = list(NULL, W1, W2, W3))
Spatial Lag 0 Spatial Lag 1 Spatial Lag 2 Spatial Lag 3
[1,] -0.102909427 0.025653689 0.082953522 0.0539520289
[2,] 0.176881582 0.117139152 0.013167676 0.0115715456
[3,] 0.042544299 0.039321092 0.007792355 0.0554658845
[4,] -0.175689995 0.033860939 0.007619782 0.0068130653
[5,] 0.002817186 -0.028309614 -0.036774801 0.0259092901
[6,] 0.075060958 0.088457609 0.034410303 0.0135122268
[7,] 0.044036252 0.023091860 -0.024324734 0.0232175233
[8,] 0.015816331 0.004172408 0.043260335 -0.0127784432
[9,] 0.030520792 0.013617616 0.028537045 0.0190366262
[10,] -0.038435104 -0.120098561 -0.044183399 -0.0241420075
[11,] -0.008104361 0.061734994 0.053531660 0.0148140566
[12,] 0.002133791 0.013137359 -0.054519301 -0.0190006145
[13,] 0.082231615 0.033276088 -0.005586549 -0.0004980636
[14,] -0.015698510 0.161005222 0.004396902 0.0289685701
[15,] 0.125114476 0.024381011 -0.010967296 0.0043345931
stpacf(palay.dif, wmatrices = list(NULL, W1, W2, W3))
Spatial Lag 0 Spatial Lag 1 Spatial Lag 2 Spatial Lag 3
[1,] -0.146421601 0.032487793 0.0853739625 0.088825947
[2,] 0.227574617 0.265251476 0.0086875911 0.022379860
[3,] 0.013884996 0.234501046 0.0017332333 0.087121251
[4,] -0.374341579 -0.007449137 0.0367435307 0.055216997
[5,] -0.148779101 -0.137998111 0.0327572108 0.064802169
[6,] 0.144623030 0.218952875 -0.0008164024 0.030398092
[7,] 0.093971255 0.287856390 -0.0136972967 0.045549415
[8,] -0.148459047 0.003528043 0.0666503281 -0.009344122
[9,] -0.110767128 -0.218838986 0.0363238989 0.029674330
[10,] -0.027504504 -0.071234693 -0.0560620268 -0.020184495
[11,] 0.041945574 0.265583483 0.0341692277 0.027824812
[12,] -0.006097138 0.095614525 0.0095997826 -0.039610927
[13,] 0.022523005 -0.100266088 -0.0116048518 -0.008237559
[14,] -0.094342410 0.199611218 -0.0280317015 0.050161727
[15,] 0.066798455 0.139086023 0.0203601170 0.003121897
The space-time ACF decays both in time and space; and the space-time PACF is significant in time lag 2 and cuts off at spatial lag 1. This is characterized by the space-time AR factor. Hence, we can consider our tentative model to be Seasonal STARIMA$(2_1,0,0)(0,1,0)_4$.