GAUSS varmaPredict Example

VARMA Predict

Introduction

This example estimates and predicts an VAR(2) model in GAUSS using simulated data. It demonstrates usage of varmaFit and varmaPredict.

Step 1: Load data

This example loads the data using the GAUSS function loadd. The function loadd utilizes the GAUSS formula string syntax and allows users to load and transform specific variables directly from the dataset.

new;
library tsmt;

// Load data
// Create file name with full path
fname = getGAUSSHome() $+ "pkgs/tsmt/examples/mink.csv";

// Load two variables from dataset
y = loadd(fname, "LogMink + LogMusk");

// Difference the data
y = vmdiffmt(y, 1);

Step 2: Estimate The Model

Because this model is strictly a VAR model, the only additional input after the data matrix is the AR order.

// Declare 'vout' to be a varmamtOut structure
// to hold the return values from 'vout'
struct varmamtOut vout;

// Estimate the parameters of the VAR(2) model
// and print diagnostic information
vout = varmaFit(y, 2);

Step 3: Estimation Output

The coefficient estimates read:

===============================================================================
 VARMAX Version 3.0.0
=============================================================================== Phi Plane [1,.,.] -0.12309 0.57672 -0.67611 0.34425 Plane [2,.,.] 0.26190 -0.12894 -0.26000 -0.044378

Step 4: Predict Model

The final step is to predict the model using varmaPredict

// Forecast 25 periods
f = varmaPredict(vout, y, 0, 25);

Plotted Output

Below is the full code to produce the graph of the forecasts shown at the top of this page.

/*
** Plot differenced data and forecast
*/

// Declare 'myPlot' to be a plotControl structure
// and fill with default values
struct plotControl myPlot;
myPlot = plotGetDefaults("xy");

// Turn grid off
plotSetGrid(&myPlot, "off");

// Font settings
font_name = "Helvetica Neue";
font_color = "black";

plotSetTitle(&myPlot, "Differenced data and VAR(2) model forecast", 
             font_name, 18, font_color);

// Add a tick label every 10 years, starting at 1860
plotSetXTicInterval(&myPlot, 10, 1860);

// Legend
plotSetLegend(&myPlot, "Y1 Obs." $| "Y2 Obs.");
plotSetLegendFont(&myPlot, font_name, 14, font_color);

// Plot differenced 'y' data
plotTS(myPlot, 1850, 1, y);

// Set line style to dots for forecasted data
plotSetLineStyle(&myPlot, 3);

// Legend
plotSetLegend(&myPlot, "Y1 Forecasts"$|"Y2 Forecasts");
plotSetLegendFont(&myPlot, font_name, 14, font_color);

// Add forecasts to plot
plotAddTS(myPlot, 1910, 1, f[.,2:3]);

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy