IModelling.SpliceP

Syntax

SpliceP(Input: ITimeSeries;
       SpliceSeries: ITimeSeries;

        ComparatorBaseSeries: ITimeSeries;

        ComparatorSpliceSeries: ITimeSeries;

        [Direction: MsSpliceDirection = 0]): Variant;

Parameters

Input. Input variable.

SpliceSeries. Spliced variable.

ComparatorBaseSeries. Basic variable for comparison block.

ComparatorSpliceSeries. Spliced variable for the comparison block.

Direction. Splice direction.

Description

The SpliceP method transforms a variable on the basis of spliced variables.

Comments

The Direction parameter is optional for Fore and has a default value: MsSpliceDirection.Both.

The method executes percentage splice. Transformation is executed by the following formula: SpliceSeries / ComparatorSpliceSeries * ComparatorBaseSeries.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier. This container includes a model with the MODEL_D identifier that is calculated by the determinate equation method and contains four input variables.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    ModelSpace, ModelObj: IMetabaseObject;
    Transf: IMsFormulaTransform;
    Formula: IMsFormula;
    Model: IMsModel;
    Determ: IMsDeterministicTransform;
    TransVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    TermInfo: IMsFormulaTermInfo;
    Inp_1, Inp_2, Inp_3, Inp_4: String;
    Expr: IExpression;

Begin
    // Get repository
    Mb := MetabaseClass.Active;
    // Get modeling container
    ModelSpace := Mb.ItemById("MS").Bind;
    // Get model
    ModelObj := Mb.ItemByIdNamespace("MODEL_D", ModelSpace.Key).Edit;
    Model := ModelObj As IMsModel;
    // Get model calculation parameters
    Transf := Model.Transform;
    Formula := Transf.FormulaItem(0);
    Determ := Formula.Method As IMsDeterministicTransform;
    // Get the first input variable
    TransVar := Transf.Inputs.Item(0);
    Slice := TransVar.Slices.Item(0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    // Remember model calculation settings for points of the first input variable
    Inp_1 := TermInfo.TermInnerText;
    // Get the second input variable
    TransVar := Transf.Inputs.Item(1);
    Slice := TransVar.Slices.Item(0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    // Remember model calculation settings for points of the second input variable
    Inp_2 := TermInfo.TermInnerText;
    // Get the third input variable
    TransVar := Transf.Inputs.Item(2);
    Slice := TransVar.Slices.Item(0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    // Remember model calculation settings for points of the third input variable
    Inp_3 := TermInfo.TermInnerText;
    // Get the fourth input variable
    TransVar := Transf.Inputs.Item(3);
    Slice := TransVar.Slices.Item(0);
    TermInfo := Transf.CreateTermInfo;
    TermInfo.Slice := Slice;
    // Set mode of passing variable into calculation
    TermInfo.Type := MsFormulaTermType.Pointwise;
    // Remember model calculation settings for points of the fourth input variable
    Inp_4 := TermInfo.TermInnerText;

    // Get model calculation expression
    Expr := Determ.Expression;
    Expr.References := "Ms";
    // Set model calculation expression
    Expr.AsString := "SpliceP(" + Inp_1 + ", " + Inp_2 + ", " + Inp_3 + ", " + Inp_4 + ")";
    // Check if the expression is correct
    If Expr.Valid
        // If the expression is set correctly, save the model
        Then ModelObj.Save;
        // If expression is not correct, output message to console window
        Else Debug.WriteLine("Model is not saved: error in the formula");
    End If;
End Sub UserProc;

After executing the example the model will transform the first input variable on the basis of spliced variables.

Example of Use in Expressions

Expression 1:

SpliceP({Japan|TX},{Japan|TM},{Japan|NX},{Japan|NM},MsSpliceDirection.Both)

Result: suppose that the Japan|TX factor contains the data from January of 1960 to July of 2005, and Japan|NX and Japan|NM - from February of 1940 to December of 2006. SpliceP calculates the relation of the Japan|NX and Japan|NM factors from February 1940 to December 1959 and from August 2005 to December 2006. Then it applies this ratio to the Japan|TX factor, using Japan|TM as denominator.

Use: it can be used in formulas of cross functional expression editor in any platform tool where it is available.

Expression 2:

SpliceP(X1,X2,X3,X4,MsSpliceDirection.Forward)

Result: suppose that the X1 factor contains the data from January to 1960 to July 2005, and X3 and X4 - from February 2003 to December 2006. SpliceP calculates the relation of the X3 and X4 factors from February 2003 to December 2006. Then it applies this ratio and calculates value of the X1 factor using X2 as a denominator.

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

See also:

IModelling