You are here: Symbol Reference > StatTimeSerAnalysis Namespace > Functions > StatTimeSerAnalysis.ARARFit Function
Stats Master VCL
ContentsIndex
PreviousUpNext
StatTimeSerAnalysis.ARARFit Function

Fit ARAR algorithm.

Pascal
procedure ARARFit(const S: TVec; const Phi: TVec; out l1: Integer; out l2: Integer; out l3: Integer; out Sigma2: double; const MaxLag: Integer);
Parameters 
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. 

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).

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: double;
 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 "MtxExpr.hpp"
#include "StatTimeSerAnalysis.hpp"
void __fastcall Example();
{
    sVector timeSeries,s,filter,phi,forecasts,stderrs;
    int l1,l2,l3,tau;
    double s2, rmse;
    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);
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!