r - Fiting Weibull using R2OpenBUGS -
because estimation of parameters of weibull function using r2openbugs different amounts provided generate data set using rweibull? what's wrong 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 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 , dic = 1147.0
r parameterizes weibull using shape
(=2 in case) , scale
(=10) default: bugs uses shape
, lambda
, lambda=(1/scale)^shape
. should expect lambda
approximately (1/10)^2=0.01, close median of 0.0093.
this question on crossvalidated, , this paper in r journal, compare parameterizations.
Comments
Post a Comment