BinaryDistr: BinaryDistrType;
The BinaryDistr property determines a binary regression model.
The property is set to BinaryDistrType.Logit by default. The Logit-model is used, that is, the logistic normal distribution is considered.
Executing the example requires that the repository contains 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;
BinaryRegr.ConstantValue := 0.4;
// Specify type of values loaded 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 options 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.
See also: