Click or drag to resize
Accord.NET (logo)

ProportionalHazardsAnalysis Class

Cox's Proportional Hazards Survival Analysis.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.AnalysisProportionalHazardsAnalysis

Namespace:  Accord.Statistics.Analysis
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class ProportionalHazardsAnalysis : IRegressionAnalysis, 
	IMultivariateAnalysis, IAnalysis, ISupervisedLearning<ProportionalHazards, Tuple<double[], double>, int>
Request Example View Source

The ProportionalHazardsAnalysis type exposes the following members.

Constructors
  NameDescription
Public methodProportionalHazardsAnalysis
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, SurvivalOutcome) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, Int32) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, SurvivalOutcome) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, Int32) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(String, String, String)
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, SurvivalOutcome, String, String, String) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Public methodProportionalHazardsAnalysis(Double, Double, Int32, String, String, String) Obsolete.
Constructs a new Cox's Proportional Hazards Analysis.
Top
Properties
  NameDescription
Public propertyChiSquare
Gets the Chi-Square (Likelihood Ratio) Test for the model.
Public propertyCoefficients
Gets the collection of coefficients of the model.
Public propertyCoefficientValues
Gets the value of each coefficient.
Public propertyConfidences
Gets the 95% Confidence Intervals (C.I.) for each coefficient found in the regression.
Public propertyDeviance
Gets the Deviance of the model.
Public propertyEventName
Gets or sets the name of event occurrence variable in the model.
Public propertyEvents
Gets whether the event of interest happened or not.
Public propertyHazardRatios
Gets the Hazard Ratio for each coefficient found during the proportional hazards.
Public propertyInputNames
Gets or sets the name of the input variables for the model.
Public propertyIterations
Gets or sets the maximum number of iterations to be performed by the regression algorithm. Default is 50.
Public propertyLikelihoodRatioTests
Gets the Likelihood-Ratio Tests for each coefficient.
Public propertyLogLikelihood
Gets the Log-Likelihood for the model.
Public propertyOutputs
Gets the dependent variable value for each of the source input points.
Public propertyRegression
Gets the Proportional Hazards model created and evaluated by this analysis.
Public propertyResult Obsolete.
Gets the resulting probabilities obtained by the logistic regression model.
Public propertySource Obsolete.
Source data used in the analysis.
Public propertyStandardErrors
Gets the Standard Error for each coefficient found during the proportional hazards.
Public propertyTimeName
Gets or sets the name of the output variable for the model.
Public propertyTimeToEvent
Gets the time passed until the event occurred or until the observation was censored.
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
Public propertyTolerance
Gets or sets the difference between two iterations of the regression algorithm when the algorithm should stop. The difference is calculated based on the largest absolute parameter change of the regression. Default is 1e-5.
Public propertyWaldTests
Gets the Wald Tests for each coefficient.
Top
Methods
  NameDescription
