Fill(Input: ITimeSeries;
Method: MsFillMethod;
[NumberOfPoints: Integer = 1;]
[SpecifiedValue: Double = 0;]
[AdditionalSeries: ITimeSeries = Null;]
[FillBound: MsFillBoundType = 2;]
[EndsFill: Boolean = false]): Variant;
Input. Output variable.
Method. Missing data treatment method.
NumberOfPoints. An additional parameter for the missing data treatment method, which determines the number of points or periods (depending on the method in use).
SpecifiedValue. Value to substitute missing data.
AdditionalSeries. The variable, which values are used for missing data substitution.
FillBound. Period of missing data substitution.
EndsFill. Missing data substitution on the period border.
The Fill parameter fills empty values of the series using various missing data treatment methods.
Features of setting parameters:
NumberOfPoints. In Fore: optional parameter with the default value set to 1. The parameter can take only positive values. The parameter is relevant for the following missing data treatment methods:
NPointsAverage. N-point average. InterpolateParam determines the N that is the number of neighbor points.
PreviousGrowthRate. SucceedingGrowthRate. Growth rate to previous or succeeding period. InterpolateParam determines the number of periods.
SpecifiedValue. The parameter is used for the Specified Value method. In Fore: optional parameter with the default value set to 0.
AdditionalSeries. The parameter is sued for the Pattern and the Overlay methods. In Fore: optional parameter, variable is not set by default.
FillBound. In Fore: optional parameter, missing data is substituted by default to the end of the forecasting period.
EndsFill. Optional parameter. Available values:
True. Missing data is substituted on period borders.
False. Default value. Missing data is not substituted on period borders.
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 using the determinate equation method and contains at least one input variable.
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
Mb := MetabaseClass.Active;
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);
TermInfo := Transf.CreateTermInfo;
TermInfo.Slice := Slice;
TermInfo.Type := MsFormulaTermType.Pointwise;
Expr := Determ.Expression;
Expr.References := "Ms;Stat";
Expr.AsString := "Fill(" + TermInfo.TermInnerText +
", MsFillMethod.NPointAverage, 4, 0, Null, MsFillBoundType.EndIdentify, True)";
If Expr.Valid
Then ModelObj.Save;
Else Debug.WriteLine(Model is not saved: error in formula);
End If;
End Sub UserProc;
After executing the example the model transforms the first input variable by using the Four Neighbor Points Average method of missing data treatment to the end of the forecasting period with missing data substitution on period border.
Expression 1:
Fill({Brazil|BCA}, MsFillMethod.Pattern, 0, 0, {China|BCA}, MsFillBoundType.EndIdentify)
Result: pattern interpolation using the pattern specified with the China|BCA time series is used to substitute missing data at the sample period for the Brazil|BCA time series.
Use: it can be used in formulas of cross functional expression editor in any platform tool where it is available.
Expression 2:
Fill(X1,MsFillMethod.Value)
Result: the random value from interval [minimum value of the X1 series; maximum value of the X1 series] is used for filling of empty points of the X1 factor.
Use: it can be used in model formulas of modeling container.
See also:
IModelling | Methods of Missing Data Treatment |Time Series Database: Calculator, Methods of Missing Data Treatment Modeling Container: The Missing Data TreatmentModel, Editing Regressor or Formula