Library: | hazreg |
See also: | hazdat hazregll hazbeta |
Quantlet: | haztest | |
Description: | calculates the value of the test statistic, the degree of freedom, and the P-value for the likelihood ratio test, Wald's test and the score test for Cox's Proportional Hazards model. |
Usage: | {testt, val, df, pval} = haztest(data, index) | |
Input: | ||
data | n x (p+4) matrix, the first column is the sorted survival time t, followed by the sorted delta, inidcating if censoring has occured, labels l, a column containing the number of ties, and lastly, the sorted covariate matrix z. | |
index | p x 1 vector, with ith element = 0 when beta[i] = 0 is in the null hypothesis, and 1, otherwise. | |
Output: | ||
testt | a table with values of the test statistics, degrees of freedom, and p-values for the likelihood ratio test, Wald's test and the score test. | |
val | 3 x 1 vector, values of the test statistics. | |
df | scalar, degree of freedom. | |
pval | 3 x 1 vector, P-values of the tests. |
library("hazreg") n = 20 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 {data,ties} = hazdat(t,delta, z) ; preparing data index = 1|0 ; testing whether the second ; coefficient is zero {testt, val, df, pval} = haztest(data, index) testt ; test results
The second parameter of beta is tested to be zero or not by likelihood ratio, Wald's and score tests.