ISmLinearRegress.Fitted

Syntax

Fitted: Array;

Description

The Fitted property returns an array of modeling series values.

Comments

Values are available after method calculation.

Example

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[
2020Of 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[00] := 1; Weights[01] := 1.5;
    Weights[
02] := 0; Weights[03] := 1;
    Weights[
04] := 1; Weights[05] := 0;
    Weights[
06] := 1.5; Weights[07] := 0;
    Weights[
08] := 1; Weights[09] := 1;
    Weights[
010] := 1; Weights[011] := 1;
    Weights[
012] := 1; Weights[013] := 1;
    Weights[
014] := 1; Weights[015] := 1;
    Weights[
016] := 0; Weights[017] := 2;
    Weights[
018] := 1; Weights[019] := 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 &lt;&gt; <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">&quot;=== Modeling series ===&quot;</font>);<br/> Print(slr.Fitted);<br/> Debug.WriteLine(<font color="#800000">&quot;=== Forecast ===&quot;</font>);<br/> Print(slr.Forecast.Value);<br/> Debug.WriteLine(<font color="#800000">&quot;=== Residual series ===&quot;</font>);<br/> Print(slr.Residuals);<br/> Debug.WriteLine(<font color="#800000">&quot;=== Fisher statistic ===&quot;</font>);<br/> Stat := slr.SummaryStatistics.Fstat;<br/> Debug.WriteLine(Stat);<br/> Debug.WriteLine(<font color="#800000">&quot;=== Fisher statistic probability === &quot;</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">&quot;, ---empty---&quot;</font>);<br/> <font color="#008080">Else</font><br/> d := Data[i];<br/> Debug.WriteLine(i.ToString + <font color="#800000">&quot;, &quot;</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:

ISmLinearRegress