IMsMetaModelVisualController.AutoCorrelation

Syntax

AutoCorrelation(EntryKey: Integer;
    Period: IMsModelPeriod;
    Var ACF: Array;
    Var PACF: Array;
    Var QStatistics: Array;
    Var Probability: Array;
    Var StandardError: Double): String;

Parameters

EntryKey. Model calculation options.

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-statistic.

Probability. Real array with probability values of the Ljung-Box Q-statistic.

StandardError. Value of standard error.

Description

The AutoCorrelation method performs the autocorrelation analysis of the variable.

Comments

If the analysis is successful, calculation results are loaded into ACF, PACF, QStatistics, Probablity and StandardError; otherwise the method returns a text of error.

Example

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 = -1Or (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-statistic");
        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.

See also:

IMsMetaModelVisualController