IModelling.InterpolateP

Fore Syntax

InterpolateP(Input: ITimeSeries;
             TargetFrequency: MsFrequency;
             Pattern: ITimeSeries;
             [PatternType: MsPatternType = 0;]
             [Period: IMsPeriod = Null]): Variant;

Fore.NET Syntax

InterpolateP(Input: Prognoz.Platform.Interop.Ms.TimeSeries;
             TargetFrequency: Prognoz.Platform.Interop.Ms.MsFrequency;
             Pattern: Prognoz.Platform.Interop.Ms.TimeSeries;
             PatternType: Prognoz.Platform.Interop.Ms.MsPatternType;
             Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext;
             Period: Prognoz.Platform.Interop.Ms.IMsPeriod): object;

Parameters

Input. Input variable.

TargetFrequency. Output frequency.

Pattern. Pattern variable, on which the interpolation is based. It must contain output frequency.

PatternType. Pattern type, on which the interpolation is based. Optional parameter.The default value of the MsPatternType.Average is average by elements.

Context. Context. The parameter is used only in Fore.NET.

Period. Period, at which the method is calculated. If the parameter is set to Null, the method is calculated at the entire time period.

Description

The InterpolateP method interpolates variable values according to a pattern.

Comments

To determine an initial frequency for the Input variable, use the IMsFormulaTransformSlice.Level property.

On data disaggregation the following calendar frequency settings are taken into account: start period offset relative to its start/end.

Example of data aggregation from weekly to daily frequency

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This container contains a model with the MODEL_D identifier (annual frequency). This model should contain several factors. Each factor should contain annual and quarterly frequency.

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

Sub UserProc;
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    InputTerm, PatternTerm: IMsFormulaTermInfo;
    Expr: IExpression;
Begin
    Mb := MetabaseClass.Active;
    ModelSpace := Mb.ItemById("CONT_MODEL").Bind;
    ModelObj := Mb.ItemByIdNamespace("M_DETERM", ModelSpace.Key).Edit;
    Model := ModelObj As IMsModel;
    Transf := Model.Transform;
    Formula := Transf.FormulaItem(0);
    Determ := Formula.Method As IMsDeterministicTransform;
    TransVar := Transf.Inputs.Item(0);
    Slice := TransVar.Slices.Item(0);
    InputTerm := Transf.CreateTermInfo;
    InputTerm.Slice := Slice;
    TransVar := Transf.Inputs.Item(1);
    Slice := TransVar.Slices.Item(0);
    PatternTerm := Transf.CreateTermInfo;
    Slice.Level := DimCalendarLevel.Quarter;
    PatternTerm.Slice := Slice;
    Expr := Determ.Expression;
    Expr.References := "Ms";
    Expr.AsString := "InterpolateP(" + InputTerm.TermInnerText + ",MsFrequency.Quarterly," +
        PatternTerm.TermInnerText + ",MsPatternType.First,SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" + "))";
    If Expr.Valid
        Then ModelObj.Save;
        Else Debug.WriteLine("Model is not saved: error in equation");
   End If;
End Sub UserProc;

After executing the example the model interpolates the first input variable data from annual frequency to quarterly for the period from 2000 to 2015.A pattern, set by the second input variable, is used for interpolation.

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.Dimensions;
Imports Prognoz.Platform.Interop.ForeSystem;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    InputTerm, PatternTerm: IMsFormulaTermInfo;
    Expr: IExpression;
Begin
    Mb := Params.Metabase;
    ModelSpace := Mb.ItemById["MS"].Bind();
    ModelObj := Mb.ItemByIdNamespace["MODEL_D", ModelSpace.Key].Edit();
    Model := ModelObj As IMsModel;
    Transf := Model.Transform;
    Formula := Transf.FormulaItem[0];
    Determ := Formula.Method As IMsDeterministicTransform;
    TransVar := Transf.Inputs.Item[0];
    Slice := TransVar.Slices.Item[0];
    InputTerm := Transf.CreateTermInfo();
    InputTerm.Slice := Slice;
    TransVar := Transf.Inputs.Item[1];
    Slice := TransVar.Slices.Item[0];
    PatternTerm := Transf.CreateTermInfo();
    Slice.Level := DimCalendarLevel.dclQuarter;
    PatternTerm.Slice := Slice;
    Expr := Determ.Expression;
    Expr.References := "Ms";
    Expr.AsString := "InterpolateP(" + InputTerm.TermInnerText + ",MsFrequency.Quarterly," +
        PatternTerm.TermInnerText + ",MsPatternType.First,SetPeriod(" +
        """" + "01.01.2000" + """" + "," + """" + "01.01.2015" + """" + "))";
    If Expr.Valid
        Then ModelObj.Save();
        Else System.Diagnostics.Debug.WriteLine("Model is not saved: error in equation");
    End If;
End Sub;

Example of Use in Expressions

Expression 1:

InterpolateP({Brazil|BCA[t]},MsFrequency.Quarterly,{China|BCA[t]})

Result: the Brazil|BCA series data will be disaggregated to quarter frequency by template set by the China|BCA series for the entire time period.

Use: it can be used in formulas of calculated series of time series database and in formulas of attribute-based models of modeling container.

Expression 2:

InterpolateP(X1,MsFrequency.Monthly,X2,MsPatternType.Last, SetPeriod("01.01.2000","01.01.2015"))

Result: the X1 factor data will be disaggregated to monthly frequency by the last template element set by the X2 factor for the period from 2000 to 2015.

Use: it can be used in model variable-based formulas of modeling container.

See also:

IModelling | Interpolation Methods | Time Series Database: Calculator, Interpolation   Modeling Container: The Interpolation Model, Editing Regressor or Formula