/// <summary>
 ///   Constructs a new Logistic regression model.
 /// </summary>
 ///
 internal StepwiseLogisticRegressionModel(StepwiseLogisticRegressionAnalysis analysis, LogisticRegression regression,
                                          int[] variables, ChiSquareTest test)
 {
     this.Analysis   = analysis;
     this.Regression = regression;
     this.Variables  = variables;
     this.ChiSquare  = test;
 }
        /// <summary>
        ///   Constructs a new Logistic regression model.
        /// </summary>
        ///
        internal StepwiseLogisticRegressionModel(StepwiseLogisticRegressionAnalysis analysis, LogisticRegression regression,
                                                 int[] variables, ChiSquareTest chiSquare, ChiSquareTest[] tests)
        {
            this.Analysis   = analysis;
            this.Regression = regression;

            int coefficientCount = regression.NumberOfInputs + 1;

            this.Inputs               = analysis.Inputs.Get(variables);
            this.ChiSquare            = chiSquare;
            this.LikelihoodRatioTests = tests;
            this.Variables            = variables;
            this.StandardErrors       = new double[coefficientCount];
            this.WaldTests            = new WaldTest[coefficientCount];
            this.CoefficientValues    = new double[coefficientCount];
            this.Confidences          = new DoubleRange[coefficientCount];
            this.OddsRatios           = new double[coefficientCount];

            // Store coefficient information
            for (int i = 0; i < regression.NumberOfInputs + 1; i++)
            {
                this.StandardErrors[i]    = regression.StandardErrors[i];
                this.WaldTests[i]         = regression.GetWaldTest(i);
                this.CoefficientValues[i] = regression.GetCoefficient(i);
                this.Confidences[i]       = regression.GetConfidenceInterval(i);
                this.OddsRatios[i]        = regression.GetOddsRatio(i);
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < Inputs.Length; i++)
            {
                sb.Append(Inputs[i]);
                if (i < Inputs.Length - 1)
                {
                    sb.Append(", ");
                }
            }
            this.Names = sb.ToString();


            var logCoefs = new List <NestedLogisticCoefficient>(coefficientCount);

            for (int i = 0; i < coefficientCount; i++)
            {
                logCoefs.Add(new NestedLogisticCoefficient(this, i));
            }
            this.Coefficients = new NestedLogisticCoefficientCollection(logCoefs);
        }