BinaryDistr: BinaryDistrType;
BinaryDistr: Prognoz.Platform.Interop.Stat.BinaryDistrType;
The BinaryDistr property selects binary regression model.
By default BinaryDistr = BinaryDistrType.Logit. The Logit-model is used, that is the logistic normal distribution is considered.
Executing the example requires a modeling container with the MS identifier containing binary choice model (maximum likelihood estimation) with the BCHOICE_MODEL identifier.
Add links to the Metabase, Ms, Stat system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
MsKey: Integer;
Model: IMsModel;
ModelTransform: IMsFormulaTransform;
ModelFormula: IMsFormula;
BinaryRegr: IMsBinaryRegressionTransform;
Explanatories: IMsCompositeFormulaTermSetList;
i: Integer;
Factor: IMsCompositeFormulaTermSet;
Begin
Mb := MetabaseClass.Active;
// Get modelling container key
MsKey := Mb.ItemById("MS").Key;
// Get the model, calculated by the binary regression method
Model := Mb.ItemByIdNamespace("BCHOICE_MODEL", MsKey).Edit As IMsModel;
// Get model calculation parameters
ModelTransform := Model.Transform;
ModelFormula := ModelTransform.FormulaItem(0);
// Get the binary regression calculation parameters
BinaryRegr := ModelFormula.Method As IMsBinaryRegressionTransform;
// Set the binary regression model
BinaryRegr.BinaryDistr := BinaryDistrType.Probit;
// Set the threshold probability value for labeling the objects as the 0 or the 1 group
BinaryRegr.ClassificationCutOff := 0.7;
// Set the likehood function optimization accuracy
BinaryRegr.Tolerance := 0.00001;
// Set manually initial values of explanatory variables
BinaryRegr.UseDefaultInitValues := False;
Explanatories := BinaryRegr.Explanatories;
For i := 0 To Explanatories.Count - 1 Do
Factor := Explanatories.Item(i);
Factor.InitValue := 0.1;
End For;
// Determine that constant value will be estimated
BinaryRegr.ConstantMode := InterceptMode.AutoEstimate;
// Set manually the constant initial value
BinaryRegr.ConstantInitValue := 0.4;
// Specify the type of the values, downloaded to the modeling and forecasting series
BinaryRegr.OutputType := MsBinaryRegressionOutputType.Probability;
// Save the model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the following parameters of model calculation will be modified:
Model of binary regression is Probit.
Threshold value of probability for dividing into groups is 0.7.
Optimization accuracy of likelihood function is 0.00001.
Initial values of all explanatory variables is 0.1, initial value of the estimated constant is 0.4.
Probability values are saved to the modeled and the forecasting series.
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.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
MsKey: uinteger;
Model: IMsModel;
ModelTransform: IMsFormulaTransform;
ModelFormula: IMsFormula;
BinaryRegr: IMsBinaryRegressionTransform;
Explanatories: IMsCompositeFormulaTermSetList;
i: Integer;
Factor: IMsCompositeFormulaTermSet;
Begin
Mb := Params.Metabase;
// Get modelling container key
MsKey := Mb.ItemById["MS"].Key;
// Get the model, calculated by the binary regression method
Model := Mb.ItemByIdNamespace["BCHOICE_MODEL", MsKey].Edit() As IMsModel;
// Get model calculation parameters
ModelTransform := Model.Transform;
ModelFormula := ModelTransform.FormulaItem[0];
// Get the binary regression calculation parameters
BinaryRegr := ModelFormula.Method As IMsBinaryRegressionTransform;
// Set the binary regression model
BinaryRegr.BinaryDistr := BinaryDistrType.bdtProbit;
// Set the threshold probability value for labeling the objects as the 0 or the 1 group
BinaryRegr.ClassificationCutOff := 0.7;
// Set the likehood function optimization accuracy
BinaryRegr.Tolerance := 0.00001;
// Set manually initial values of explanatory variables
BinaryRegr.UseDefaultInitValues := False;
Explanatories := BinaryRegr.Explanatories;
For i := 0 To Explanatories.Count - 1 Do
Factor := Explanatories.Item[i];
Factor.InitValue := 0.1;
End For;
// Determine that constant value will be estimated
BinaryRegr.ConstantMode := InterceptMode.imAutoEstimate;
// Set manually the constant initial value
BinaryRegr.ConstantInitValue := 0.4;
// Specify the type of the values, downloaded to the modeling and forecasting series
BinaryRegr.OutputType := MsBinaryRegressionOutputType.mbrotProbability;
// Save the model
(Model As IMetabaseObject).Save();
End Sub;
See also: