[R] R-Help: Censoring data

Christopher Kelvin chris_kelvin2001 at yahoo.com
Fri Apr 13 12:54:43 CEST 2012


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

z<-function(p){ 
shape<-p[1]
scale<-p[2]
log1<-(r*log(p[1])-r*(p[1])*log(p[2])+(p[1]-1)*sum(log(t))-sum((t/(p[2]))^(p[1])
)-((n-r)*(sum(cen)/(p[2]))^(p[1])))
return(-log1)
}

start <- c(1,1)
zz<-optim(start,fn=z,hessian=T)
zz

Thanks in anticipation

Chris Guure
Researcher
Institute for Mathematical Research
UPM



More information about the R-help mailing list