Public methodCompute Obsolete.
Computes the Proportional Hazards Analysis.
Public methodCompute(ProportionalHazards) Obsolete.
Computes the Proportional Hazards Analysis for an already computed regression.
Public methodCompute(Double, Int32) Obsolete.
Computes the Proportional Hazards Analysis.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLikelihoodRatio
Gets the Log-Likelihood Ratio between this model and another model.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLearn(TupleDouble, Double, SurvivalOutcome, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(TupleDouble, Double, Int32, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(Double, Double, SurvivalOutcome, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(Double, Double, Int32, Double)
Learns a model that can map the given inputs to the given outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

Proportional hazards models are a class of survival models in statistics. Survival models relate the time that passes before some event occurs to one or more covariates that may be associated with that quantity. In a proportional hazards model, the unique effect of a unit increase in a covariate is multiplicative with respect to the hazard rate.

For example, taking a drug may halve one's hazard rate for a stroke occurring, or, changing the material from which a manufactured component is constructed may double its hazard rate for failure. Other types of survival models such as accelerated failure time models do not exhibit proportional hazards. These models could describe a situation such as a drug that reduces a subject's immediate risk of having a stroke, but where there is no reduction in the hazard rate after one year for subjects who do not have a stroke in the first year of analysis.

This class uses the ProportionalHazards to extract more detailed information about a given problem, such as confidence intervals, hypothesis tests and performance measures.

This class can also be bound to standard controls such as the DataGridView by setting their DataSource property to the analysis' Coefficients property.

Examples
// Consider the following example data, adapted from John C. Pezzullo's
// example for his great Cox's proportional hazards model example in
// JavaScript (http://statpages.org/prophaz2.html). 

// In this data, we have three columns. The first column denotes the
// input variables for the problem. The second column, the survival
// times. And the last one is the output of the experiment (if the
// subject has died [1] or has survived [0]).

double[][] example =
{
    //             input  time censor
    new double[] {   50,    1,    0   },
    new double[] {   70,    2,    1   },
    new double[] {   45,    3,    0   },
    new double[] {   35,    5,    0   },
    new double[] {   62,    7,    1   },
    new double[] {   50,   11,    0   },
    new double[] {   45,    4,    0   },
    new double[] {   57,    6,    0   },
    new double[] {   32,    8,    0   },
    new double[] {   57,    9,    1   },
    new double[] {   60,   10,    1   },
};

// First we will extract the input, times and outputs
double[][] inputs = example.Get(null, 0, 1);
double[] times = example.GetColumn(1);
SurvivalOutcome[] output = example.GetColumn(2).To<SurvivalOutcome[]>();

// Now we can proceed and create the analysis (giving optional variable names)
var cox = new ProportionalHazardsAnalysis(new[] { "input" }, "time", "censor");

// Then compute the analysis, learning a regression in the process:
ProportionalHazards regression = cox.Learn(inputs, times, output);

// Now we can show an analysis summary
// Accord.Controls.DataGridBox.Show(cox.Coefficients);

The resulting table is shown below.

VB
' We can also investigate all parameters individually. For
' example the coefficients values will be available at

Dim coef As Double() = cox.CoefficientValues    ' should be { 0.37704239281490765 }
Dim stde As Double() = cox.StandardErrors       ' should be { 0.25415746361167235 }

' We can also obtain the hazards ratios         
Dim ratios As Double() = cox.HazardRatios       ' should be { 1.4579661153488215 }

' And other information such as the partial
' likelihood, the deviance And also make 
' hypothesis tests on the parameters

Dim partialL = cox.LogLikelihood                ' should be -2.0252666205735466
Dim deviance = cox.Deviance                     ' should be 4.0505332411470931

' Chi-Square for whole model              
Dim chi As ChiSquareTest = cox.ChiSquare        ' should be 7.3570 (p=0.0067)

' Wald tests for individual parameters    
Dim wald As WaldTest = cox.Coefficients(0).Wald ' should be 1.4834 (p=0.1379)


' Finally, we can also use the model to predict
' scores for New observations (without considering time)

Dim y1 = cox.Regression.Probability(New Double() {63}) ' should be 86.138421225296526
Dim y2 = cox.Regression.Probability(New Double() {32}) ' should be 0.00072281400325299814

' Those scores can be interpreted by comparing then
' to 1. If they are greater than one, the odds are
' the patient will Not survive. If the value Is less
' than one, the patient Is likely to survive.

' The first value, y1, gives approximately 86.138,
' while the second value, y2, gives about 0.00072.


' We can also consider instant estimates for a given time
Dim p1 = cox.Regression.Probability(New Double() {63}, 2)  'should be 0.17989138010770425
Dim p2 = cox.Regression.Probability(New Double() {63}, 10) ' should be 15.950244161356357

' Here, p1 Is the score after 2 time instants, with a 
' value of 0.0656. The second value, p2, Is the time
' after 10 time instants, with a value of 6.2907.

' In addition, if we would Like a higher precision when 
' computing very small probabilities using the methods 
' above, we can use the LogLikelihood methods instead

Dim log_y1 = cox.Regression.LogLikelihood(New Double() {63})     ' should be  4.4559555514489091
Dim log_y2 = cox.Regression.LogLikelihood(New Double() {32})     ' should be -7.2323586258132284
Dim log_p1 = cox.Regression.LogLikelihood(New Double() {63}, 2)  ' should be -1.7154020540835324
Dim log_p2 = cox.Regression.LogLikelihood(New Double() {63}, 10) ' should be  2.7694741370357177
// We can also investigate all parameters individually. For
// example the coefficients values will be available at

double[] coef = cox.CoefficientValues;     // should be { 0.37704239281490765 }
double[] stde = cox.StandardErrors;        // should be { 0.25415746361167235 }

// We can also obtain the hazards ratios
double[] ratios = cox.HazardRatios;        // should be { 1.4579661153488215 }

// And other information such as the partial
// likelihood, the deviance and also make 
// hypothesis tests on the parameters

double partialL = cox.LogLikelihood;       // should be -2.0252666205735466
double deviance = cox.Deviance;            // should be 4.0505332411470931

// Chi-Square for whole model              
ChiSquareTest chi = cox.ChiSquare;         // should be 7.3570 (p=0.0067)

// Wald tests for individual parameters
WaldTest wald = cox.Coefficients[0].Wald;  // should be 1.4834 (p=0.1379)


// Finally, we can also use the model to predict
// scores for new observations (without considering time)

double y1 = cox.Regression.Probability(new double[] { 63 }); // should be 86.138421225296526
double y2 = cox.Regression.Probability(new double[] { 32 }); // should be 0.00072281400325299814

// Those scores can be interpreted by comparing then
// to 1. If they are greater than one, the odds are
// the patient will not survive. If the value is less
// than one, the patient is likely to survive.

// The first value, y1, gives approximately 86.138,
// while the second value, y2, gives about 0.00072.


// We can also consider instant estimates for a given time:
double p1 = cox.Regression.Probability(new double[] { 63 }, 2);   // should be 0.17989138010770425
double p2 = cox.Regression.Probability(new double[] { 63 }, 10);  // should be 15.950244161356357

// Here, p1 is the score after 2 time instants, with a 
// value of 0.0656. The second value, p2, is the time
// after 10 time instants, with a value of 6.2907.

// In addition, if we would like a higher precision when 
// computing very small probabilities using the methods 
// above, we can use the LogLikelihood methods instead:

double log_y1 = cox.Regression.LogLikelihood(new double[] { 63 });      // should be  4.4559555514489091
double log_y2 = cox.Regression.LogLikelihood(new double[] { 32 });      // should be -7.2323586258132284
double log_p1 = cox.Regression.LogLikelihood(new double[] { 63 }, 2);   // should be -1.7154020540835324
double log_p2 = cox.Regression.LogLikelihood(new double[] { 63 }, 10);  // should be  2.7694741370357177
See Also