void ARARFit(TVec S, TVec Phi, ref Int32 l1, ref Int32 l2, ref Int32 l3, ref Double Sigma2, Int32 MaxLag)
Fit ARAR algorithm.
| # | Name | Description |
|---|---|---|
| 1 | S | Memory-shortened time series. If no memory-shortening was performed, then S defines the original unshortened time series. |
| 2 | Phi | Returns ARAR model phi coefficients (phi[1],phi[l1],phi[l2],phi[l3]). Size of Phi vector is adjusted automatically (4). |
| 3 | l1 | Returns ARAR model phil1 lag. |
| 4 | l2 | Returns ARAR model phil2 lag. |
| 5 | l3 | Returns ARAR model phil3 lag. |
| 6 | Sigma2 | Returns ARAR model estimated WN variance. |
| 7 | MaxLag | Defines upper limit for l3, where 1 < l1 < l2 < l3 <= MaxLag. |
Result: stored in self (calling object)
Remarks:
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).
Examples
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, s22;
double s2, rmse;
timeseries.LoadFromFile("deaths.vec");
// #1: shorten series
StatTimeSerAnalysis.ShortenFilter(timeseries, s, out tau, filter, 15);
// #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(), 100, forecasts, stderrs, out rmse);
}
}