Seasonal adjustment capabilities for the blockr ecosystem using X-13ARIMA-SEATS and TRAMO/SEATS. This package introduces a new pattern in blockr: blocks that output statistical model objects rather than data or plots, enabling reactive model-based workflows.
pak::pak("cynkra/blockr.seasonal")
library(blockr.core)
library(blockr.seasonal)
library(blockr.ts)
# Simple seasonal adjustment
serve(
new_board(
blocks = c(
data = blockr.ts::new_ts_dataset_block(dataset = "AirPassengers"),
seas = new_seas_block(seas_call = "seas(x = x, x11 = list())"),
final = new_final_block()
),
links = c(
new_link("data", "seas"),
new_link("seas", "final")
)
)
)
This example demonstrates ALL available blocks in blockr.seasonal:
library(blockr.core)
library(blockr.seasonal)
library(blockr.ts)
# Complete seasonal adjustment dashboard with all blocks
serve(
new_board(
blocks = c(
# Data input
data = blockr.ts::new_ts_dataset_block(dataset = "AirPassengers"),
# Main seasonal adjustment block with interactive editor
seas = new_seas_block(
seas_call = "seas(x = x, x11 = list())"
),
# Visualization blocks
final = new_final_block(), # Original vs adjusted series
month = new_monthplot_block(), # Seasonal patterns by month
# Diagnostic blocks
series = new_series_block( # Extract components
series = "d10"
),
models = new_fivebestmdl_block(), # Five best ARIMA models
udg = new_udg_block(), # X-13 statistics via udg()
summary = new_summary_block() # Enhanced model summary
),
# Link all blocks to the seasonal adjustment model
links = c(
new_link("data", "seas"),
new_link("seas", "final"),
new_link("seas", "month"),
new_link("seas", "series"),
new_link("seas", "models"),
new_link("seas", "udg"),
new_link("seas", "summary")
)
)
)
blockr.seasonal is the first blockr package where blocks output statistical model objects. The main new_seas_block()
outputs a seas
model that downstream blocks consume for visualization and analysis.
✅ Single model computation with multiple diagnostic views ✅ Reactive updates across all diagnostics when model changes ✅ Natural workflow for statistical modeling in blockr ✅ Efficient computation - model calculated once, used many times
┌──────────────────────────────────────────┐
│ SEAS MODEL BLOCK │
│ [Interactive seas() specification] │
│ [Model summary output] │
└──────────────────────────────────────────┘
↓
┌───────────────┴───────────────┐
↓ ↓ ↓
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Final │ │ Month │ │ Series │
│ Plot │ │ Plot │ │ Extract │
└─────────┘ └─────────┘ └─────────┘
Creates the main seasonal adjustment block using X-13ARIMA-SEATS.
Parameters:
seas_call
: String containing the complete seas() call (default:"seas(x = x, x11 = list())"
)
Features:
- Interactive Ace editor for modifying seasonal adjustment specifications
- Real-time model summary display
- Error handling for invalid specifications
- Outputs seas model object for downstream blocks
Displays original vs seasonally adjusted series.
Input: seas model from new_seas_block()
Output: Interactive dygraph showing both series overlaid
Shows seasonal patterns by month/period.
Input: seas model from new_seas_block()
Output: Monthplot showing seasonal subseries
Extracts specific components from the seasonal adjustment.
Parameters:
component
: Component to extract ("trend", "seasonal", "irregular", "final", etc.)
Input: seas model from new_seas_block()
Output: blockr.ts time series object (can be used with any blockr.ts blocks)
Compares the five best ARIMA models from automatic model selection.
Input: seas model from new_seas_block()
Output: Model comparison table showing BIC, AIC, and other statistics
Extracts detailed X-13 statistics using the udg()
function.
Input: seas model from new_seas_block()
Output: Comprehensive X-13 diagnostics and statistics
Enhanced model diagnostics and statistical tests.
Input: seas model from new_seas_block()
Output: Detailed diagnostic summary with tests and quality measures
library(blockr.core)
library(blockr.seasonal)
# Prepare data with Chinese New Year regressor
air_data <- tsbox::ts_tbl(datasets::AirPassengers)
cny_regressor <- tsbox::ts_tbl(
seasonal::genhol(seasonal::cny, start = 0, end = 6, center = "calendar")
)
# Seasonal adjustment with external regressor
# Both x and xreg are automatically converted to ts format inside the block
blockr.core::serve(
new_seas_block(
seas_call = "seas(x = x, xreg = xreg, regression.variables = 'td')"
),
data = list(
x = air_data,
xreg = cny_regressor
)
)
- Additional Plots: Spectrum analysis, SI ratios, residual diagnostics
- Model Comparison: Side-by-side evaluation of different specifications
- Export Capabilities: Save adjusted series and models
- Advanced UI: More sophisticated controls beyond ace editor