/// <summary>
        ///   Creates a new GeneralizedLinearRegression that is a copy of the current instance.
        /// </summary>
        ///
        public object Clone()
        {
            ILinkFunction function = (ILinkFunction)linkFunction.Clone();

            var regression = new GeneralizedLinearRegression(function, coefficients.Length);

            regression.coefficients   = (double[])this.coefficients.Clone();
            regression.standardErrors = (double[])this.standardErrors.Clone();

            return(regression);
        }
        /// <summary>
        ///   The likelihood ratio test of the overall model, also called the model chi-square test.
        /// </summary>
        ///
        /// <param name="input">A set of input data.</param>
        /// <param name="output">A set of output data.</param>
        ///
        /// <remarks>
        ///   <para>
        ///   The Chi-square test, also called the likelihood ratio test or the log-likelihood test
        ///   is based on the deviance of the model (-2*log-likelihood). The log-likelihood ratio test
        ///   indicates whether there is evidence of the need to move from a simpler model to a more
        ///   complicated one (where the simpler model is nested within the complicated one).</para>
        ///   <para>
        ///   The difference between the log-likelihood ratios for the researcher's model and a
        ///   simpler model is often called the "model chi-square".</para>
        /// </remarks>
        ///
        public ChiSquareTest ChiSquare(double[][] input, double[] output)
        {
            double y0 = 0;
            double y1 = 0;

            for (int i = 0; i < output.Length; i++)
            {
                y0 += 1.0 - output[i];
                y1 += output[i];
            }

            var intercept  = Math.Log(y1 / y0);
            var regression = new GeneralizedLinearRegression(linkFunction, Inputs, intercept);

            double ratio = GetLogLikelihoodRatio(input, output, regression);

            return(new ChiSquareTest(ratio, coefficients.Length - 1));
        }
 /// <summary>
 ///   Gets the Log-Likelihood Ratio between two models.
 /// </summary>
 ///
 /// <remarks>
 ///   The Log-Likelihood ratio is defined as 2*(LL - LL0).
 /// </remarks>
 ///
 /// <param name="input">A set of input data.</param>
 /// <param name="output">A set of output data.</param>
 /// <param name="weights">The weights associated with each input vector.</param>
 /// <param name="regression">Another Logistic Regression model.</param>
 ///
 /// <returns>The Log-Likelihood ratio (a measure of performance
 /// between two models) calculated over the given data sets.</returns>
 ///
 public double GetLogLikelihoodRatio(double[][] input, double[] output, double[] weights, GeneralizedLinearRegression regression)
 {
     return(2.0 * (this.GetLogLikelihood(input, output, weights) - regression.GetLogLikelihood(input, output, weights)));
 }