Fitted: Array;
The Fitted property returns an array of modeling series values.
Values are available after method calculation.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
slr: SmLinearRegress;
Factors: ISlSeries;
res: Integer;
Serie, Factor: Array Of Double;
Weights: Array[20, 20] Of Double;
Period: IStatPeriod;
AR, MA: Array Of Integer;
ARMA: ISlARMA;
Stat: Double;
Begin
slr := New SmLinearRegress.Create;
// Set explained series
Serie := New Double[20];
Serie[00] := 6209; Serie[01] := 6385;
Serie[02] := 6752; Serie[03] := 6837;
Serie[04] := 6495; Serie[05] := 6907;
Serie[06] := 7349; Serie[07] := 7213;
Serie[08] := 7061; Serie[09] := 7180;
Serie[10] := 7132; Serie[11] := 7137;
Serie[12] := 7473; Serie[13] := 7722;
Serie[14] := 8088; Serie[15] := 7486;
Serie[16] := 7832; Serie[17] := 9064;
Serie[18] := 9380; Serie[19] := 9746;
slr.Explained.Value := Serie;
// Set explanatory series
Factor := New Double[30];
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;
Factor[10] := 5948; Factor[11] := 6218;
Factor[12] := 6521; Factor[13] := 6788;
Factor[14] := 7222; Factor[15] := 7486;
Factor[16] := 7832; Factor[17] := 8153;
Factor[18] := 8468; Factor[19] := 9054;
Factor[20] := 9907; Factor[21] := 10333;
Factor[22] := 10863; Factor[23] := 11693;
Factors := slr.Explanatories;
Factors.Add.Value := Factor;
// Set a weights series
Weights[0, 0] := 1; Weights[0, 1] := 1.5;
Weights[0, 2] := 0; Weights[0, 3] := 1;
Weights[0, 4] := 1; Weights[0, 5] := 0;
Weights[0, 6] := 1.5; Weights[0, 7] := 0;
Weights[0, 8] := 1; Weights[0, 9] := 1;
Weights[0, 10] := 1; Weights[0, 11] := 1;
Weights[0, 12] := 1; Weights[0, 13] := 1;
Weights[0, 14] := 1; Weights[0, 15] := 1;
Weights[0, 16] := 0; Weights[0, 17] := 2;
Weights[0, 18] := 1; Weights[0, 19] := 1.</font><font color="#008000">5</font><font color="#000000">;<br/> slr.UseWeights := </font><font color="#008080">True</font><font color="#000000">;<br/> slr.GLSMatrix := Weights;</font></span><br/> <font color="#008000">// Set autoregression and moving average parameters<br/> </font> ARMA := slr.ARMA;<br/> AR := <font color="#008080">New</font> Integer[<font color="#008000">1</font>];<br/> AR[<font color="#008000">0</font>] := <font color="#008000">1</font>;<br/> ARMA.OrderAR := AR;<br/> MA := <font color="#008080">New</font> Integer[<font color="#008000">1</font>];<br/> MA[<font color="#008000">0</font>] := <font color="#008000">1</font>;<br/> ARMA.OrderMA := MA;<br/> <font color="#008000">// Set sample period parameters<br/> </font> Period := slr.ModelPeriod;<br/> Period.FirstPoint := <font color="#008000">4</font>;<br/> Period.LastPoint := <font color="#008000">20</font>;<br/> <font color="#008000">// Set forecasting parameters<br/> </font> slr.Forecast.LastPoint := <font color="#008000">30</font>;<br/> <font color="#008000">//Calculate and display results<br/> </font> res := slr.Execute;<br/> <font color="#008080">If</font> res <> <font color="#008000">0</font> <font color="#008080">Then</font><br/> Debug.WriteLine(slr.Errors);<br/> <font color="#008080">Else</font><br/> Debug.WriteLine(<font color="#800000">"=== Modeling series ==="</font>);<br/> Print(slr.Fitted);<br/> Debug.WriteLine(<font color="#800000">"=== Forecast ==="</font>);<br/> Print(slr.Forecast.Value);<br/> Debug.WriteLine(<font color="#800000">"=== Residual series ==="</font>);<br/> Print(slr.Residuals);<br/> Debug.WriteLine(<font color="#800000">"=== Fisher statistic ==="</font>);<br/> Stat := slr.SummaryStatistics.Fstat;<br/> Debug.WriteLine(Stat);<br/> Debug.WriteLine(<font color="#800000">"=== Fisher statistic probability === "</font>);<br/> Stat := slr.SummaryStatistics.ProbFstat;<br/> Debug.WriteLine(Stat);<br/> <font color="#008080">End</font> <font color="#008080">If</font>;<br/> <font color="#008080">End</font> <font color="#008080">Sub</font> UserProc;<br/> <font color="#008000">// Data input procedure<br/> </font><font color="#008080">Sub</font> Print(Data: Array <font color="#008080">Of</font> Double);<br/> <font color="#008080">Var</font><br/> i: Integer;<br/> d: Double;<br/> <font color="#008080">Begin</font><br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Data.Length - <font color="#008000">1</font> <font color="#008080">Do</font><br/> <font color="#008080">If</font> Double.IsNan(Data[i]) <font color="#008080">Then</font><br/> Debug.WriteLine(i.ToString + <font color="#800000">", ---empty---"</font>);<br/> <font color="#008080">Else</font><br/> d := Data[i];<br/> Debug.WriteLine(i.ToString + <font color="#800000">", "</font> + d.ToString);<br/> <font color="#008080">End</font> <font color="#008080">If</font>;<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> <font color="#008080">End</font> <font color="#008080">Sub</font> Print;
After executing the example the console window displays linear regression calculation results: modeling series, forecasting series, residual series, the Fisher statistic, and Fisher statistic probability.
See also: