BinaryDistr: BinaryDistrType;
BinaryDistr: Prognoz.Platform.Interop.Stat.BinaryDistrType;
The BinaryDistr property determines a 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 a 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 modeling container key
MsKey := Mb.ItemById("MS").Key;
// Get model calculated by binary regression method
Model := Mb.ItemByIdNamespace("BCHOICE_MODEL", MsKey).Edit As IMsModel;
// Get model calculation parameters
ModelTransform := Model.Transform;
ModelFormula := ModelTransform.FormulaItem(0);
// Get binary regression calculation parameters
BinaryRegr := ModelFormula.Method As IMsBinaryRegressionTransform;
// Set binary regression model
BinaryRegr.BinaryDistr := BinaryDistrType.Probit;
// Set threshold probability value for including objects to the 0 or the 1 group
BinaryRegr.ClassificationCutOff := 0.7;
// Set likelihood 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 constant initial value
BinaryRegr.ConstantInitValue := 0.4;
// Specify type of values unloaded to modeling and forecasting series
BinaryRegr.OutputType := MsBinaryRegressionOutputType.Probability;
// Save model
(Model As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the following model calculation parameters will be changed:
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 output 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 modeling container key
MsKey := Mb.ItemById["MS"].Key;
// Get model calculated by binary regression method
Model := Mb.ItemByIdNamespace["BCHOICE_MODEL", MsKey].Edit() As IMsModel;
// Get model calculation parameters
ModelTransform := Model.Transform;
ModelFormula := ModelTransform.FormulaItem[0];
// Get binary regression calculation parameters
BinaryRegr := ModelFormula.Method As IMsBinaryRegressionTransform;
// Set binary regression model
BinaryRegr.BinaryDistr := BinaryDistrType.bdtProbit;
// Set the threshold probability value for including objects to the 0 or the 1 group
BinaryRegr.ClassificationCutOff := 0.7;
// Set likelihood 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 constant initial value
BinaryRegr.ConstantInitValue := 0.4;
// Specify type of values unloaded to modeling and forecasting series
BinaryRegr.OutputType := MsBinaryRegressionOutputType.mbrotProbability;
// Save model
(Model As IMetabaseObject).Save();
End Sub;
See also: