BASTION is an R package providing a Bayesian framework for decomposing univariate time series into meaningful components. It offers several key advantages over existing decomposition methods:
- Locally adaptive estimation of trend and seasonality.
- Explicit modeling of outliers and time-varying volatility.
- Robust uncertainty quantification through credible intervals for all components.
Installation
# Install devtools package if not already installed
install.packages("devtools")
devtools::install_github("Jasoncho0914/BASTION")
Quick Start
The main function is fit_BASTION
. Following is a quick demonstration using the Airline Passenger data between 1949 to 1960.
data(airtraffic)
fit <- fit_BASTION(y = airtraffic$Int_Pax,
Ks = list(12))
#Trend
plot(fit$summary$p_means$y,ylim = c(-1,13),ylab = "Trend")
lines(fit$summary$p_means$Trend,lwd = 4)
#Yearly Seasonality
plot(fit$summary$p_means$Seasonal12,type= "l",lwd = 4,ylab = "Seasonality (k=12)")
#Remainder
plot(fit$summary$p_means$Remainder,type = "l",lwd = 4,ylab = "Remainder")