Navigate to a folder containing sample data.

Load the sample data.

The first column of the light bulb data has the lifetime (in
hours) of two different types of bulbs. The second column has the
binary variable indicating whether the bulb is fluorescent or incandescent.
0 indicates that the bulb is incandescent, and 1 indicates that it
is fluorescent. The third column contains the censorship information,
where 0 indicates the bulb was observed until failure, and 1 indicates
the bulb was censored.

Fit a Cox proportional hazards model for the lifetime
of the light bulbs, also accounting for censoring. The predictor variable
is the type of bulb.

The estimate of the hazard ratio is *exp*(*b*)
= 112.8646. This means that the hazard for the incandescent bulbs
is 112.86 times the hazard for the fluorescent bulbs.

Navigate to a folder containing sample data.

Load the sample data.

The first column of the data has the lifetime (in hours) of
two types of bulbs. The second column has the binary variable indicating
whether the bulb is fluorescent or incandescent. 1 indicates that
the bulb is fluorescent and 0 indicates that it is incandescent. The
third column contains the censorship information, where 0 indicates
the bulb is observed until failure, and 1 indicates the item (bulb)
is censored.

Fit a Cox proportional hazards model, also accounting
for censoring. The predictor variable is the type of bulb.

Display the default control parameters for the algorithm `coxphfit`

uses
to estimate the coefficients.

ans =
Display: 'off'
MaxFunEvals: 200
MaxIter: 100
TolBnd: 1.0000e-06
TolFun: 1.0000e-08
TolTypeFun: []
TolX: 1.0000e-08
TolTypeX: []
GradObj: []
Jacobian: []
DerivStep: []
FunValCheck: []
Robust: []
RobustWgtFun: []
WgtFun: []
Tune: []
UseParallel: []
UseSubstreams: []
Streams: {}
OutputFcn: []

Save the options under a different name and change how
the results will be displayed and the maximum number of iterations, `Display`

and `MaxIter`

.

Run `coxphfit`

with the new algorithm
parameters.

Successful convergence: Norm of gradient less than OPTIONS.TolFun
b =
4.7262

`coxphfit`

displays a report on the final iteration.
Changing the maximum number of iterations did not affect the coefficient
estimate.

Generate Weibull data depending on predictor `X`

.

The response values are generated from a Weibull distribution
with a shape parameter depending on the predictor variable `X`

and
a scale parameter of 2.

Fit a Cox proportional hazards model.

The coefficient estimate is 0.9409 and the log likelihood value
is –331.1479.

Request the model statistics.

stats =
covb: 0.0158
beta: 0.9409
se: 0.1256
z: 7.4889
p: 6.9462e-14

The covariance matrix of the coefficient estimates, `covb`

,
contains only one value, which is equal to the variance of the coefficient
estimate in this example. The coefficient estimate, `beta`

,
is the same as `b`

and is equal to 0.9409. The standard
error of the coefficient estimate, `se`

, is 0.1256,
which is the square root of the variance 0.0158. The *z*-statistic, `z`

,
is `beta/se`

= 0.9409/0.1256 = 7.4880. The p-value, `p`

,
indicates that the effect of `X`

is significant.

Plot the Cox estimate of the baseline survivor function
together with the known Weibull function.

The fitted model gives a close estimate to the survivor function
of the actual distribution.