Title: | Seasonal Generalized Space Time Autoregressive (S-GSTAR) Model |
---|---|
Description: | A set of function that implements for seasonal multivariate time series analysis based on Seasonal Generalized Space Time Autoregressive with Seemingly Unrelated Regression (S-GSTAR-SUR) Model by Setiawan(2016)<https://www.researchgate.net/publication/316517889_S-GSTAR-SUR_model_for_seasonal_spatio_temporal_data_forecasting>. |
Authors: | M. Yoga Satria Utama Developer [aut, cre], Ernawati Pasaribu Developer [aut] |
Maintainer: | M. Yoga Satria Utama Developer <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2025-02-07 03:26:44 UTC |
Source: | https://github.com/yogasatria30/sgstar |
A simple tibble
dataset containing the coordinate region In South.
coords
coords
A tibble
with 17 rows as Region/City and 2 column,which are:
longitude coordinate for each location
latitude coordinate for each location
https://www.bps.go.id/
Plotting line chart dataset and fit.values of the Seasonal GSTAR model.
plot_sgstar(formula)
plot_sgstar(formula)
formula |
an object from the output from sgstar() function. |
returns output a list that shown line chart for each location.
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) plot1 <- plot_sgstar(fit)
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) plot1 <- plot_sgstar(fit)
Predicting value based on Sgstar object
predict_sgstar(formula, n_time)
predict_sgstar(formula, n_time)
formula |
an object from the output from sgstar() function. |
n_time |
number of steps ahead for which prediction is required. |
returns output a dataframe that shown predict value based on model, with rows as time and column that shown for each location.
Setiawan, Suhartono, and Prastuti M.(2016).S GSTAR-SUR for Seasonal Spatio Temporal Data Forecasting. Malaysian Journal Of Mathematical Sciences.10.<Corpus ID :189955959>.
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) #predicting for 12 time ahead predict.fit <-predict_sgstar(fit,12)
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) #predicting for 12 time ahead predict.fit <-predict_sgstar(fit,12)
sgstar function return the parameter estimation of Seaonal Generalized Space Time Autoregressive Model by using Generalized Least Square (GLS)
sgstar(data, w, p, ps, s)
sgstar(data, w, p, ps, s)
data |
A dataframe that contain timeseries data with k column as space and n rows as time. |
w |
a spatial weight, matrix ncol(data) * ncol(data) with diagonal = 0. |
p |
an autoregressive order, value must be greater than 0. |
ps |
an autoregressive order for seasonal, value must be greater than 0. |
s |
an order of the seasonal period |
sgstar returns output with detail are shown in the following list :
Coefficiens |
coefficiens parameter model for each location |
Fitted.Values |
a dataframe with fit value for each location based on model |
Residual |
a dataframe that contain residual,that is response minus fitted values based on model |
Performance |
a dataframe containing the following objects: |
MSE : Mean Squared Error (MSE) for all the data combined.
RMSE : Root Mean Squared Error (RMSE) for all the data combined.
AIC : a Version of Akaike's Information Criterion (AIC)
Rsquared : R^2, the ‘fraction of variance explained by the model’.
p |
an autoregressive order |
ps |
an autoregressive order for seasonal |
s |
an order of the seasonal period |
weight |
a spatial weight |
data |
a dataset that used in modeling |
Setiawan, Suhartono, and Prastuti M.(2016).S GSTAR-SUR for Seasonal Spatio Temporal Data Forecasting. Malaysian Journal Of Mathematical Sciences.10.<Corpus ID :189955959>.
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) fit
library(sgstar) data("coords") data("simulatedata") #create weight matrix using distance inverse matrix z<-dist(coords,method = "euclidean") z <- as.matrix(z) matriksd <- 1/z matriksd[is.infinite(matriksd)] <- 0 matriksd_w <- matriksd / rowSums(as.data.frame(matriksd)) fit <- sgstar(data = simulatedata, w = matriksd_w, p = 2,ps = 1, s =4) fit
A simple tibble
that is generate from random normal
distribution for simulate seasonal generalized space-time autoregressive model.
simulatedata
simulatedata
A tibble
with 100 observation time and 17 column as location,which are:
a value dataset for PALEMBANG
a value dataset for LUBUKLINGGAU
a value dataset for OGAN KOMERING ULU SELATAN
a value dataset for OGAN KOMERING ULU
a value dataset for OGAN KOMERING ILIR
a value dataset for MUSI RAWAS
a value dataset for OGAN ILIR
a value dataset for PAGAR ALAM
a value dataset for BANYU ASIN
a value dataset for OGAN KOMERING ULU TIMUR
a value dataset for EMPAT LAWANG
a value dataset for EMPAT LAWANG
a value dataset for LAHAT
a value dataset for MUSI RAWAS UTARA
a value dataset for PENUKAL ABAB LEMATANG ILIR
a value dataset for MUARA ENIM
a value dataset for MUSI BANYUASIN