Value: Array;
Value: System.Array;
The Value property returns an array of forecasting series values.
Length of this array depends on the set last point of the forecast determined by the IForecast.LastPoint property. At the sample period this array contains missing data equal to Double.NAN or 1#.QNAN, which are followed by forecast values in the array.
Add a link to the Stat system assembly.
Sub UserProc;
Var
Method: SmLinearRegress;
Factors: ISlSeries;
Forecast: IForecast;
Serie: Array[6] Of Double;
Factor: Array[10] Of Double;
Period: IStatPeriod;
d0: Double;
FirstPoint, LastPoint, status, i: Integer;
Begin
Method := New SmLinearRegress.Create;
// Set explained series
Serie[00] := 6209; Serie[01] := 6385;
Serie[02] := 6752; Serie[03] := 6837;
Serie[04] := 6495; Serie[05] := Double.Nan;
Method.Explained.Value := Serie;
// Set explanatory series
Factor[00] := 4110; Factor[01] := 4280;
Factor[02] := 4459; Factor[03] := 4545;
Factor[04] := 4664; Factor[05] := 4861;
Factor[06] := 5195; Factor[07] := 5389;
Factor[08] := 5463; Factor[09] := 5610;
Factors := Method.Explanatories;
Factors.Add.Value := Factor;
// Get forecast parameters
Forecast := Method.Forecast;
// Define autoregression parameters
Forecast.ConfidenceLevel := 0.95;
Forecast.CoefUncertaintyInSECalc := False;
// Set sample period
Period := Method.ModelPeriod;
Period.FirstPoint := 1;
Period.LastPoint := 6;
// Set forecast period
Forecast.FirstPoint := 8;
Forecast.LastPoint := 10;
//Run calculation and output results
status := Method.Execute;
FirstPoint := Method.ModelPeriod.FirstPoint;
LastPoint := Forecast.LastPoint;
Debug.WriteLine("=== Forecast values ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.Value[i];
Debug.WriteLine(i.ToString + " " + d0.ToString);
End For;
Debug.WriteLine("=== Upper confidence bound ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.UpperConfidenceLevel[i];
Debug.WriteLine(i.ToString + " " + d0.ToString);
End For;
Debug.WriteLine("=== Lower confidence bound ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.LowerConfidenceLevel[i];
Debug.WriteLine(i.ToString + " " + d0.ToString);
End For;
Debug.WriteLine("=== Standard errors of forecast series ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.StandardError[i];
Debug.WriteLine(i.ToString + " " + d0.ToString);
End For;
End Sub UserProc;
After executing the example the following is set:
Autoregression parameters.
Sample period and forecast period pages.
The console window displays the following calculation results:
Forecast values.
Upper and lower confidence limits.
Standard errors of forecasting series.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
Method: SmLinearRegress;
Factors: ISlSeries;
Forecast: IForecast;
Serie: Array[6] Of Double;
Factor: Array[10] Of Double;
Period: IStatPeriod;
d0: Double;
FirstPoint, LastPoint, status, i: Integer;
Begin
Method := New SmLinearRegress.Create();
// Set explained series
Serie[00] := 6209; Serie[01] := 6385;
Serie[02] := 6752; Serie[03] := 6837;
Serie[04] := 6495; Serie[05] := Double.Nan;
Method.Explained.Value := Serie;
// Set explanatory series
Factor[00] := 4110; Factor[01] := 4280;
Factor[02] := 4459; Factor[03] := 4545;
Factor[04] := 4664; Factor[05] := 4861;
Factor[06] := 5195; Factor[07] := 5389;
Factor[08] := 5463; Factor[09] := 5610;
Factors := Method.Explanatories;
Factors.Add().Value := Factor;
// Get forecast parameters
Forecast := Method.Forecast;
// Define autoregression parameters
Forecast.ConfidenceLevel := 0.95;
Forecast.CoefUncertaintyInSECalc := False;
// Set sample period
Period := Method.ModelPeriod;
Period.FirstPoint := 1;
Period.LastPoint := 6;
// Set forecast period
Forecast.FirstPoint := 8;
Forecast.LastPoint := 10;
//Run calculation and output results
status := Method.Execute();
FirstPoint := Method.ModelPeriod.FirstPoint;
LastPoint := Forecast.LastPoint;
System.Diagnostics.Debug.WriteLine("=== Forecast values ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.Value.GetValue(i) As double;
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + d0.ToString());
End For;
System.Diagnostics.Debug.WriteLine("=== Upper confidence bound ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.UpperConfidenceLevel.GetValue(i) As double;
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + d0.ToString());
End For;
System.Diagnostics.Debug.WriteLine("=== Lower confidence bound ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.LowerConfidenceLevel.GetValue(i) As double;
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + d0.ToString());
End For;
System.Diagnostics.Debug.WriteLine("=== Standard errors of forecast series ===");
For i := FirstPoint To LastPoint - 1 Do
d0 := Forecast.StandardError.GetValue(i) As double;
System.Diagnostics.Debug.WriteLine(i.ToString() + " " + d0.ToString());
End For;
End Sub;
See also: