ISmLinearRegress.PDLTermCollection

Syntax

PDLTermCollection: ISlPDLTermCollection;

Description

The PDLTermCollection property returns a collection of lag variables.

Comments

Each element of the collection is implemented by the ISlPDLTerm interface that enables the user to set lag variable and define its parameters.

Example

To execute the example you need to add a link to the system assembly Stat.

Sub UserProc;
Var
    Method: SmLinearRegress;
    Factors: ISlSeries;
    Serie, Factor, ger, jpn: Array[20Of Double;
    PDLTermCollect: ISlPDLTermCollection;
    PDLTerm: ISlPDLTerm;
    
    Sub Print(Data: Array Of Double);
    Var i: Integer;
        d: Double;
    Begin
        For i := 0 To Data.Length - 1 Do
            If Double.IsNan(Data[i]) Then
                Debug.WriteLine(i.ToString + ", ---empty---");
            Else
                d := Data[i];
                Debug.WriteLine(i.ToString + ", " + d.ToString);
            End If;
        End For;
    End Sub Print;
Begin

    Method := New SmLinearRegress.Create;
// explained variable
    Serie[00] := 6209; Serie[10] := 7132;
    Serie[01] := 6385; Serie[11] := 7137;
    Serie[02] := 6752; Serie[12] := 7473;
    Serie[03] := 6837; Serie[13] := 7722;
    Serie[04] := 6495; Serie[14] := 8088;
    Serie[05] := 6907; Serie[15] := Double.Nan;
    Serie[06] := 7349; Serie[16] := Double.Nan;
    Serie[07] := 7213; Serie[17] := 9064;
    Serie[08] := 7061; Serie[18] := 9380;
    Serie[09] := 7180; Serie[19] := 9746;
// explanatory variable

    Factor[00] := 4110; Factor[10] := 5948;
    Factor[01] := 4280; Factor[11] := 6218;
    Factor[02] := 4459; Factor[12] := 6521;
    Factor[03] := 4545; Factor[13] := 6788;
    Factor[04] := 4664; Factor[14] := 7222;
    Factor[05] := 4861; Factor[15] := 7486;
    Factor[06] := 5195; Factor[16] := 7832;
    Factor[07] := 5389; Factor[17] := 8153;
    Factor[08] := 5463; Factor[18] := 8468;
    Factor[09] := 5610; Factor[19] := 9054;
// first lag variable
    ger[00] := 3415; ger[10] := 6633;
    ger[01] := 3673; ger[11] := 6910;
    ger[02] := 4013; ger[12] := 7146;
    ger[03] := 4278; ger[13] := 7248;
    ger[04] := 4577; ger[14] := 7689;
    ger[05] := 5135; ger[15] := 8046;
    ger[06] := 5388; ger[16] := 8143;
    ger[07] := 5610; ger[17] := 8064;
    ger[08] := 5787; ger[18] := 8556;
    ger[09] := 6181; ger[19] := 9177;

// second lag variable
    jpn[00] := 1475; jpn[10] := 3052;
    jpn[01] := 1649; jpn[11] := 3453;
    jpn[02] := 1787; jpn[12] := 3666;
    jpn[03] := 1884; jpn[13] := 4008;
    jpn[04] := 1972; jpn[14] := 4486;
    jpn[05] := 2108; jpn[15] := 4663;
    jpn[06] := 2249; jpn[16] := 5115;
    jpn[07] := 2394; jpn[17] := 5655;
    jpn[08] := 2505; jpn[18] := 6358;
    jpn[09] := 2714; jpn[19] := 6995;
// set explained and explanatory variables
    
Method.Explained.Value := Serie;
    Factors := Method.Explanatories;
    Factors.Add.Value := Factor;
// set regression parameters
    Method.MissingData.Method := MissingDataMethod.LinInterpolation;
    Method.ModelPeriod.LastPoint := 20;
    Method.Forecast.LastPoint := 30;

// set lag variables
    PDLTermCollect := Method.PDLTermCollection;
    If PDLTermCollect.Count > 0 Then
        PDLTermCollect.Clear;
    End If;
// set parameters of the first lag variable
    PDLTerm := PDLTermCollect.Add;
    PDLTerm.Explanatory.Value := ger;
    PDLTerm.PDLConstraint := PDLConstraintType.Both;
    PDLTerm.PolinomialDegreeP := 4;
    PDLTerm.LagLengthK := 1;
// set parameters of the second lag variable
    PDLTerm := PDLTermCollect.Add;
    PDLTerm.Explanatory.Value := jpn;
    PDLTerm.PDLConstraint := PDLConstraintType.FarEnd;
    PDLTerm.PolinomialDegreeP := 2;
    PDLTerm.LagLengthK := 2;

    If Method.Execute = 0 Then
     // calculate method with lag variables, output results
        Debug.WriteLine("--- Calculate with lag variables ---");
        Debug.WriteLine("");
        Debug.WriteLine("=== Sum by coefficients  ===");
        Debug.WriteLine(PDLTerm.EstimatesSum);
        Debug.WriteLine("=== Sum of standard errors  ===");
        Debug.WriteLine(PDLTerm.StdErrSum);
        Debug.WriteLine("=== Sum  of t-statistics  ===");
        Debug.WriteLine(PDLTerm.TStatSum);
        Debug.WriteLine("=== Value of coefficients of the first lag variable  ===");
        PDLTerm := PDLTermCollect.Item(0);
        Print(PDLTerm.BetaCoefficients.Estimate);
        Debug.WriteLine("=== Value of coefficients of the second lag variable  ===");
        PDLTerm := PDLTermCollect.Item(1);
        Print(PDLTerm.BetaCoefficients.Estimate);

        Debug.WriteLine("=== Model series ===");
        Print(Method.Fitted);
     // remove lag variables
        PDLTermCollect.Remove(0);
        PDLTermCollect.Remove(1);
     // calculate method without lag variables, output results
        Method.Execute;
        Debug.WriteLine("");
        Debug.WriteLine("--- Calculate without lag variables ---");
        Debug.WriteLine("");
        Debug.WriteLine("=== Model series ===");
        Print(Method.Fitted);
    End If;
End Sub UserProc;

The following parameters for linear regression calculation are defined in this axample:

Then this method is calculated using lag variables and without using lag variables. Both times calculation results are displayed in the console window:

--- Calculation using lag variables ---

=== Sum by coefficients  ===
-0,259287376046178
=== Standard errors' sum  ===
1,#QNAN
=== T-statistics sum  ===
1,#QNAN
=== Value of the1st lag variable coefficients  ===
0, -1.7962778395230557E+030
10
=== Value of the2nd lag variable coefficients  ===
0, -0.72547345120881013
10.027016101144493737
20.43916997401813851
=== Model series ===

0, ---empty---
1, ---empty---
26746.6262960822805
36705.2419410586554
46811.0056257257002
56865.9015751798979
67292.6256724880859
77154.7388452839468
87034.0549816297171
97019.5326444809853
107175.7552959831073
117133.7987951692921
127493.2677988806945
137752.1833310759594
148246.7312273784864
158412.3662053850512
168747.7534296460744
179049.2002280807264
189295.9170202707646
199751.2990862005718

--- Calculation without lag variables ---

=== Model series ===
0, ---empty---
1, ---empty---
26613.769915787384
36773.9117223980902
46876.8830698908987
56906.7321402631733
66883.5744185839867
76964.012416733297
87099.7805343158489
97199.9024146523625
107212.3379803167554
117375.27145090251
127662.7794419466027
137976.5614721920238
148075.9943825777045
158402.5141370048095
168745.8416724303534
178884.288279843915
189302.1786791848208
199731.6658709754629

See also:

ISmLinearRegress