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;
Interpolate(Input: Prognoz.Platform.Interop.Ms.ITimeSeries;
Method: Prognoz.Platform.Interop.Ms.MsInterpolateType;
TargetFrequency: Prognoz.Platform.Interop.Ms.MsFrequency;
Power: Integer;
Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext;
Period: Prognoz.Platform.Interop.Ms.IMsPeriod;
MissingData: Prognoz.Platform.Interop.Stat.MissingDataMethod;
NumberOfPoints: integer;
SpecifiedValue: double;
AdditionalSeries: Prognoz.Platform.Interop.Ms.ITimeSeries]): 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. If the parameter is set to Null, the method is calculated at the entire time period.
Context. Context. The parameter is used only in Fore.NET.
MissingData. Missing data treatment method.
NumberOfPoints. Additional parameter for missing data treatment method. It 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.
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.
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 calculated by the method of determinate equation and contains at least one factor.
Add links to the Metabase, 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 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 girst model factor
TransVar := Transf.Inputs.Item(0);
// Get slice that corresponds to factor
Slice := TransVar.Slices.Item(0);
// Create 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: formula error");
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
TransVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
TermInfo: IMsFormulaTermInfo;
Expr: IExpression;
Begin
// Get current repository
Mb := Params.Metabase;
// 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 first model factor
TransVar := Transf.Inputs.Item[0];
// Get slice that corresponds to factor
Slice := TransVar.Slices.Item[0];
// Create 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 System.Diagnostics.Debug.WriteLine("Model is not saved: formula error");
End If;
End Sub;
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 calculated series of time series database and in formulas of attribute-based models of modeling container.
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 whole period by linear interpolation method with the use of missing data treatment by the Linear Trend method.
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