### SARIMA Example Source: https://github.com/zemlyansky/arima/blob/master/README.md Illustrates the setup and usage of a SARIMA (Seasonal ARIMA) model. It configures seasonal parameters (P, D, Q, s) along with standard ARIMA parameters and then trains and predicts. ```javascript // Init sarima and start training const sarima = new ARIMA({ p: 2, d: 1, q: 2, P: 1, D: 0, Q: 1, s: 12, verbose: false }).train(ts) // Predict next 12 values const [pred, errors] = sarima.predict(12) ``` -------------------------------- ### ARIMA Example Source: https://github.com/zemlyansky/arima/blob/master/README.md Demonstrates a typical ARIMA model usage: initializing, training with time series data, and predicting future values. This example focuses on a synchronous implementation suitable for Node.js or Firefox. ```javascript // Load package const ARIMA = require('arima') // Synthesize timeseries const ts = Array(24).fill(0).map((_, i) => i + Math.random() / 5) // Init arima and start training const arima = new ARIMA({ p: 2, d: 1, q: 2, verbose: false }).train(ts) // Predict next 12 values const [pred, errors] = arima.predict(12) ``` -------------------------------- ### Install ARIMA module Source: https://github.com/zemlyansky/arima/blob/master/README.md Installs the ARIMA JavaScript package using npm. This is the first step to use the library in your project. ```bash npm install arima ``` -------------------------------- ### SARIMAX Example Source: https://github.com/zemlyansky/arima/blob/master/README.md Provides an example of using the SARIMAX model, which incorporates external (exogenous) variables. It shows how to generate data with exogenous variables, train the model using `fit`, and predict with new exogenous data. ```javascript // Generate timeseries using exogenous variables const f = (a, b) => a * 2 + b * 5 const exog = Array(30).fill(0).map(x => [Math.random(), Math.random()]) const exognew = Array(10).fill(0).map(x => [Math.random(), Math.random()]) const ts = exog.map(x => f(x[0], x[1]) + Math.random() / 5) // Init and fit sarimax const sarimax = new ARIMA({ p: 1, d: 0, q: 1, transpose: true, verbose: false }).fit(ts, exog) // Predict next 12 values using exognew const [pred, errors] = sarimax.predict(12, exognew) ``` -------------------------------- ### AutoARIMA Example Source: https://github.com/zemlyansky/arima/blob/master/README.md Demonstrates the usage of the AutoARIMA functionality, which automatically determines the best ARIMA model parameters. It's initialized with `auto: true` and then trained and used for prediction. ```javascript const autoarima = new ARIMA({ auto: true }).fit(ts) const [pred, errors] = autoarima.predict(12) ``` -------------------------------- ### Initialize ARIMA model Source: https://github.com/zemlyansky/arima/blob/master/README.md Initializes a new ARIMA model instance with optional configuration parameters. The 'options' object allows customization of model behavior, including automatic parameter selection and seasonal components. ```javascript const ARIMA = require('arima') const arima = new ARIMA(options) ``` -------------------------------- ### Old functional API for ARIMA Source: https://github.com/zemlyansky/arima/blob/master/README.md Shows the legacy functional API of the ARIMA package, which accepts time series data, prediction steps, and an options object as direct arguments. This method is still supported but the constructor-based approach is preferred. ```javascript const arima = require('arima') const [pred, errors] = arima(ts, 20, { method: 0, // ARIMA method (Default: 0) optimizer: 6, // Optimization method (Default: 6) p: 1, // Number of Autoregressive coefficients d: 0, // Number of times the series needs to be differenced q: 1, // Number of Moving Average Coefficients verbose: true // Output model analysis to console }) ``` -------------------------------- ### Asynchronous ARIMA Loading Source: https://github.com/zemlyansky/arima/blob/master/README.md Loads the ARIMA module asynchronously, which is recommended for browser environments to overcome Web Worker limitations. It returns a Promise that resolves with the ARIMA constructor. ```javascript const ARIMAPromise = require('arima/async') ARIMAPromise.then(ARIMA => { const ts = Array(10).fill(0).map((_, i) => i + Math.random() / 5) const arima = new ARIMA({ p: 2, d: 1, q: 2, P: 0, D: 0, Q: 0, S: 0, verbose: false }).train(ts) const [pred, errors] = arima.predict(10) }) ``` -------------------------------- ### Train and Predict with ARIMA/SARIMA Source: https://github.com/zemlyansky/arima/blob/master/README.md Trains the ARIMA or SARIMA model using a time series dataset and predicts future values. The `train` method (or `fit`) takes the time series data as input, and `predict` forecasts a specified number of steps. ```javascript arima.train(ts) // Or arima.fit(ts) arima.predict(10) // Predict 10 steps forward ``` -------------------------------- ### Train and Predict with SARIMAX Source: https://github.com/zemlyansky/arima/blob/master/README.md Trains the SARIMAX model, which includes exogenous variables, and predicts future values. The `train` method (or `fit`) accepts both the time series data and exogenous variables, while `predict` can optionally use new exogenous variables for forecasting. ```javascript arima.train(ts, exog) // or arima.fit(ts, exog)arima.predict(10, exognew) // Predict 10 steps forwars using new exogenous variables ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.