AutoCorrelation(EntryKey: Integer;
Period: IMsModelPeriod;
Var ACF: Array;
Var PACF: Array;
Var QStatistics: Array;
Var Probability: Array;
Var StandardError: Double): String;
AutoCorrelation
(EntryKey: integer;
Period: Prognoz.Platform.Interop.Ms.IMsModelPeriod;
var ACF: System.Array;
var PACF: System.Array;
var QStatistics: System.Array;
var Probability: System.Array;
var StandardError: double): string;
EntryKey. Model calculation parameters.
Period. Calculation period.
ACF. Real-valued array with values of the autocorrelation function.
PACF. Real array with values of the private autocorrelation function.
QStatistics. Real array with values of the Ljung-Box Q-statistics.
Probability. Real array with probability values of the Ljung-Box Q-statistics.
StandardError. Value of standard error.
The AutoCorrelation method performs the autocorrelation analysis of the variable.
If the analysis is successful, calculation results are loaded into ACF, PACF, QStatistics, Probablity and StandardError; otherwise the method returns a text of error.
Executing the example requires that the repository contains a modeling container with the MS identifier, containing a modeling problem with the PROBLEM identifier. This problem must contain the internal metamodel.
Add links to the Metabase, Ms system assemblies.
// Execution of autocorrelation analysis
Sub UserAutoCorrelation;
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Period: IMsModelPeriod;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
VarKey, i: Integer;
ChainEn: IMsCalculationChainEntries;
ACF, PACF, QStatistics, Probability: Array Of Double;
StandardError: Double;
Begin
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace("PROBLEM", MsObj.Key).Bind As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
// Get calculation period
Period := (Problem.Details As IMsProblemDetails).Period;
// Get the first free variable
ChainEn := Meta.CalculationChain;
VarKey := -1; i := 0;
Repeat
If ChainEn.Item(i).Type = MsCalculationChainEntryType.Variable Then
VarKey := ChainEn.Item(i).Key;
End If;
i := i + 1;
Until (VarKey = -1) Or (i <> ChainEn.Count);
// If the variable is found then perform the autocorrelational analysis
If VarKey <> -1 Then
MetaVisual := Meta.VisualController;
Debug.WriteLine(MetaVisual.AutoCorrelation(VarKey, Period, ACF, PACF, QStatistics, Probability, StandardError));
Debug.WriteLine("Values of autocorrelation function");
PrintArray(ACF);
Debug.WriteLine("Values of private autocorrelation function");
PrintArray(PACF);
Debug.WriteLine("Values of Ljung-Box q statistics");
PrintArray(QStatistics);
Debug.WriteLine("Probability value of Ljung-Box Q-statistic");
PrintArray(Probability);
Debug.WriteLine("Value of standard error of autocorrelation function");
Debug.WriteLine(StandardError);
End If;
End Sub UserAutoCorrelation;
// Data output procedure
Sub PrintArray(arr: Array Of Double);
Var i: Integer;
Begin
For i := 0 To arr.Length - 1 Do
Debug.WriteLine(arr[i]);
End For;
Debug.WriteLine("");
End Sub PrintArray;
Example execution result: if the metamodel contains variables, the autocorrelation analysis will be executed for the first variable, and the results will be displayed in the console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
// Performing autocorrelation analysis
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Period: IMsModelPeriod;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
VarKey: uinteger;
i: integer;
ChainEn: IMsCalculationChainEntries;
ACF, PACF, QStatistics, Probability: System.Array;
StandardError: Double;
Begin
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MS"];
// Get modeling problem
Problem := mb.ItemByIdNamespace["PROBLEM", MsObj.Key].Bind() As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
// Get calculation period
Period := (Problem.Details As IMsProblemDetails).Period;
// Get the first free variable
ChainEn := Meta.CalculationChain;
VarKey := 0; i := 0;
Repeat
If ChainEn.Item[i].Type = MsCalculationChainEntryType.mccetVariable Then
VarKey := ChainEn.Item[i].Key;
End If;
i := i + 1;
Until (VarKey = 0) Or (i <> ChainEn.Count);
// If the variable is found then perform the autocorrelational analysis
If VarKey <> 0 Then
MetaVisual := Meta.VisualController;
System.Diagnostics.Debug.WriteLine(MetaVisual.AutoCorrelation(VarKey As integer, Period,
Var ACF, Var PACF, Var QStatistics, Var Probability, Var StandardError));
System.Diagnostics.Debug.WriteLine("Values of autocorrelation function");
PrintArray(ACF);
System.Diagnostics.Debug.WriteLine("Values of private autocorrelation function");
PrintArray(PACF);
System.Diagnostics.Debug.WriteLine("Values of Ljung-Box Q-statistics");
PrintArray(QStatistics);
System.Diagnostics.Debug.WriteLine("Probability values of Ljung-Box Q-statistics");
PrintArray(Probability);
System.Diagnostics.Debug.WriteLine("Values of standard error of autocorrelation function");
System.Diagnostics.Debug.WriteLine(StandardError);
End If;
End Sub;
// Data output procedure
Public Shared Sub PrintArray(arr: System.Array);
Var i: Integer;
Begin
For i := 0 To arr.Length - 1 Do
System.Diagnostics.Debug.WriteLine(arr[i]);
End For;
System.Diagnostics.Debug.WriteLine("");
End Sub PrintArray;
See also: