1\name{QTECox}
2\alias{QTECox}
3\title{Function to obtain QTE from a Cox model}
4\description{Computes quantile treatment effects comparable to those of
5crq model from a coxph object.}
6\usage{
7QTECox(x, smooth = TRUE)
8}
9\arguments{
10  \item{x}{An object of class coxph produced by \code{coxph}.}
11  \item{smooth}{Logical indicator if TRUE (default)
12	then Cox survival function is smoothed.}
13}
14\details{ Estimates of the Cox QTE, \eqn{\frac{dQ(t|x)}{dx_{j}}}{(d/dx_j) Q( t | x ) }
15          at \eqn{x=\bar{x}}{x=xbar}, can be expressed as a function of t as follows:
16
17\deqn{\frac{dQ(t|x)}{dx_{j}}=\frac{dt}{dx_{j}}\frac{dQ(t|x)}{dt}}{
18(d/dx_j) Q( t | x ) = (d/dx_j)t * (d/dt) Q(t | x)}
19
20The Cox survival function, \eqn{S(y|x)=\exp \{-H_{0}(y)\exp (b^{\prime
21}x)\}}{S( y | x ) = exp{ - H_o(y) exp(b'x) }}
22
23\deqn{\frac{dS(y|x)}{dx_{j}}=S(y|x)log \{S(y|x)\}b_{j}}{(d/dx_j)
24S( y | x ) = S( y | x ) log(S( y | x )) b_j}
25
26
27where \eqn{\frac{dQ(t|x)}{dx_{j}}}{ (d/dt) Q(t | x) }
28can be estimated by \eqn{\frac{\Delta (t)}{\Delta (S)}
29(1-t)}{- (diff(t)/diff(S) (1-t)}
30where $S$  and $t$ denote the \code{surv} and \code{time} components
31of the  \code{survfit} object.
32Note that since \eqn{t=1-S(y|x)}{t = 1 - S( y | x )}, the above is the
33value corresponding to the argument $(1-t)$; and furthermore
34
35\deqn{\frac{dt}{dx_{j}}=-\frac{dS(y|x)}{dx_{j}}=-(1-t) log (1-t)b_{j}}{
36   (d/dx_j)t = - (d/dx_j) S( y | x ) =  - (1-t) log(1-t) b_j}
37
38Thus the QTE at the mean of x's is:
39
40\deqn{(1-S)= \frac{\Delta (t)}{\Delta (S)}S ~log
41(S)b_{j}}{(1 - S) = (diff(t)/diff(S) S log(S) b_j}
42
43
44Since \eqn{\Delta S}{diff(S)} is negative and $log (S)$ is also negative
45this has the same sign as \eqn{b_{j}}
46The crq  model fits the usual AFT form  Surv(log(Time),Status), then
47
48\deqn{\frac{d log (Q(t|x))}{dx_{j}}=\frac{dQ(t|x)}{dx_{j}}/
49Q(t|x)}{(d/dx_j) log(Q( t | x )) = (d/dx_j) Q( t | x ) / Q( t | x )}
50
51This is the matrix form returned.
52}
53
54\value{
55  \item{taus }{points of evaluation of the QTE.}
56  \item{QTE}{matrix of QTEs, the ith column contains the QTE for the
57	ith covariate effect.  Note that there is no intercept effect.
58	see \code{plot.summary.crqs} for usage.}
59}
60
61\references{Koenker, R. and Geling, O. (2001). Reappraising Medfly
62longevity: a quantile regression survival analysis, J. Amer. Statist.
63Assoc., 96, 458-468}
64
65\author{Roger Koenker Stephen Portnoy & Tereza Neocleous}
66\seealso{\code{\link{crq}}}
67
68\keyword{survival}
69