1\name{svykm}
2\alias{svykm}
3\alias{plot.svykm}
4\alias{plot.svykmlist}
5\alias{lines.svykm}
6\alias{quantile.svykm}
7\alias{confint.svykm}
8%- Also NEED an '\alias' for EACH other topic documented here.
9\title{Estimate survival function. }
10\description{
11Estimates the survival function using a weighted Kaplan-Meier
12estimator.
13}
14\usage{
15svykm(formula, design,se=FALSE, ...)
16\method{plot}{svykm}(x,xlab="time",ylab="Proportion surviving",
17  ylim=c(0,1),ci=NULL,lty=1,...)
18\method{lines}{svykm}(x,xlab="time",type="s",ci=FALSE,lty=1,...)
19\method{plot}{svykmlist}(x, pars=NULL, ci=FALSE,...)
20\method{quantile}{svykm}(x, probs=c(0.75,0.5,0.25),ci=FALSE,level=0.95,...)
21\method{confint}{svykm}(object,parm,level=0.95,...)
22}
23%- maybe also 'usage' for other objects documented here.
24\arguments{
25  \item{formula}{Two-sided formula. The response variable should be a right-censored
26    \code{Surv} object}
27  \item{design}{survey design object}
28  \item{se}{Compute standard errors? This is slow for moderate to large
29    data sets}
30  \item{\dots}{in \code{plot} and \code{lines} methods, graphical
31parameters }
32   \item{x}{a \code{svykm} or \code{svykmlist} object}
33   \item{xlab,ylab,ylim,type}{as for \code{plot}}
34   \item{lty}{Line type, see \code{\link{par}}}
35   \item{ci}{Plot (or return, for\code{quantile}) the confidence interval}
36   \item{pars}{A list of vectors of graphical parameters for the
37     separate curves in a \code{svykmlist} object}
38   \item{object}{A \code{svykm} object}
39   \item{parm}{vector of times to report confidence intervals}
40   \item{level}{confidence level}
41   \item{probs}{survival probabilities for computing survival quantiles
42     (note that these are the complement of the usual
43     \code{\link{quantile}} input, so 0.9 means 90\% surviving, not 90\% dead)}
44}
45\value{
46  For \code{svykm}, an object of class \code{svykm} for a single curve or \code{svykmlist}
47  for multiple curves.
48}
49\details{
50  When standard errors are computed, the survival curve is
51  actually the Aalen (hazard-based) estimator rather than the
52  Kaplan-Meier estimator.
53
54  The standard error computations use memory proportional to the sample
55  size times the square of the number of events. This can be a lot.
56
57  In the case of equal-probability cluster sampling without replacement
58  the computations are essentially the same as those of Williams (1995),
59  and the same linearization strategy is used for other designs.
60
61  Confidence intervals are computed on the log(survival) scale,
62  following the default in \code{survival} package, which was based on
63  simulations by Link(1984).
64
65  Confidence intervals for quantiles use Woodruff's method: the interval
66  is the intersection of the horizontal line at the specified quantile
67  with the pointwise confidence band around the survival curve.
68}
69\references{
70Link, C. L. (1984). Confidence intervals for the survival function using
71Cox's proportional hazards model with covariates. Biometrics 40,
72601-610.
73
74Williams RL (1995) "Product-Limit Survival Functions with Correlated
75Survival Times" Lifetime Data Analysis 1: 171--186
76
77Woodruff RS (1952) Confidence intervals for medians and other
78position measures. JASA 57, 622-627.
79 }
80 \seealso{\code{\link{predict.svycoxph}} for survival curves from a Cox model
81 }
82\examples{
83data(pbc, package="survival")
84pbc$randomized <- with(pbc, !is.na(trt) & trt>0)
85biasmodel<-glm(randomized~age*edema,data=pbc)
86pbc$randprob<-fitted(biasmodel)
87
88dpbc<-svydesign(id=~1, prob=~randprob, strata=~edema, data=subset(pbc,randomized))
89
90s1<-svykm(Surv(time,status>0)~1, design=dpbc)
91s2<-svykm(Surv(time,status>0)~I(bili>6), design=dpbc)
92
93plot(s1)
94plot(s2)
95plot(s2, lwd=2, pars=list(lty=c(1,2),col=c("purple","forestgreen")))
96
97quantile(s1, probs=c(0.9,0.75,0.5,0.25,0.1))
98
99s3<-svykm(Surv(time,status>0)~I(bili>6), design=dpbc,se=TRUE)
100plot(s3[[2]],col="purple")
101
102confint(s3[[2]], parm=365*(1:5))
103quantile(s3[[1]], ci=TRUE)
104
105}
106% Add one or more standard keywords, see file 'KEYWORDS' in the
107% R documentation directory.
108\keyword{survey}
109\keyword{survival}% __ONLY ONE__ keyword per line
110