Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: hazreg
See also: plothare haresummary xhare

Quantlet: harefit
Description: non-proportional hazards regression using linear splines. Its results are to be interpreted by haresummary and hareplot.

Reference(s):

Usage: z = harefit(data{, delta, covars, ipenalty, maxdim, exclude, include, prophaz, additive, linear, fit})
Input:
data n x 1 vector of observations. Observations may or may not be right censored. All observations should be nonnegative.
delta binary n x 1 vector with the same length as data. Elements of data for which the corresponding element of delta is 0 are assumed to be right censored, elements of data for which the corresponding element of delta is 1 are assumed to be uncensored. If delta is missing, all observations are assumed to be uncensored.
covars n x k matrix of covariates with as many rows as the length of data. May be omitted if there are no covariates.
ipenalty an optional scalar parameter to be used in the AIC criterion. The method chooses the number of knots that minimizes -2*loglikelihood+ipenalty*(dimension). The default is to use ipenalty=log(samplesize) as in BIC.
maxdim a scalar, maximum dimension of splines (default is 6*length(data)^0.2).
exclude an optional m x 2 matrix of combinations to be excluded from interactions. If for example exclude[1,1]=2 and exclude[1,2]=3, no interaction between covariate 2 and 3 is included. 0 represents time. Exclude can be specified only if include is not.
include an optional m x 2 matrix of combinations to be included as interactions. If for example exclude[1,1]=2 and exclude[1,2]=3, interaction term between covariate 2 and 3 is included. 0 represents time. Include can be specified only if exclude is not.
prophaz an optional scalar (default is 0); if non-zero, a proportional hazard model is fitted (instead of non-proportional).
additive an optional scalar (default is 0); if non-zero, an aditive hazard model is fitted, which means that no interaction terms between covariates are included and include and exclude should not be specified.
linear an optional vector indicating for which of the variables no knots should be entered. For example, if linear=c(2,3), no knots for covariates 2 or 3 are entered. 0 represents time.
fit an optional object created by harefit. If a fit is specified, harefit adds basis functions starting with those in the specified fit.
Output:
z.ncov number of covariates
z.ndim number of dimensions of the fitted model
z.fcts ndim x 6 matrix; each row is a basis function; the first element is first covariate involved (0=time); the second element means which knot (0 means constant (time), else linear (covariate)); the third element is second covariate involved (NaN means: this is a function of one variable); the fourth element is knot involved (if the third element is NaN, of no relevance); the fifth element is beta; the sixth element is standard error of beta.
z.knots a matrix of size ncov x v, one row for each dimension. Covariate i has row i+1, time has row 1. First element is the number of knots in this dimension, the other elements are the knots, appended with NaNs to make it a matrix.
z.penalty the parameter used in the AIC criterion
z.max maximum element of data
z.ranges column i gives the range of the i-th covariate
z.logl matrix with two columns. The i-th element of the first column is the loglikelihood of the model of dimension i. The second column indicates whether this model was fitted during the addition stage (1) or during the deletion stage (0).
z.sample sample size

Note:

Example:
library("hazreg")
randomize(111)
n = 500
p = 2
beta = 1|2                      ; regression parameter
z = 1 + uniform(n,p)            ; covariates
y = -log(1-uniform(n))          ; exponential survival
y = y./exp(z*beta)              ; covariate effects
c = 4*uniform(n)                ; uniform censoring
t = min(y~c,2)                  ; censored time
delta =(y<=c)                  ; censoring indicator
fit=harefit(t,delta,z)
haresummary(fit)
plothare(fit,1.1~1.4,"p,s")

Result:
Along with the summary, the estimated distribution and
survival functions are plotted.

Contents of sum

[ 1,] "dim A/D   loglik      AIC         penalty  "
[ 2,] "                                min     max"
[ 3,] "  0 Add  -1.6e-46 -9.2e+102 1.4e+02 1.4e+02"
[ 4,] "  0 Add  5.6e+175 -5.9e-144      42      42"
[ 5,] "  0 Add   9.7e+43 -6.2e-127     1.3     1.3"
[ 6,] "  0 Add -7.3e-252  2.7e-273    0.00"
[ 7,] "                                              "
[ 8,] "the present optimal number of dimensions is 3."
[ 9,] "penalty(AIC) was the default: BIC=log(samplesize): log(500)=6.2"
[10,] "                                                         "
[11,] "  dim1           dim2            beta       SE       Wald"
[12,] "Constant                           0.21      0.32    0.64"
[13,] "Co-2  linear                        1.8      0.16      11"
[14,] "Co-1  linear                          1      0.16     6.5"
Example:
library("hazreg")
randomize(11)
n = 500
p = 2
beta = 1|2                      ; regression parameter
z = 1 + uniform(n,p)            ; covariates
y = -log(1-uniform(n))          ; exponential survival
y = y./exp(1 + z*beta + 5*z[,1].*z[,2])              ; covariate effects
c = 4*uniform(n)                ; uniform censoring
t = min(y~c,2)                  ; censored time
delta =(y<=c)                  ; censoring indicator
fit=harefit(t,delta,z)
haresummary(fit)

Result:
Contents of sum

[ 1,] "dim A/D   loglik      AIC         penalty  "
[ 2,] "                                min     max"
[ 3,] "  0 Add  -3.5e+46   5.3e+83     Inf"
[ 4,] "  0 Add -8.9e-287 -2.1e-212     NaN     NaN"
[ 5,] "  0 Add -8.5e-101   3.1e+11      70      70"
[ 6,] "  0 Add     2e+75  1.2e+224    0.00"
[ 7,] "                                              "
[ 8,] "the present optimal number of dimensions is 4."
[ 9,] "penalty(AIC) was the default: BIC=log(samplesize): log(500)=6.2"
[10,] "                                                         "
[11,] "  dim1           dim2            beta       SE       Wald"
[12,] "Constant                           0.25       1.3    0.19"
[13,] "Co-2  linear                        2.4      0.89     2.7"
[14,] "Co-1  linear                        1.4      0.85     1.7"
[15,] "Co-1  linear   Co-2  linear         4.8      0.58     8.3"



Author: P. Cizek, W. Haerdle, 20010507 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006