[R] Censoring data

Terry Therneau therneau at mayo.edu
Mon Apr 16 15:10:22 CEST 2012


On 04/14/2012 05:00 AM, r-help-request at r-project.org wrote:
> Hello,
> ?I want to estimate weibull parameters with 30% censored data. I have below the code for the censoring
> ?but how it must be put into the likelihood equation to obtain the desire estimate is where i have a problem with,
> ?can some body help?
> ?My likelihood equation is for a random type-I censoring where time for the censored units is different for each unit.
> ?
> n=50;r=35
> p=0.8;b=1.5
> t<-rweibull(50,shape=p,scale=b)
> meantrue<-gamma(1+(1/p))*b
> meantrue
> d<-meantrue/0.30
>
> cen<- runif(50,min=0,max=d)
> cen
> s<-ifelse(t<=cen,1,0)
> s
Use the survreg function in the 'survival' package to get the 
estimates,  It uses a location-scale parameterization, read the examples 
in the manual page, help('survreg'), to see the transformation to and 
from the form used by rweibull.

Terry T.



More information about the R-help mailing list