Hello,

The following script allows for Weibull plots using R. 

Its output is similar to the output of the wblplot function (or weibplot 
function) in MATLAB.

As opposed to the previously mentioned function it does not require proprietary 
software. Instead, it is based on R.

My code also allows for a graphical visualization of  weibull fitted data. In 
particular, data can be represented by a straight line in a so-called Weibull 
plot. According to my observations this is the most common way of analyzing 
Weibull distributed data (e.g. time to breakdown values, tensile strength 
values, metal fatigue). 

Here comes my code:

# data 4 wbl plot

data<-c(10,25,35,90,175)

confidence_level=.95

jpeg()

library(survival)

# time to breakdown values

res<-survreg(Surv(data) ~ 1,dist='weibull')

# scale parameter:

eta=exp(res$coefficient)

# shape parameter:

beta=1/res$scale

# plot stuff

n=length(data)

plot(data,log(-log(1-ppoints(n,a=.5))),log="x",axes=FALSE,frame.plot=TRUE,xlab="data",ylab="probability")
 

# Let the confidence interval code below plot the regression curve

# curve(log(-log(exp(-(x/eta)^beta))),log="x",add=TRUE) 

# annotate the graph

ticklabels=c(.1,.3,.63,.9) 

ticksat=log(-log(1-ticksatlog)) 

axis(2,at=ticksat,labels=ticklabels) 

axis(1) 

grid()

# plot 95% confidence intervals

x<-data

out=lm(log(-log(1-ppoints(n,a=.5)))~log(x))

curve(predict(out,newdata=data.frame(x=x)),add=TRUE)

curve(predict(out,newdata=data.frame(x=x),level=confidence_level,interval="confidence")[,"lwr"],add=TRUE)

curve(predict(out,newdata=data.frame(x=x),level=confidence_level,interval="confidence")[,"upr"],add=TRUE)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to