Interpolate(Input: ITimeSeries;
Method: MsInterpolateType;
TargetFrequency: MsFrequency;
[Power: Integer = 3;]
[Period: IMsPeriod = Null;]
[MissingData: MissingDataMethod =16;]
[NumberOfPoints: Integer = 1;]
[SpecifiedValue: Double = 0;]
[AdditionalSeries: ITimeSeries = Null]): Variant;
Input. Input variable.
Method. Interpolation method.
TargetFrequency. Output frequency.
Power. Polynomial degree. The parameter is used at polynomial interpolation.
Period. Period, at which the method is calculated.
MissingData. Missing data treatment method.
NumberOfPoints. Additional parameter for missing data treatment method
SpecifiedValue. The value, with which missing data is substituted by the MissingDataMethod.SpecifiedValue Value method.
AdditionalSeries. The series that is used to substitute missing data by the MissingDataMethod.Pattern Pattern and MissingDataMethod.Overlay Overlay methods.
The Interpolate method interpolates variable values.
Features of setting parameters:
Period. If the parameter is set to Null, the method is calculated at the entire time period.
NumberOfPoints. The parameter can take only positive values. It is used for the following methods of missing data treatment:
MissingDataMethod.NPointsAverage. N-Point Average. The parameter determines the number of neighbor points.
PreviousGrowthRate, SucceedingGrowthRate. Previous Growth Rate, Succeeding Growth Rate. The parameter determines the number of periods.
Use the IModelling.InterpolateP method for pattern interpolation.
On data interpolation the following calendar frequency settings are taken into account: start period offset relative to its start/end.
Example of data interpolation from weekly to daily frequency
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 and annual frequency that is calculated by the determinate equation method and contains at least one factor.
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;
Expr: IExpression;
Begin
// Get the current 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 parameters
Transf := Model.Transform;
// Get model calculation method
Formula := Transf.FormulaItem(0);
Determ := Formula.Method As IMsDeterministicTransform;
// Get the first model factor
TransVar := Transf.Inputs.Item(0);
// Get slice corresponding to factor
Slice := TransVar.Slices.Item(0);
// Create a term based on the first factor
TermInfo := Transf.CreateTermInfo;
TermInfo.Slice := Slice;
// Get model calculation expression
Expr := Determ.Expression;
// Set model calculation expression
Expr.AsString := "Interpolate(" + TermInfo.TermInnerText + ", MsInterpolateType.Polynomial, " +
"MsFrequency.Quarterly, 3, Null, MissingDataMethod.NPointsAverage, 5)";
// Check expression correctness
If Expr.Valid
// If expression is correct, save changes
Then ModelObj.Save;
// If expression is not correct, display message in the console window
Else Debug.WriteLine("Model is not saved: error in formula");
End If;
End Sub UserProc;
After executing the example the model will disaggregate data of the first input variable from annual frequency to quarterly for the entire period using missing data treatment with the N-Point Average method where N = 5.
Expression 1:
Interpolate({Brazil|BCA}, MsInterpolateType.Polynomial, MsFrequency.Quarterly, 3, SetPeriod("01.01.2000", "01.01.2015"), MissingDataMethod.NPointsAverage, 5)
Result: data of the Brazil|BCA series is disaggregated for quarterly frequency at the period 2000-2015. Polynomial interpolation of the third order is used with missing data treatment by the N-Point Average method where N = 5.
Use: it can be used in formulas of cross functional expression editor in any platform tool where it is available.
Expression 2:
Interpolate(X1, MsInterpolateType.Linear, MsFrequency.Quarterly, 3, Null, MissingDataMethod.LinTrend)
Result: data of the X1 factor is disaggregated for quarterly frequency at the entire period by linear interpolation method with the use of missing data treatment by the Linear Trend method.
Use: it can be used in model formulas of modeling container based on variables.
See also:
IModelling | Interpolation Methods | Time Series Database: Calculator, Interpolation Modeling Container: The InterpolationModel, Editing Regressor or Formula