| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
b = coxphfit(X,y)
[...] = coxphfit(X,Y,param1,val1,param2,val2,...)
[b,logl,H,stats] = coxphfit(...)
b = coxphfit(X,y) returns a p-by-1 vector b of coefficient estimates for a Cox proportional hazards regression of the responses in y on the predictors in X. X is an n-by-p matrix of p predictors at each of n observations. y is an n-by-1 vector of observed responses.
The phrase h(t)*exp(X*b) models the hazard rate for the distribution of y, where h(t) is a common baseline hazard function. The model does not include a constant term, and X cannot contain a column of 1s.
[...] = coxphfit(X,Y,param1,val1,param2,val2,...) specifies additional parameter name/value pairs chosen from the following:
| Name | Value |
|---|---|
| 'baseline' | The X values at which to compute the baseline hazard. Default is mean(X), so the hazard at X is h(t)*exp((X-mean(X))*b). Enter 0 to compute the baseline relative to 0, so the hazard at X is h(t)*exp(X*b). |
| 'censoring' | A Boolean array of the same size as y that is 1 for observations that are right-censored and 0 for observations that are observed exactly. Default is all observations observed exactly. |
| 'frequency' | An array of the same size as y containing nonnegative integer counts. The jth element of this vector gives the number of times the method observes the jth element of y and the jth row of X. Default is one observation per row of X and y. |
| 'init' | A vector containing initial values for the estimated coefficients b. |
| 'options' | A structure specifying control parameters for the iterative algorithm used to estimate b. A call to statset can create this argument. For parameter names and default values, type statset('coxphfit'). |
[b,logl,H,stats] = coxphfit(...) returns additional results. logl is the log likelihood. H is a two-column matrix containing y values in the first column and the estimated baseline cumulative hazard evaluated at those values in the second column. stats is a structure that contains the fields:
beta — Coefficient estimates (same as b)
se — Standard errors of coefficient estimates b
z — z statistics for b (b divided by standard error)
p — p-values for b
covb — Estimated covariance matrix for b
Generate Weibull data depending on predictor x:
x = 4*rand(100,1); A = 50*exp(-0.5*x); B = 2; y = wblrnd(A,B);
Fit a Cox model :
[b,logL,H,stats] = coxphfit(x,y);
Show the Cox estimate of the baseline survivor function together with the known Weibull function:
stairs(H(:,1),exp(-H(:,2)))
xx = linspace(0,100);
line(xx,1-wblcdf(xx,50*exp(-0.5*mean(x)),B),'color','r')
xlim([0,50])
legend('Survivor Function','Weibull Function')

[1] Cox, D.R., and D. Oakes. Analysis of Survival Data. London: Chapman & Hall, 1984.
[2] Lawless, J. F. Statistical Models and Methods for Lifetime Data. Hoboken, NJ: Wiley-Interscience, 2002.
![]() | CovType property (gmdistribution) | CPrior property (NaiveBayes) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |