private void initialize(double[][] inputs, double[] outputs) { this.NumberOfInputs = inputs[0].Length; int coefficientCount = NumberOfInputs + 1; // Store data sets this.inputData = inputs; this.outputData = outputs; // Create additional structures this.coefficients = new double[coefficientCount]; this.waldTests = new WaldTest[coefficientCount]; this.standardErrors = new double[coefficientCount]; this.oddsRatios = new double[coefficientCount]; this.confidences = new DoubleRange[coefficientCount]; this.ratioTests = new ChiSquareTest[coefficientCount]; this.outputName = "Output"; this.inputNames = new string[NumberOfInputs]; for (int i = 0; i < inputNames.Length; i++) { inputNames[i] = "Input " + i; } // Create object-oriented structure to represent the analysis var logCoefs = new List <LogisticCoefficient>(coefficientCount); for (int i = 0; i < coefficientCount; i++) { logCoefs.Add(new LogisticCoefficient(this, i)); } this.coefficientCollection = new LogisticCoefficientCollection(logCoefs); }
//--------------------------------------------- #region Constructors /// <summary> /// Constructs a Logistic Regression Analysis. /// </summary> /// /// <param name="inputs">The input data for the analysis.</param> /// <param name="outputs">The output data for the analysis.</param> /// public LogisticRegressionAnalysis(double[][] inputs, double[] outputs) { // Initial argument checking if (inputs == null) { throw new ArgumentNullException("inputs"); } if (outputs == null) { throw new ArgumentNullException("outputs"); } if (inputs.Length != outputs.Length) { throw new ArgumentException("The number of rows in the input array must match the number of given outputs."); } this.inputCount = inputs[0].Length; int coefficientCount = inputCount + 1; // Store data sets this.inputData = inputs; this.outputData = outputs; // Create additional structures this.coefficients = new double[coefficientCount]; this.waldTests = new WaldTest[coefficientCount]; this.standardErrors = new double[coefficientCount]; this.oddsRatios = new double[coefficientCount]; this.confidences = new DoubleRange[coefficientCount]; this.ratioTests = new ChiSquareTest[coefficientCount]; // Start regression using the Null Model this.regression = new LogisticRegression(inputCount); // Create coefficient object collection List <LogisticCoefficient> list = new List <LogisticCoefficient>(coefficientCount); for (int i = 0; i < coefficientCount; i++) { list.Add(new LogisticCoefficient(this, i)); } this.coefficientCollection = new LogisticCoefficientCollection(list); this.source = inputs.ToMatrix(); }