x12aMdlFile: Array;
The x12aMdlFile property determines a string array with possible ARIMA specifications.
The property is used if ISmx12arima.SelectFromFile = True.
Executing the example requires the files:
X12ARIMA.txt. The file contains specifications of ARIMA parameters in the form: (AR, D, MA) (SAR, DS, SMA), where:
AR / SAR. Non-seasonal/seasonal regression order.
D / DS. Non-seasonal/seasonal differentiation order.
MA / SMA. Non-seasonal/seasonal moving average.
Massiv.txt. The file is used to store results of X12 model calculation by specified parameters.
Errors.txt. The file is used to store errors and warnings occurred on X12 model calculation.
Add links to the IO and Stat system assemblies.
Sub UserProc;
Var
cens: ISmX12ARIMA;
y: Array[62] Of Double;
outlier: ICensus2PeriodBegin;
i, n, res: Integer;
NetFile: File;
TextR: ITextReader;
TextW: ITextWriter;
arr: Array Of String;
Begin
cens := New SmX12ARIMA.Create;
// Explained series values
y[0] := 284; y[1] := 277; y[2] := 338; y[3] := 363; y[4] := 370; y[5] := 388;
y[6] := 407; y[7] := 427; y[8] := 368; y[9] := 365; y[10] := 353; y[11] := 375;
y[12] := 248; y[13] := 263; y[14] := 322; y[15] := 396; y[16] := 412; y[17] := 451;
y[18] := 457; y[19] := 457; y[20] := 463; y[21] := 443; y[22] := 411; y[23] := 398;
y[24] := 335; y[25] := 321; y[26] := 393; y[27] := 418; y[28] := 431; y[29] := 499;
y[30] := 583; y[31] := 578; y[32] := 497; y[33] := 519; y[34] := 528; y[35] := 508;
y[36] := 422; y[37] := 439; y[38] := 494; y[39] := 539; y[40] := 559; y[41] := 603;
y[42] := 627; y[43] := 612; y[44] := 548; y[45] := 480; y[46] := 385; y[47] := 428;
y[48] := 307; y[49] := 273; y[50] := 334; y[51] := 390; y[52] := 415; y[53] := 453;
y[54] := 450; y[55] := 479; y[56] := 420; y[57] := 387; y[58] := 381; y[59] := 414;
y[60] := 335; y[61] := 326;
/// General settings ///
//Calculation period
cens.ModelPeriod.FirstPoint := 1;
cens.ModelPeriod.LastPoint := 62;
//Select explanatory variable
cens.Serie.Value := y;
//Quarters or months
cens.SeasonalComponentCycleType := SeasonalityCycleType.Month;
cens.StartPeriod.MonthOrQuarter := 2;
cens.StartPeriod.Year := 2000;
/// Seasonality settings ///
//Seasonality type
cens.SeasonalAdjustmentMode := SeasonalityTypeX12.Additive;
//Seasonal filter
cens.SeasonalFilter := SeasonalFilterType.Auto;
/// Working day and holiday adjustments ///
cens.AdjustmentOptions := AdjustmentOptionsX12Type.X11Step;
// Working day adjustment
cens.TradingDayEffects := TradingDayEffectsX12Type.Td;
// Holiday adjustment
cens.Easter.IsActive := True;
cens.Easter.Day := 8;
/// Specification of ARIMA parameters from file ///
cens.SelectFromFile := True;
cens.SelectFromFileBest := True;
cens.SelectFromFileByFit := True;
TextR := File.OpenTextReader("C:\X12ARIMA.txt");
n := 0;
While Not(TextR.Eof) Do
n := n + 1;
TextR.ReadLine;
End While;
TextR := File.OpenTextReader("C:\X12ARIMA.txt");
arr := New String[n];
For i := 0 To n-1 Do
arr[i] := TextR.ReadLine;
End For;
cens.x12aMdlFile := arr;
/// Outliers ///
outlier := cens.OutliersX11ao.Add;
outlier.Year := 2004;
outlier.MonthOrQuarter := 2;
outlier := cens.OutliersARIMArpbegin.Add;
outlier.Year := 2002;
outlier.MonthOrQuarter := 1;
outlier := cens.OutliersARIMArpend.Add;
outlier.Year := 2002;
outlier.MonthOrQuarter := 5;
/// Diagnostics ///
// Analysis of seasonal component stability
cens.StabilityAnalysisofSeasonals := StabilityAnalysisofSeasonalsX12Type.None;
/// Model calculation ///
res := cens.Execute;
Debug.WriteLine(cens.Errors);
For i := 0 To cens.WarningsCount - 1 Do
Debug.WriteLine(cens.Warnings[i]);
End For;
If (res = 0) Then
// saving to file
If File.Exists("C:\Massiv.txt") Then
TextW := File.OpenTextWriter("C:\Massiv.txt", True);
For i := 0 To cens.Output.Length - 1 Do
TextW.WriteLnString(cens.Output[i]);
End For;
End If;
//output errors
If File.Exists("C:\Errors.txt") Then
TextW := NetFile.OpenTextWriter("C:\Errors.txt", True);
For i := 0 To cens.ErrorFile.Length - 1 Do
TextW.WriteLnString(cens.ErrorFile[i]);
End For;
End If;
End If;
End Sub UserProc;
After executing the example the X12 model is created, two files are formed: Massiv.txt, Errors.txt.
See also: