/// <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="time">The time-to-event before the output occurs.</param> /// <param name="output">The corresponding 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[] time, SurvivalOutcome[] output) { ProportionalHazards regression = new ProportionalHazards(Inputs); double ratio = GetLogLikelihoodRatio(input, time, output, regression); return(new ChiSquareTest(ratio, Coefficients.Length)); }
/// <summary> /// Creates a new Cox's Proportional Hazards that is a copy of the current instance. /// </summary> /// public object Clone() { var regression = new ProportionalHazards(Coefficients.Length); regression.Coefficients = (double[])this.Coefficients.Clone(); regression.StandardErrors = (double[])this.StandardErrors.Clone(); regression.Offsets = (double[])this.Offsets.Clone(); return(regression); }
/// <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="time">The time-to-event before the output occurs.</param> /// <param name="output">The corresponding output data.</param> /// <param name="hazards">Another Cox Proportional Hazards 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[] time, SurvivalOutcome[] output, ProportionalHazards hazards) { return(2.0 * (this.GetPartialLogLikelihood(input, time, output) - hazards.GetPartialLogLikelihood(input, time, output))); }