Forms vectors for fitting a proportional hazards model as a generalized linear model (R.W. Payne).

### Options

`SUBJECTS` = factor |
Subject corresponding to each observation |
---|---|

`TIMES` = factor or variate |
Time of each observation |

`CENSORED` = variate |
Contains the value 1 for censored observations, otherwise 0; if unset it is assumed that there is no censoring |

`RESPONSE` = variate |
Response variate for the generalized linear model |

`OFFSET` = variate |
Offset variate |

`INDEX` = variate |
Mapping variate used to produce the expanded variables |

`NEWSUBJECTS` = factor |
Expanded subjects factor |

`NEWTIMES` = factor or variate |
Expanded times factor |

`NEWOFFSET` = variate |
Offset variate for fitting the proportional hazards model |

### Parameters

`X` = variates or factors |
Lists the x-variables that are to be expanded |
---|---|

`NEWX` = variates or factors |
Identifiers to store the expanded x-variables; if no `NEWX` is specified, the expanded values overwrite the original values of `X` |

### Description

The data for a proportional hazards model consist of a set of subjects observed at one or more times. The final time is usually at the time of death (or failure), otherwise (if the subject survives the trial) the observation is said to be censored. The `CENSORED`

option of `RPHVECTORS`

can be used to specify a variate with an entry for each subject containing one when there is censoring, and zero when there is no censoring. If this is not specified, it is assumed that there is no censoring. The `SUBJECTS`

option can specify a factor to indicate the subject corresponding to each observation; this can be omitted if there is only one observation per subject. The time at which each observation was made must be specified by the `TIMES`

option, in either a factor or a variate.

The proportional hazards model (Cox 1972) can be fitted in Genstat using the `RPHFIT`

procedure. To fit this as a generalized linear model, the vectors in the model must be expanded so that, for each subject, there is a unit for every time interval up to the last one during which the subject was observed. If (as usually happens) the subject was not observed at every cutpoint, the covariates and treatment factors are taken to be constant during the intervals between the times of the observations.

`RPHVECTORS`

is used by `RPHFIT`

to produce these expanded vectors, and is made available as a Library procedure in its own right to allow you to program your own proportional hazards analyses. The variates and factors to be expanded are specified using the `X`

parameter, and the `NEWX`

parameter can specify identifiers for the each expanded variate or factor. If `NEWX`

is not specified, the expanded version will replace the original one. The `INDEX`

option allows the variate of indexes used to produce the expanded vectors from the original ones to be saved. The `NEWTIMES`

option can save an expanded factor indicating the time interval corresponding to each unit of the expanded vectors, and the `NEWSUBJECTS`

option can save an expanded factor indicating the subject corresponding to each of their units. The `RESPONSE`

option saves a variate containing one or zero according to whether or not the relevant subject “responded” (i.e. died or failed) during the time period corresponding to each unit of the expanded vectors.

The generalized linear model also needs an offset variate, containing the log of the exposure time corresponding to each units of the expanded variables. This can be saved using the `NEWOFFSET`

option. This will incorporate any additional offset, which can be specified by the `OFFSET`

option.

Options: `SUBJECTS`

, `TIMES`

, `CENSORED`

, `RESPONSE`

, `OFFSET`

, `INDEX`

, `NEWSUBJECTS`

, `NEWTIMES`

, `NEWOFFSET`

.

Parameters: `X`

, `NEWX`

.

### Method

`RPHVECTORS`

uses the standard Genstat manipulation commands.

### Action with `RESTRICT`

None of the vectors must be restricted, and any restrictions will be cancelled.

### Reference

Cox, D.R. (1972). Regression models and life tables (with discussion). *Journal of the Royal Statistical Society B*, 34, 187-220.

### See also

Procedure: `RPHFIT`

.

Commands for: Survival analysis.

### Example

CAPTION 'RPHVECTORS example',\ 'Data from Gehan (1965, Biometrika, 52, 203-223).';\ STYLE=meta,plain VARIATE [VALUES=1,1,2,2,3,4,4,5,5,8,8,8,8,11,11,12,12,15,17,22,23,\ 6,6,6,6,7,9,10,10,11,13,16,17,19,20,22,23,25,32,32,34,35] Time & [VALUES=24(0),1,0,1,0,1,1,0,0,1,1,1,0,0,1,1,1,1,1] Censor FACTOR [LABELS=!t(control,'6-mercaptopurine'); VALUES=21(1,2)] Treatment FACTOR [LEVELS=42; VALUES=1...42] Subject RPHVECTORS [TIMES=Time; SUBJECTS=Subject; CENSORED=Censor; RESPONSE=Yvar;\ INDEX=Index; NEWTIMES=ExTimes; NEWSUBJECTS=ExSubj]\ Treatment; NEWX=ExTreatment PRINT Yvar,ExSubj,ExTimes,Index,ExTreatment;\ FIELD=4(9),18; DECIMALS=0