Dew Stats Master .NET
ARARFit Routine
Summary
Fit ARAR algorithm.

Unit
StatTimeSerAnalysis

Declaration
Procedure ARARFit(S: TVec; Phi: TVec; out l1, l2, l3: Integer; out Sigma2: TSample; MaxLag: Integer);
 Parameter  Description 
Memory-shortened time series. If no memory-shortening was performed, then S defines the original unshortened time series. 
Phi Returns ARAR model phi coefficients (phi[1],phi[l1],phi[l2],phi[l3]). Size of Phi vector is adjusted automatically (4). 
l1 Returns ARAR model phil1 lag. 
l2 Returns ARAR model phil2 lag. 
l3 Returns ARAR model phil3 lag. 
Sigma2 Returns ARAR model estimated WN variance. 
MaxLag Defines upper limit for l3, where 1 < l1 < l2 < l3 <= MaxLag. 

Description
Fit ARAR algorithm to (optionaly) memory-shortened series. Let S[t] denote memory-shortened series, derived from Y[t] and let avg(S) denote sample mean of S[t]. The ARAR algorithm tries to fit an autoregressive (AR) process to the mean-corrected series:

The fitted model then has the form:

where Z[t] is WN(0,sigma2).
Categories
Time series analysis routines
ARMA and ARIMA routines
 See Also 
ARARForecast 
ShortenFilter 

Example 1

Fit and then forecast time series values by using ARAR algorithm. Before applying the ARAR algorithm, use the shortening filter on original series.
Uses MtxExpr, StatTimeSerAnalysis, Math387; procedure Example; var timeseries,s,filter,phi: Vector; forecasts,stderrs: Vector; l1,l2,l3,tau: Integer; s2,rmse: TSample; begin timeseries.LoadFromFile('deaths.vec'); // #1: shorten series ShortenFilter(timeSeries,s,tau,Filter); // #2 : fit ARAR model on shortened series ARARFit(s,Phi,l1,l2,l3,s2,13); // #3: forecast 100 values by using ARAR fit parameters ARARForecast(timeseries,Phi,Filter,tau,l1,l2,l3,s.mean,100,forecasts,stderrs,rmse); end;
#include "MtxVecCpp.h" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(); { Vector timeseries,s,filter,phi,forecasts,stderrs; int l1,l2,l3,tau; double s2; timeseries->LoadFromFile("deaths.vec"); // #1: shorten series ShortenFilter(timeSeries,s,tau,Filter); // #2 : fit ARAR model on shortened series ARARFit(s,Phi,l1,l2,l3,s2,13); // #3: forecast 100 values by using ARAR fit parameters ARARForecast(timeseries,Phi,Filter,tau,l1,l2,l3,s->Mean(),s2,100,forecasts,stderrs,rmse); }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector timeseries = new Vector(0); Vector s = new Vector(0); Vector filter = new Vector(0); Vector phi = new Vector(0); Vector forecasts = new Vector(0); Vector stderrs = new Vector(0); int l1,l2,l3,tau; double s2, rmse; timeseries.LoadFromFile("deaths.vec"); // #1: shorten series StatTimeSerAnalysis.ShortenFilter(timeSeries,s,tau,Filter); // #2 : fit ARAR model on shortened series StatTimeSerAnalysis.ARARFit(s,Phi,out l1,out l2,out l3,out s2,13); // #3: forecast 100 values by using ARAR fit parameters StatTimeSerAnalysis.ARARForecast(timeseries,Phi,Filter,tau,l1,l2,l3,s.Mean(),s2,100,forecasts,stderrs,out rmse); } }

Copyright 2008 Dew Research
http://www.dewresearch.com