CointegralCount: Integer;
CointegralCount: integer;
The CointegralCount property determines the number of cointegration links.
The property value cannot be less than 1 and smaller than the number of endogenous variables.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
ECM: ISmErrorCorrectionModel;
Series, SE, TStat: ISlSeries;
Eqs: ISlEquations;
Eq: ISlEquation;
can, fra, ger, us, uk: Array[15] Of Double;
ARO: Array[1] Of Integer;
CI: Array Of Double;
i, res: Integer;
d: Double;
Sub Print(Data: Array Of Double);
Var
i: Integer;
Begin
Debug.WriteLine("---Begin---");
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i]) Then
Debug.WriteLine("---empty---");
Else
Debug.WriteLine(i.ToString + ", " + Data[i].ToString);
End If;
End For;
Debug.WriteLine("---End---");
End Sub Print;
Begin
// values can, fra, ger, uk, us
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; uk[00] := 5320; us[00] := 8680;
can[01] := 6385; fra[01] := 4280; ger[01] := 3673; uk[01] := 5484; us[01] := 9132;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013; uk[02] :=5517; us[02] :=9213;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278; uk[03] :=5791; us[03] :=9450;
can[04] := double.Nan; fra[04] := 4664; ger[04] := 4577; uk[04] := 5971; us[04] := 9177;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135; uk[05] :=6158; us[05] :=9756;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388; uk[06] :=6238; us[06] :=9756;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610; uk[07] :=6322; us[07] :=9724;
can[08] := 7061; fra[08] := 5463; ger[08] := 5787; uk[08] := 6340; us[08] := 9476;
can[09] := 7180; fra[09] := 5610; ger[09] := 6181; uk[09] :=6569; us[09] :=9913;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633; uk[10] := 6813; us[10] := 9974;
can[11] := 7137; fra[11] := 6218; ger[11] := 6910; uk[11] :=6974; us[11] :=10046;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146; uk[12] :=6994; us[12] :=10467;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248; uk[13] := 7220; us[13] := 10740;
can[14] := 8088; fra[14] := 7222; ger[14] := 7689; uk[14] :=7570; us[14] :=11157;
ARO[0] := 1;
ECM := New SmErrorCorrectionModel.Create;
// Sample period parameters
Ecm.ModelPeriod.FirstPoint := 1;
Ecm.ModelPeriod.LastPoint := 15;
// Equations
Eqs := ECM.Equations;
// First equation
Eq := Eqs.Add;
Eq.Serie.Value := can;
Series := Eq.ExogenousVariables;
Series.Add.Value := us;
Series.Add.Value := uk;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.AutoEstimate;
// Second equation
Eq := Eqs.Add;
Eq.Serie.Value := fra;
Series := Eq.ExogenousVariables;
Series.Add.Value := us;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.AutoEstimate;
// Third equation
Eq := Eqs.Add;
Eq.Serie.Value := Ger;
Series := Eq.ExogenousVariables;
Series.Add.Value := uk;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.AutoEstimate;
// Number of cointegration links
ECM.CointegralCount := 2;
// Model type
ECM.ModelType := ECMType.QTrendTrend;
// Missing data treatment method parameters
ECM.MissingData.Method := MissingDataMethod.LinTrend;
// Method calculation and output results
res := Ecm.Execute;
If res <> 0 Then
Debug.WriteLine(Ecm.Errors);
Else
Debug.WriteLine(" == Cointegration equations == ");
Series := Ecm.CointegralEquations;
For i := 0 To Series.Count - 1 Do
CI := Series.Item(i).Value;
Print(CI);
End For;
Debug.WriteLine(" == Standard errors of cointegration equations == ");
SE := Ecm.CointegralEquationsSE;
For i := 0 To SE.Count - 1 Do
CI := SE.Item(i).Value;
Print(CI);
End For;
Debug.WriteLine(" == t-statistics of equation cointegration equations == ");
TStat := Ecm.CointegralEquationsTstat;
For i := 0 To SE.Count - 1 Do
CI := SE.Item(i).Value;
Print(CI);
End For;
Debug.WriteLine(" == Coefficients on cointegration links == ");
For i := 0 To Eqs.Count - 1 Do
Eq := Eqs.Item(i);
CI := Eq.CointegralCoefficients.Estimate;
Print(CI);
End For;
Debug.WriteLine(" == Constant values == ");
For i := 0 To Eqs.Count - 1 Do
Eq := Eqs.Item(i);
Debug.WriteLine(Eq.Trend.Estimate);
End For;
Debug.WriteLine("=== Akaike criterion === ");
d := Ecm.VARStatistics.AIC;
Debug.WriteLine(d);
Debug.WriteLine("=== Schwarz criterion ===");
d := Ecm.VARStatistics.SC;
Debug.WriteLine(d);
End If;
End Sub UserProc;
Results of executing the procedure: parameters are set for the error correction model with a trend and a constant in autoregression and in cointegrated equation, and with quadratic trend in data. The model is estimated, the results are displayed to the console window.
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 Print(Data: System.Array);
Var
i: Integer;
Begin
System.Diagnostics.Debug.WriteLine("---Begin---");
For i := 0 To Data.Length - 1 Do
If Double.IsNan(Data[i] As double) Then
System.Diagnostics.Debug.WriteLine("---empty---");
Else
System.Diagnostics.Debug.WriteLine(i.ToString() + ", " + Data[i].ToString());
End If;
End For;
System.Diagnostics.Debug.WriteLine("---End---");
End Sub Print;
Public Shared Sub Main(Params: StartParams);
Var
ECM: ISmErrorCorrectionModel;
Series, SE, TStat: ISlSeries;
Eqs: ISlEquations;
Eq: ISlEquation;
can, fra, ger, us, uk: Array[15] Of Double;
ARO: Array[1] Of Integer;
CI: System.Array;
i, res: Integer;
d: Double;
Begin
// values can, fra, ger, uk, us
can[00] := 6209; fra[00] := 4110; ger[00] := 3415; uk[00] := 5320; us[00] := 8680;
can[01] := 6385; fra[01] := 4280; ger[01] := 3673; uk[01] := 5484; us[01] := 9132;
can[02] := 6752; fra[02] := 4459; ger[02] := 4013; uk[02] :=5517; us[02] :=9213;
can[03] := 6837; fra[03] := 4545; ger[03] := 4278; uk[03] :=5791; us[03] :=9450;
can[04] := double.Nan; fra[04] := 4664; ger[04] := 4577; uk[04] := 5971; us[04] := 9177;
can[05] := 6907; fra[05] := 4861; ger[05] := 5135; uk[05] :=6158; us[05] :=9756;
can[06] := 7349; fra[06] := 5195; ger[06] := 5388; uk[06] :=6238; us[06] :=9756;
can[07] := 7213; fra[07] := 5389; ger[07] := 5610; uk[07] :=6322; us[07] :=9724;
can[08] := 7061; fra[08] := 5463; ger[08] := 5787; uk[08] := 6340; us[08] := 9476;
can[09] := 7180; fra[09] := 5610; ger[09] := 6181; uk[09] :=6569; us[09] :=9913;
can[10] := 7132; fra[10] := 5948; ger[10] := 6633; uk[10] :=6813; us[10] :=9974;
can[11] := 7137; fra[11] := 6218; ger[11] := 6910; uk[11] := 6974; us[11] := 10046;
can[12] := 7473; fra[12] := 6521; ger[12] := 7146; uk[12] :=6994; us[12] :=10467;
can[13] := 7722; fra[13] := 6788; ger[13] := 7248; uk[13] := 7220; us[13] := 10740;
can[14] := 8088; fra[14] := 7222; ger[14] := 7689; uk[14] :=7570; us[14] :=11157;
ARO[0] := 1;
ECM := New SmErrorCorrectionModel.Create();
// Sample period parameters
Ecm.ModelPeriod.FirstPoint := 1;
Ecm.ModelPeriod.LastPoint := 15;
// Equations
Eqs := ECM.Equations;
// First equation
Eq := Eqs.Add();
Eq.Serie.Value := can;
Series := Eq.ExogenousVariables;
Series.Add().Value := us;
Series.Add().Value := uk;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.imAutoEstimate;
// Second equation
Eq := Eqs.Add();
Eq.Serie.Value := fra;
Series := Eq.ExogenousVariables;
Series.Add().Value := us;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.imAutoEstimate;
// Third equation
Eq := Eqs.Add();
Eq.Serie.Value := Ger;
Series := Eq.ExogenousVariables;
Series.Add().Value := uk;
Eq.AutoRegressionOrder := ARO;
Eq.Forecast.LastPoint := 15;
Eq.Trend.Mode := InterceptMode.imAutoEstimate;
// Number of cointegration links
ECM.CointegralCount := 2;
// Model type
ECM.ModelType := ECMType.ecmtQTrendTrend;
// Missing data treatment method parameters
ECM.MissingData.Method := MissingDataMethod.mdmLinTrend;
// Method calculation and output results
res := Ecm.Execute();
If res <> 0 Then
System.Diagnostics.Debug.WriteLine(Ecm.Errors);
Else
System.Diagnostics.Debug.WriteLine(" == Cointegration equations == ");
Series := Ecm.CointegralEquations;
For i := 0 To Series.Count - 1 Do
CI := Series.Item[i].Value;
Print(CI);
End For;
System.Diagnostics.Debug.WriteLine(" == Standard errors of cointegration equations == ");
SE := Ecm.CointegralEquationsSE;
For i := 0 To Series.Count - 1 Do
CI := Series.Item[i].Value;
Print(CI);
End For;
System.Diagnostics.Debug.WriteLine(" == t-statistics of cointegration equation coefficients == ");
TStat := Ecm.CointegralEquationsTstat;
For i := 0 To Series.Count - 1 Do
CI := Series.Item[i].Value;
Print(CI);
End For;
System.Diagnostics.Debug.WriteLine(" == Coefficients on cointegration links == ");
For i := 0 To Eqs.Count - 1 Do
Eq := Eqs.Item[i];
CI := Eq.CointegralCoefficients.Estimate;
Print(CI);
End For;
System.Diagnostics.Debug.WriteLine(" == Constant values == ");
For i := 0 To Eqs.Count - 1 Do
Eq := Eqs.Item[i];
System.Diagnostics.Debug.WriteLine(Eq.Trend.Estimate);
End For;
System.Diagnostics.Debug.WriteLine("=== Akaike criterion === ");
d := Ecm.VARStatistics.AIC;
System.Diagnostics.Debug.WriteLine(d);
System.Diagnostics.Debug.WriteLine("=== Schwarz criterion ===");
d := Ecm.VARStatistics.SC;
System.Diagnostics.Debug.WriteLine(d);
End If;
End Sub;
See also: