IMsExponentialSmoothingTransform.BestModelCoefficients

Fore Syntax

BestModelCoefficients: IExponentialSmoothingParameters;

Fore.NET Syntax

BestModelCoefficients: Prognoz.Platform.Interop.StatLib.IExponentialSmoothingParameters;

Description

The BestModelCoefficients property returns autoselection results of exponential smoothing parameters.

Comments

Results are available only after method calculation.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier, containing a model with the MODEL_EXPLSM identifier. This model must be calculated by the Exponential Smoothing method.

Add links to the Metabase, Ms, Stat system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    msKey: Integer;
    model: IMsModel;
    method: IMsMethod;
    exp: IMsExponentialSmoothingTransform;
    transf: IMsFormulaTransform;
    Coord: IMsFormulaTransformCoord;
    Calc: IMsMethodCalculation;
    res: IMsModelCalculationResult;
    autoSearch: IExponentialSmoothingAutoSearch;
    coef: IExponentialSmoothingParameters;
    i: Integer;
    explSerie: Array Of Double;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container key
    msKey := mb.GetObjectKeyById("MS");
    // Get model
    model := mb.ItemByIdNamespace("MODEL_EXPLSM", msKey).Bind As IMsModel;
    // Get the parameters of the method of model calculation
    transf := model.Transform;
    method := transf.FormulaItem(0).Method;
    exp := method As IMsExponentialSmoothingTransform;
    coord := transf.CreateCoord(transf.Outputs.Item(0));
    // Create object for method calculation
    calc := transf.CreateCalculation;
    calc.Period.IdentificationStartDate := transf.Period.IdentificationStartDate;
    calc.Period.IdentificationEndDate := transf.Period.IdentificationEndDate;
    calc.Period.ForecastStartDate := transf.Period.ForecastStartDate;
    calc.Period.ForecastEndDate := transf.Period.ForecastEndDate;
    calc.CurrentPoint := transf.Period.IdentificationStartDate;
    // Perform calculation
    res := exp.Execute(calc, Coord);
    // Show results in console window
    If res.StatMethod.Status = 0 Then
        autoSearch := exp.AutoSearch;
        coef := exp.BestModelCoefficients;
        Debug.WriteLine("Parameter values:");
        Debug.Indent;
        Debug.Write("Alpha = " + coef.Alpha.ToString);
        PrintInfo(autoSearch.AlphaSearch);
        Debug.Write("Delta = " + coef.Delta.ToString);
        PrintInfo(autoSearch.DeltaSearch);
        Debug.Write("Gamma = " + coef.Gamma.ToString);
        PrintInfo(autoSearch.GammaSearch);
        Debug.Write("Phi = " + coef.Phi.ToString);
        PrintInfo(autoSearch.PhiSearch);
        Debug.Unindent;
    End If;
    explSerie := exp.Explained.Serie(calc);
    Debug.WriteLine("Modeling series values:");
    Debug.Indent;
    For i := 0 To explSerie.Length - 1 Do
        Debug.WriteLine(explSerie[i]);
    End For;
    Debug.Unindent;
End Sub UserProc;

Sub PrintInfo(AutoParam: Boolean);
Begin
    If AutoParam Then
        Debug.WriteLine(" (calculated automatically)");
    Else
        Debug.WriteLine(" (set by user)");
    End If;
End Sub PrintInfo;

After executing the example the console window displays parameter values and model modelling series values.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    msKey: uinteger;
    model: IMsModel;
    method: IMsMethod;
    exp: IMsExponentialSmoothingTransform;
    transf: IMsFormulaTransform;
    Coord: IMsFormulaTransformCoord;
    Calc: IMsMethodCalculation;
    res: IMsModelCalculationResult;
    autoSearch: IExponentialSmoothingAutoSearch;
    coef: IExponentialSmoothingParameters;
    i: Integer;
    explSerie: System.Array;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get modeling container key
    msKey := mb.GetObjectKeyById("MS");
    // Get model
    model := mb.ItemByIdNamespace["MODEL_EXPLSM", msKey].Bind() As IMsModel;
    // Get the parameters of the method of model calculation
    transf := model.Transform;
    method := transf.FormulaItem[0].Method;
    exp := method As IMsExponentialSmoothingTransform;
    coord := transf.CreateCoord(transf.Outputs.Item[0]);
    // Create object for method calculation
    calc := transf.CreateCalculation();
    calc.Period.IdentificationStartDate := transf.Period.IdentificationStartDate;
    calc.Period.IdentificationEndDate := transf.Period.IdentificationEndDate;
    calc.Period.ForecastStartDate := transf.Period.ForecastStartDate;
    calc.Period.ForecastEndDate := transf.Period.ForecastEndDate;
    calc.CurrentPoint := transf.Period.IdentificationStartDate;
    // Perform calculation
    res := exp.Execute(calc, Coord);
    // Show results in console window
    If res.StatMethod.Status = 0 Then
        autoSearch := exp.AutoSearch;
        coef := exp.BestModelCoefficients;
        System.Diagnostics.Debug.WriteLine("Parameter values:");
        System.Diagnostics.Debug.Indent();
        System.Diagnostics.Debug.Write("Alpha = " + coef.Alpha.ToString());
        PrintInfo(autoSearch.AlphaSearch);
        System.Diagnostics.Debug.Write("Delta = " + coef.Delta.ToString());
        PrintInfo(autoSearch.DeltaSearch);
        System.Diagnostics.Debug.Write("Gamma = " + coef.Gamma.ToString());
        PrintInfo(autoSearch.GammaSearch);
        System.Diagnostics.Debug.Write("Phi = " + coef.Phi.ToString());
        PrintInfo(autoSearch.PhiSearch);
        System.Diagnostics.Debug.Unindent();
    End If;
    explSerie := exp.Explained.Serie[calc];
    System.Diagnostics.Debug.WriteLine("Modeling series values:");
    System.Diagnostics.Debug.Indent();
    For i := 0 To explSerie.Length - 1 Do
        System.Diagnostics.Debug.WriteLine(explSerie[i]);
    End For;
    System.Diagnostics.Debug.Unindent();
End Sub;

Public Shared Sub PrintInfo(AutoParam: Boolean);
Begin
    If AutoParam Then
        System.Diagnostics.Debug.WriteLine(" (calculated automatically)");
    Else
        System.Diagnostics.Debug.WriteLine(" (set by user)");
    End If;
End Sub PrintInfo;

See also:

IMsExponentialSmoothingTransform