Re: [R] [Fwd: R2WinBUGS: Comparison to WinBUGS]

From: Sibylle Sturtz <sturtz_at_statistik.uni-dortmund.de>
Date: Wed 28 Sep 2005 - 18:14:46 EST

This is due to the following:

In bugs(), the default for thinning is

n.thin = max(1, floor(n.chains * (n.iter - n.burnin)/1000))

which is 29 for n.iter=12000 and n.burnin=2001 as in your example. Therefore, the number of iterations used for calculation of posterior values is

(12000-2001)/29 = 344.7931

which corresponds to the number of iterations given in your plot. If you specify the thinning parameter directly in bugs() it should be fine.

Sibylle

> -------- Original Message --------
> Subject: [R] R2WinBUGS: Comparison to WinBUGS
> Date: Wed, 28 Sep 2005 03:55:08 -0400
> From: Hadassa Brunschwig <h.brunschwig@utoronto.ca>
> To: r-help@stat.math.ethz.ch
>
> Hi R-Help!
>
>
> I used R2WinBUGS and WinBUGS directly on the same model just to compare. It
> seems I am still making a mistake: after running the function bugs() I
> tried to
> plot the posteriors of the parameters by using read.bugs() to convert
> the output
> to an mcmc object and then plot.mcmc() to plot the densities. Using the
> same
> model, the same number of iterations, the same initial values and the
> same data
> I get completely different plots for the densities (e.g. the range of one
> parameter in R2WinBUGS is from 0 to 8 but in WinBUGS only from 1.5 to
> 3)??? That
> means my results are different, too.
> Also, on the plot it says N=345 which is not what I specified in the bugs()
> function (I specified 12000 iterations).
> Below I put some of the code I used (if that helps):
>
> parameters <-
> c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop","st90.pop80")
>
> inits <- inits <- function(){
> list(tau = rep(1, 17),tau.cpop = 0.2, tau.stpop = 1)
> }
>
> mcmcA <-
> bugs(dataA,inits,parameters,modelA,n.chains=3,debug=T,n.iter=12000,n.burnin=2001,
>
> bugs.directory="c:/Program
> Files/WinBUGS14",working.directory="C:/Documents and
> Settings/Daikon/Roche/R2WinBUGS Output",codaPkg=T)
>
> codaA1 <- read.bugs(mcmcA[1])
> plot(codaA1)
>
>
> THANKS A LOT!!

-- 
Dipl.-Stat. Sibylle Sturtz
Mathematische Statistik und biometrische Anwendungen
Fachbereich Statistik
Universitšt Dortmund
44221 Dortmund
Tel.: 0231/755 4391
FAX : 0231/755 5303

______________________________________________
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
Received on Wed Sep 28 18:17:48 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:26 EST