help for pwexp

piecewise exponential

pwexp
varname x
[if exp] [in range]
,
generate(varname y)
timepoints(numlist)
survivalpoints(numlist) or hazardpoints(numlist)
[
ftype(pdf , cdf , inv , lmd or lambda)
rhr(number) replace
]

Description

pwexp piecewise exponential distribution function defined by the time change(s) and end points listed in
time(numlist) with the corresponding survival values of survival(numlist)
or the failure rates of hazard(numlist).
These together define the implied failure rate or survival of each defined time interval.

Options

rhr() Relative hazard ratio of the survival. This is equal to one, by default.

One of the following function types:

ftype(pdf) The default, Calculates pdf: the survival, y, as a function of time, x.

ftype(cdf) Calculates cdf: the cumulative survival, y, as a function of time, x.

ftype(inv) Calculates inv: the inverse or time, y, as a function of survival, x.

ftype(lmd or lambda) Calculates the failure rate lambda, y, as a function of time, x.

Returned matrix

r(itimeS) This is a matrix containing the defined number, time, and survival or hazard defined by the time change(s), end points, and survival or hazard values input, for verification.

Examples

. clear

. set obs 1025

. gen time=((_n-1)/1024)*8

.

. local tlistA `"0 1(1)4 9"'

. local slistA `"1 .8 .6 .4 .2 0.02"'

. local hlistA `"0 .22314 .28768 .40547 .69314 .46052"'

.

. pwexp time , gen(S0h) time(`tlistA') haz(`hlistA') replace

. matrix list r(itimeS)

.

. pwexp time , gen(S0) time(`tlistA') sur(`slistA')

. matrix list r(itimeS)

.

. pwexp time , gen(lamda0) f(lmd) time(`tlistA') sur(`slistA')

. pwexp time , gen(S1) rhr(`=2/3') time(`tlistA') sur(`slistA')

. pwexp time , gen(lamda1) f(lambda) rhr(`=2/3') time(`tlistA') sur(`slistA') replace

.

. twoway ///

. (line S0 time, sort lcolor(teal)) ///

. (line S1 time, sort lcolor(green)) ///

. (scatter lamda0 time, sort yaxis(2) msymbol(o) msize(vtiny) mcolor(teal%100) ) ///

. (scatter lamda1 time, sort yaxis(2) msymbol(o) msize(vtiny) mcolor(green%100) ), ///

. yscale(range(0 1)) ylabel(0(.2)1) ytitle(probabilty) ytitle(lambda, axis(2)) xscale(range(0 5)) legend(off)

.

. gsort lamda0 time

. by lamda0: keep if inlist(_n,1,_N)

. gsort time

. list , clean noobs

Author

Allen Buxton

abuxton@childrensoncologygroup.org