Fiting Weibull using R2OpenBUGS

Because the estimation of the parameters of the Weibull function using R2OpenBUGS is so different from the amounts provided to generate the data set using rweibull? What's wrong with my fit?

data<-rweibull(200, 2, 10) model<-function(){ v ~ dgamma(0.0001,0.0001) lambda ~ dgamma(0.0001,0.0001) for(i in 1:n){ y[i] ~ dweib(v, lambda) } } y<-data n<-length(y) data<-list("y", "n") inits<-function(){list(v=1, lambda=1)} params<-c("v", "lambda") model.file<-file.path(tempdir(), "model.txt") write.model(model, model.file) weibull<-bugs(data, inits, params, model.file, n.iter = 3000, n.burnin = 2000, n.chains = 3) print(weibull, 4)

The result obtained is:

Current: 3 chains, each with 3000 iterations (first 2000 discarded) Cumulative: n.sims = 3000 iterations saved mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff v 2.0484 0.1044 1.8450 1.9780 2.0500 2.1180 2.2470 1.0062 780 lambda 0.0097 0.0026 0.0056 0.0078 0.0093 0.0112 0.0159 1.0063 830 deviance 1145.6853 1.8403 1144.0000 1144.0000 1145.0000 1146.0000 1151.0000 1.0047 770 pD = 1.6 and DIC = 1147.0

-------------Problems Reply------------

R parameterizes the Weibull using shape (=2 in your case) and scale (=10) by default: BUGS uses shape and lambda, where lambda=(1/scale)^shape. So you should expect lambda to be approximately (1/10)^2=0.01, which is close to your median of 0.0093.

This question on CrossValidated, and this paper in the R Journal, compare parameterizations.

Category:r Views:1 Time:2018-03-11
Tags: weibull

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.117 (s). 11 q(s)