You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(11) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(24) |
Jun
(15) |
Jul
(5) |
Aug
(21) |
Sep
(85) |
Oct
(9) |
Nov
|
Dec
|
2008 |
Jan
(15) |
Feb
(11) |
Mar
|
Apr
(2) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(29) |
Oct
(47) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
(8) |
Feb
(12) |
Mar
(14) |
Apr
(4) |
May
(1) |
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
(11) |
Nov
(18) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
(24) |
Jun
|
Jul
(1) |
Aug
(7) |
Sep
(5) |
Oct
(3) |
Nov
(4) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
(13) |
Apr
(3) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(24) |
Sep
(3) |
Oct
|
Nov
|
Dec
(29) |
2012 |
Jan
(5) |
Feb
(5) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Uwe L. <li...@st...> - 2008-02-01 09:53:05
|
FYI. I will release the bugfix right now. Uwe -------- Original Message -------- Subject: Re: [R] R2WinBUGS is broken Date: Fri, 01 Feb 2008 10:42:36 +0100 From: Uwe Ligges <li...@st...> Organization: Fakultät Statistik, Technische Universität Dortmund To: John Smith <zm...@gm...> CC: r-...@r-... References: <1a0...@ma...> Dear John, this is a new bug caused by a side effect from a new bugs.log function by Jouni Kerman that improves many other things. I have fixed it in the master sources on sourceforge right now and a bugfix release will appear on CRAN within a couple of days. Best, Uwe Ligges John Smith wrote: > Dear R-users, > > I am trying to use the following code to reproduce results from Prof. > Gelman's book, but have the listed error for R2WinBUGS version (the openbugs > version is good). I am using R-2.6.1 on windows XP, and all the R packages > are most current ones. schools.bug can be found at > http://www.stat.columbia.edu/~gelman/bugsR/runningbugs.html . Can anyone > help me to figure out what's going wrong? > > > rm(list=ls()) > library(R2WinBUGS) > library ('BRugs') > setwd('C:/bayesian/bda/codes/example_5_5') > data(schools) > J <- nrow(schools) > y <- schools$estimate > sigma.y <- schools$sd > data <- list(J=J, y=y, sigma.y=sigma.y) > > inits <- function() > list(theta=rnorm(J,0,100), mu.theta=rnorm(1,0,100), > sigma.theta=runif(1,0,100)) > parameters <- c('theta', 'mu.theta', 'sigma.theta') > schools.sim <- bugs(data, inits, parameters, model.file='schools.bug', > n.chains=3, n.iter=1000, clearWD=TRUE) > ## schools.sim <- bugs(data, inits, parameters, model.file='schools.bug', > ## n.chains=3, n.iter=1000, clearWD=TRUE, > ## program = 'openbugs') > print(schools.sim) > plot(schools.sim) > > > > Error in matrix(unlist(mx), ncol = n.cols, byrow = TRUE) : > invalid 'nrow' value (too large or NA) > > > > Thanks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-...@r-... 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. |
From: <li...@us...> - 2008-02-01 09:42:53
|
Revision: 85 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=85&view=rev Author: ligges Date: 2008-02-01 01:42:28 -0800 (Fri, 01 Feb 2008) Log Message: ----------- bugfix if DIC is not available ... Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/R/bugs.log.R Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2008-01-22 12:27:56 UTC (rev 84) +++ trunk/R2WinBUGS/DESCRIPTION 2008-02-01 09:42:28 UTC (rev 85) @@ -1,7 +1,7 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2008-01-18 -Version: 2.1-7 +Date: 2008-02-01 +Version: 2.1-8 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. Modified: trunk/R2WinBUGS/R/bugs.log.R =================================================================== --- trunk/R2WinBUGS/R/bugs.log.R 2008-01-22 12:27:56 UTC (rev 84) +++ trunk/R2WinBUGS/R/bugs.log.R 2008-02-01 09:42:28 UTC (rev 85) @@ -11,10 +11,11 @@ log.txt <- readLines(file) extract <- function (m, line.match, skip=0, empty.left.col=TRUE) { start <- (skip + which(m == line.match)[1]) - if(is.na(start)) return(NULL) - if(length(start) < 1) return(NULL) + if(is.na(start)) return(NA) + if(length(start) < 1) return(NA) mx <- strsplit(m[-(1:start)], "\t") n.cols <- length(mx[[1]]) + if(n.cols < 1) return(NA) mxlen <- sapply(mx, length) end <- which(mxlen!=n.cols)[1] - 1 mx <- mx[1:end] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-22 12:27:50
|
Revision: 84 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=84&view=rev Author: ligges Date: 2008-01-22 04:27:56 -0800 (Tue, 22 Jan 2008) Log Message: ----------- Add a warning on when to use modelSetSeed Modified Paths: -------------- trunk/BRugs/man/model.seed.Rd Modified: trunk/BRugs/man/model.seed.Rd =================================================================== --- trunk/BRugs/man/model.seed.Rd 2008-01-21 15:50:10 UTC (rev 83) +++ trunk/BRugs/man/model.seed.Rd 2008-01-22 12:27:56 UTC (rev 84) @@ -12,6 +12,7 @@ More than one integer if the chosen random number generator requires more seed components.} \item{i}{indicates which component of the seed should be returned.} } +\details{Warning: \code{modelSetSeed} must not be used before \code{\link{modelCompile}} has been executed successfully!} \seealso{\code{\link{BRugs}}, \code{\link{help.WinBUGS}}} \keyword{interface} \concept{update} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-21 15:50:13
|
Revision: 83 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=83&view=rev Author: ligges Date: 2008-01-21 07:50:10 -0800 (Mon, 21 Jan 2008) Log Message: ----------- moved is.R() check into openbugs.R() Modified Paths: -------------- trunk/R2WinBUGS/R/openbugs.R Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2008-01-18 17:00:00 UTC (rev 82) +++ trunk/R2WinBUGS/R/openbugs.R 2008-01-21 15:50:10 UTC (rev 83) @@ -1,14 +1,14 @@ - -if (is.R()) { - openbugs <- function(data, inits, parameters.to.save, model.file="model.txt", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), n.thin = max(1, floor(n.chains *(n.iter - n.burnin) / n.sims)), n.sims = 1000, DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", working.directory=NULL, digits = 5) { + if(!is.R()) + stop("OpenBUGS is not yet available in S-PLUS") if(!require("BRugs")) stop("BRugs is required") + ## switching from bugs() to BRugsFit() notation modelFile <- model.file numChains <- n.chains @@ -93,5 +93,3 @@ a.stem <- substr(a, 1, ifelse(bracket.pos>0, bracket.pos-1, nchar(a))) a[order(match(a.stem, b))] } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Dawn W. <dwo...@in...> - 2008-01-20 23:32:48
|
Yes, certainly that solution is fine. Thank you! Dawn -----Original Message----- From: Uwe Ligges [mailto:li...@st...]=20 Sent: Saturday, January 19, 2008 1:34 PM To: Dawn Woodard Cc: bug...@li... Subject: [Fwd: Re: R2WinBUGS] R2WinBUGS has not been accepted on CRAN (I should have tested under=20 R-devel before submitting, so partly my fault): Kurt asked me to remove the conditional "if (is.R())" before the=20 definition of the openbugs function, because the codetools are not=20 seeing openbugs() as always defined but we have a documentation object. if (is.R()) { openbugs <- function(data, inits, parameters.to.save,=20 model.file=3D"model.txt", ....... Dawn, I'd propose to remove the "if (is.R())" and move it indide the=20 function so that is simply stop()s when called from S-PLUS. Are you fine = with that solution? Best, Uwe |
From: Uwe L. <li...@st...> - 2008-01-19 18:34:11
|
R2WinBUGS has not been accepted on CRAN (I should have tested under R-devel before submitting, so partly my fault): Kurt asked me to remove the conditional "if (is.R())" before the definition of the openbugs function, because the codetools are not seeing openbugs() as always defined but we have a documentation object. if (is.R()) { openbugs <- function(data, inits, parameters.to.save, model.file="model.txt", ....... Dawn, I'd propose to remove the "if (is.R())" and move it indide the function so that is simply stop()s when called from S-PLUS. Are you fine with that solution? Best, Uwe |
From: Uwe L. <li...@st...> - 2008-01-18 17:02:03
|
Kurt, R2WinBUGS_2.1-7.tar.gz has been released and is on CRAN/incoming. Best wishes, Uwe |
From: <li...@us...> - 2008-01-18 16:59:59
|
Revision: 82 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=82&view=rev Author: ligges Date: 2008-01-18 09:00:00 -0800 (Fri, 18 Jan 2008) Log Message: ----------- - make scan() in openbugs() quiet - add note on option BRugsVerbose - increase date for release Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/R/openbugs.R trunk/R2WinBUGS/man/openbugs.Rd Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2008-01-17 18:24:14 UTC (rev 81) +++ trunk/R2WinBUGS/DESCRIPTION 2008-01-18 17:00:00 UTC (rev 82) @@ -1,6 +1,6 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2008-01-08 +Date: 2008-01-18 Version: 2.1-7 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2008-01-17 18:24:14 UTC (rev 81) +++ trunk/R2WinBUGS/R/openbugs.R 2008-01-18 17:00:00 UTC (rev 82) @@ -7,7 +7,7 @@ DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", working.directory=NULL, digits = 5) { - if(!require(BRugs)) + if(!require("BRugs")) stop("BRugs is required") ## switching from bugs() to BRugsFit() notation modelFile <- model.file @@ -55,7 +55,7 @@ ## set the adaptive phases adaptivelines <- scan(system.file("OpenBUGS", "Bugs", "Rsrc", "Registry.txt", package="BRugs"), - what="character") + what="character", quiet = TRUE) factories <- sub(".adaptivePhase", "", adaptivelines[grep("adaptivePhase",adaptivelines)]) sapply(factories, BRugs::modelSetAP, max(0, nBurnin-1)) Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2008-01-17 18:24:14 UTC (rev 81) +++ trunk/R2WinBUGS/man/openbugs.Rd 2008-01-18 17:00:00 UTC (rev 82) @@ -67,6 +67,11 @@ and Uwe Ligges. } +\note{By default, BRugs (and hence \code{openbugs()}) is quite verbose. + This can be controlled for the whole BRugs package by by the option \sQuote{BRugsVerbose} (see \code{\link{options}}) + which is set to \code{TRUE} by default. +} + \seealso{\code{\link{bugs}} and the \pkg{BRugs} package} \examples{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Uwe L. <li...@st...> - 2008-01-18 12:49:28
|
Welcome in the team, Jouni! Best wishes, Uwe jou...@no... wrote: > Dear Uwe > > I've now registered with Sourceforge now, my username is 'jkerman'. Thanks > for letting me join the team. > > best wishes (& happy new year btw!) > > Jouni > > > > > Uwe Ligges <li...@st...> wrote on 08.01.2008 22:15:01: > >> >> jou...@no... wrote: >>> Dear Uwe >>> >>> Great - thanks a lot! I guess when it's been tested on S-Plus you'll >>> upload it to CRAN? >> Yes. >> >> >>> Yes it would be probably good to become a r2winbugs developer... it > looks >>> like I'll have to use SVN on my computer to submit changes, right ? > There >>> is no simple web access? >> >> Yes, you need a) SVN and b) a sourceforge account. When you tell me the >> sourceforge Account, I'll make you a developer. >> >> >> >>> Jouni >>> >>> PS >>> I do have one interesting function (I call it 'bugsfun') that could be > >>> useful to add to future releases. You specify inits, parameters, and > data >>> within the same R function where the model is included, and then > bugsfun() >>> takes this function, parses it and creates the R code to execute a > bugs() >>> call. It also has 'pre-processor' style directives such as #IF and > #ELSE >>> and #ENDIF to let you include and exclude portions of the model or > the >>> data/inits/params specifications; it's helpful when you want to > experiment >>> with several models that differ only slightly. >> OK, great, so let's include it! >> >> Best wishes, >> Uwe >> >> >>> >>> Uwe Ligges <li...@st...> wrote on 06.01.2008 >>> 19:24:40: >>> >>>> Dear Jouni, >>>> >>>> after a serious delay due to work-overload, I finally found the time > to >>>> incorporate your changes into R2WinBUGS, most of them unchanged. >>>> >>>> So thank you again for your nice code!!! >>>> >>>> I replaced bugs.log() by your function bugs.summary() and tried to >>>> update all the help pages. >>>> >>>> The current version is committed to the repository at: >>>> https://sourceforge.net/projects/bugs-r/ >>>> If you like, we can give you access as a developer. If not, for the > next >>>> time, please send changes as diffs against the sources on the >>>> sourceforge address mentioned above. >>>> >>>> >>>> >>>> Dear Dawn, can you quickly test under S-PLUS, please? I think we > could >>>> release this one pretty soon now. >>>> >>>> Best wishes, >>>> Uwe >>>> >>>> >>>> >>>> >>>> jou...@no... wrote: >>>>> Dear Uwe >>>>> >>>>> I noticed that Sibylle Sturtz is the maintainer of R2WinBUGS so I > sent >>> her >>>>> the following message. I don't know if you're interested any more > but >>>>> maybe you have some comments? >>>>> >>>>> best regards >>>>> >>>>> Jouni Kerman >>>>> >>>>> >>>>> ----------- >>>>> >>>>> I've made some improvements and additions to the R2WinBUGS code to >>> make it >>>>> more flexible. >>>>> >>>>> However I would like to make the changes available for everyone. How > >>> could >>>>> I help you best to get them incorporated in the package? >>>>> >>>>> ---- >>>>> My current code is attached. >>>>> >>>>> I have currently 5 rewritten functions for the package. Most are > just >>>>> small modifications and affect only small parts of the functions. I >>> tried >>>>> not to change too much of the old code just to make it easier to >>> review. >>>>> In summary the additions and changes are: >>>>> >>>>> (In function bugs:) >>>>> - Add bugs.seed parameter and the corresponding bugs script entry to > >>>>> specify random seed in WinBUGS >>>>> - Add summary.only parameter (default FALSE) which prevents > outputting >>> the >>>>> coda and only returns the parameter summary >>>>> - Add save.history parameter (default TRUE) which controls whether > the >>>>> trace plots are generated at end >>>>> - Add n.sims parameter (number of simulations to keep). I often >>> specify >>>>> this and n.iter only. >>>>> - Fix definition of n.thin which assumes output of 1000 simulations >>>>> (divide by n.sims instead) >>>>> - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses > it >>> for >>>>> the R2WinBUGS directory >>>>> - Allow specification of data file that can be named something else >>> than >>>>> data.txt >>>>> - Allow specification of inits file names >>>>> >>>>> I have also rewritten the bugs.log routine so it does not crash if > DIC >>> is >>>>> not specified; it also does not make assumptions about the column >>> names. >>>>> These improvements are all quite useful for us. Especially, > bugs.seed >>> is >>>>> crucial and summary.only helps a lot if one repeats the same > analysis >>> many >>>>> times and only needs some quick summary. >>>>> >>>>> If you agree, I would like to have these changes implemented in the >>> next >>>>> version of R2WinBUGS. >>>>> >>>>> I've tried them out for some time now and there are no known bugs. > I >>> have >>>>> not tried it with openbugs. >>>>> >>>>> Best regards, Mit freundlichen Grüssen, Meilleures salutations, >>>>> Jouni Kerman, Ph.D. >>>>> Novartis Pharma AG >>>>> PH3483, CIS - METHODOLOGY >>>>> CHBS, WSJ-027.3.017 >>>>> Phone: +41 61 324 3600 >>>>> Fax: +41 61 324 3781 >>>>> Email : jou...@no... >>>>> >>>>> > |
From: Uwe L. <li...@st...> - 2008-01-18 08:42:13
|
Dawn Woodard wrote: > I have checked that the latest changes work in S-PLUS 8.0. There was only > one problem, which has now been resolved. The new bugs.seed argument works, > which is great! Thanks for the helpful changes! Great, thanks for the bugfix! Best, Uwe > Dawn > > > > -----Original Message----- > From: bug...@li... > [mailto:bug...@li...] On Behalf Of Uwe Ligges > Sent: Sunday, January 06, 2008 1:25 PM > To: jou...@no... > Cc: bug...@li... > Subject: Re: [Bugs-r-devel] Fw: R2WinBUGS modifications > > Dear Jouni, > > after a serious delay due to work-overload, I finally found the time to > incorporate your changes into R2WinBUGS, most of them unchanged. > > So thank you again for your nice code!!! > > I replaced bugs.log() by your function bugs.summary() and tried to > update all the help pages. > > The current version is committed to the repository at: > https://sourceforge.net/projects/bugs-r/ > If you like, we can give you access as a developer. If not, for the next > time, please send changes as diffs against the sources on the > sourceforge address mentioned above. > > > > Dear Dawn, can you quickly test under S-PLUS, please? I think we could > release this one pretty soon now. > > Best wishes, > Uwe > > > > > jou...@no... wrote: >> Dear Uwe >> >> I noticed that Sibylle Sturtz is the maintainer of R2WinBUGS so I sent her >> the following message. I don't know if you're interested any more but >> maybe you have some comments? >> >> best regards >> >> Jouni Kerman >> >> >> ----------- >> >> I've made some improvements and additions to the R2WinBUGS code to make it >> more flexible. >> >> However I would like to make the changes available for everyone. How could >> I help you best to get them incorporated in the package? >> >> ---- >> My current code is attached. >> >> I have currently 5 rewritten functions for the package. Most are just >> small modifications and affect only small parts of the functions. I tried >> not to change too much of the old code just to make it easier to review. >> >> In summary the additions and changes are: >> >> (In function bugs:) >> - Add bugs.seed parameter and the corresponding bugs script entry to >> specify random seed in WinBUGS >> - Add summary.only parameter (default FALSE) which prevents outputting the >> coda and only returns the parameter summary >> - Add save.history parameter (default TRUE) which controls whether the >> trace plots are generated at end >> - Add n.sims parameter (number of simulations to keep). I often specify >> this and n.iter only. >> - Fix definition of n.thin which assumes output of 1000 simulations >> (divide by n.sims instead) >> - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses it for >> the R2WinBUGS directory >> - Allow specification of data file that can be named something else than >> data.txt >> - Allow specification of inits file names >> >> I have also rewritten the bugs.log routine so it does not crash if DIC is >> not specified; it also does not make assumptions about the column names. >> >> These improvements are all quite useful for us. Especially, bugs.seed is >> crucial and summary.only helps a lot if one repeats the same analysis many >> times and only needs some quick summary. >> >> If you agree, I would like to have these changes implemented in the next >> version of R2WinBUGS. >> >> I've tried them out for some time now and there are no known bugs. I have >> not tried it with openbugs. >> >> Best regards, Mit freundlichen Grüssen, Meilleures salutations, >> Jouni Kerman, Ph.D. >> Novartis Pharma AG >> PH3483, CIS - METHODOLOGY >> CHBS, WSJ-027.3.017 >> Phone: +41 61 324 3600 >> Fax: +41 61 324 3781 >> Email : jou...@no... >> >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Dawn W. <dwo...@in...> - 2008-01-17 18:37:00
|
I have checked that the latest changes work in S-PLUS 8.0. There was = only one problem, which has now been resolved. The new bugs.seed argument = works, which is great! Thanks for the helpful changes! Dawn -----Original Message----- From: bug...@li... [mailto:bug...@li...] On Behalf Of Uwe = Ligges Sent: Sunday, January 06, 2008 1:25 PM To: jou...@no... Cc: bug...@li... Subject: Re: [Bugs-r-devel] Fw: R2WinBUGS modifications Dear Jouni, after a serious delay due to work-overload, I finally found the time to=20 incorporate your changes into R2WinBUGS, most of them unchanged. So thank you again for your nice code!!! I replaced bugs.log() by your function bugs.summary() and tried to=20 update all the help pages. The current version is committed to the repository at: https://sourceforge.net/projects/bugs-r/ If you like, we can give you access as a developer. If not, for the next = time, please send changes as diffs against the sources on the=20 sourceforge address mentioned above. Dear Dawn, can you quickly test under S-PLUS, please? I think we could=20 release this one pretty soon now. Best wishes, Uwe jou...@no... wrote: > Dear Uwe >=20 > I noticed that Sibylle Sturtz is the maintainer of R2WinBUGS so I sent = her=20 > the following message. I don't know if you're interested any more but=20 > maybe you have some comments? >=20 > best regards >=20 > Jouni Kerman >=20 >=20 > ----------- >=20 > I've made some improvements and additions to the R2WinBUGS code to = make it=20 > more flexible.=20 >=20 > However I would like to make the changes available for everyone. How = could=20 > I help you best to get them incorporated in the package?=20 >=20 > ---- > My current code is attached.=20 >=20 > I have currently 5 rewritten functions for the package. Most are just=20 > small modifications and affect only small parts of the functions. I = tried=20 > not to change too much of the old code just to make it easier to = review.=20 >=20 > In summary the additions and changes are: >=20 > (In function bugs:) > - Add bugs.seed parameter and the corresponding bugs script entry to=20 > specify random seed in WinBUGS > - Add summary.only parameter (default FALSE) which prevents outputting = the=20 > coda and only returns the parameter summary > - Add save.history parameter (default TRUE) which controls whether the = > trace plots are generated at end > - Add n.sims parameter (number of simulations to keep). I often = specify=20 > this and n.iter only.=20 > - Fix definition of n.thin which assumes output of 1000 simulations=20 > (divide by n.sims instead) > - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses it = for=20 > the R2WinBUGS directory > - Allow specification of data file that can be named something else = than=20 > data.txt > - Allow specification of inits file names >=20 > I have also rewritten the bugs.log routine so it does not crash if DIC = is=20 > not specified; it also does not make assumptions about the column = names.=20 >=20 > These improvements are all quite useful for us. Especially, bugs.seed = is=20 > crucial and summary.only helps a lot if one repeats the same analysis = many=20 > times and only needs some quick summary.=20 >=20 > If you agree, I would like to have these changes implemented in the = next=20 > version of R2WinBUGS.=20 >=20 > I've tried them out for some time now and there are no known bugs. I = have=20 > not tried it with openbugs.=20 >=20 > Best regards, Mit freundlichen Gr=FCssen, Meilleures salutations,=20 > Jouni Kerman, Ph.D. > Novartis Pharma AG > PH3483, CIS - METHODOLOGY > CHBS, WSJ-027.3.017 > Phone: +41 61 324 3600 > Fax: +41 61 324 3781 > Email : jou...@no... >=20 >=20 -------------------------------------------------------------------------= This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bugs-r-devel mailing list Bug...@li... https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: <woo...@us...> - 2008-01-17 18:24:15
|
Revision: 81 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=81&view=rev Author: woodard_ Date: 2008-01-17 10:24:14 -0800 (Thu, 17 Jan 2008) Log Message: ----------- Typo in R code caused a bug in S-PLUS (though not in R) Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.log.R Modified: trunk/R2WinBUGS/R/bugs.log.R =================================================================== --- trunk/R2WinBUGS/R/bugs.log.R 2008-01-16 12:50:28 UTC (rev 80) +++ trunk/R2WinBUGS/R/bugs.log.R 2008-01-17 18:24:14 UTC (rev 81) @@ -10,7 +10,7 @@ stop("Log file", file, "does not exist") log.txt <- readLines(file) extract <- function (m, line.match, skip=0, empty.left.col=TRUE) { - start <- (skip + which(log.txt == line.match)[1]) + start <- (skip + which(m == line.match)[1]) if(is.na(start)) return(NULL) if(length(start) < 1) return(NULL) mx <- strsplit(m[-(1:start)], "\t") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-16 12:50:47
|
Revision: 80 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=80&view=rev Author: ligges Date: 2008-01-16 04:50:28 -0800 (Wed, 16 Jan 2008) Log Message: ----------- new e-mail address / name of university has changed Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/inst/CITATION trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/inst/CITATION trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw trunk/R2WinBUGS/inst/doc/bugs.tex trunk/R2WinBUGS/man/as.bugs.array.Rd trunk/R2WinBUGS/man/bugs.Rd trunk/R2WinBUGS/man/openbugs.Rd Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/BRugs/DESCRIPTION 2008-01-16 12:50:28 UTC (rev 80) @@ -4,7 +4,7 @@ Date: 2007-09-20 Author: The Chief Software Bug is Andrew Thomas, with web assistance from Real Bug Bob O'Hara. Other members of the BUGS team are statisticians David Spiegelhalter, Nicky Best, Dave Lunn and Ken Rice. Dave Lunn has also made major contributions to the software development. R Code modified, extended and packaged for R by Uwe Ligges and Sibylle Sturtz. Some ideas taken from the R2WinBUGS package based on code by Andrew Gelman. Description: An R / S-PLUS package containing OpenBUGS and its R / S-PLUS interface BRugs. -Maintainer: Uwe Ligges <li...@st...> +Maintainer: Uwe Ligges <li...@st...> Depends: R (>= 2.5.0), coda SystemRequirements: currently the only supported OS is Windows, we expect to support Linux in future releases License: GPL-2 Modified: trunk/BRugs/inst/CITATION =================================================================== --- trunk/BRugs/inst/CITATION 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/BRugs/inst/CITATION 2008-01-16 12:50:28 UTC (rev 80) @@ -6,7 +6,7 @@ person(first="Andrew", last="Thomas", email=""), person(first="Bob", last="O'Hara", email=""), person(first="Uwe", last="Ligges", email="Uwe...@R-..."), - person(first="Sibylle", last="Sturtz", email="st...@st...")), + person(first="Sibylle", last="Sturtz", email="st...@st...")), journal = "R News", year = 2006, pages = "12--17", Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/DESCRIPTION 2008-01-16 12:50:28 UTC (rev 80) @@ -3,8 +3,8 @@ Date: 2008-01-08 Version: 2.1-7 Author: originally written by Andrew Gelman <ge...@st...>; - changes and packaged by Sibylle Sturtz <st...@st...> - and Uwe Ligges <li...@st...>. + changes and packaged by Sibylle Sturtz <st...@st...> + and Uwe Ligges <li...@st...>. With considerable contributions by Gregor Gorjanc <gre...@bf...> and Jouni Kerman <ke...@st...>. Ported to S-PLUS by Insightful Corp. @@ -17,6 +17,6 @@ Suggests: BRugs (>= 0.3-2) SystemRequirements: WinBUGS 1.4 URL: http://www.stat.columbia.edu/~gelman/bugsR/ -Maintainer: Uwe Ligges <li...@st...> +Maintainer: Uwe Ligges <li...@st...> License: GPL-2 Dialect: R, S-PLUS Modified: trunk/R2WinBUGS/inst/CITATION =================================================================== --- trunk/R2WinBUGS/inst/CITATION 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/inst/CITATION 2008-01-16 12:50:28 UTC (rev 80) @@ -3,7 +3,7 @@ citEntry(entry = "article", title = "R2WinBUGS: A Package for Running WinBUGS from R", author = personList( - person(first="Sibylle", last="Sturtz", email="st...@st..."), + person(first="Sibylle", last="Sturtz", email="st...@st..."), person(first="Uwe", last="Ligges", email="Uwe...@R-..."), person(first="Andrew", last="Gelman", email="ge...@st...")), journal = "Journal of Statistical Software", Modified: trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw 2008-01-16 12:50:28 UTC (rev 80) @@ -7,9 +7,9 @@ \setlength{\textheight}{23.5cm} \title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} -\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany +\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany \And - Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany \And Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA } Modified: trunk/R2WinBUGS/inst/doc/bugs.tex =================================================================== --- trunk/R2WinBUGS/inst/doc/bugs.tex 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/inst/doc/bugs.tex 2008-01-16 12:50:28 UTC (rev 80) @@ -138,7 +138,7 @@ \end{Value} \begin{Author}\relax Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; -modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. +modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. \end{Author} \begin{References}\relax Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003): Modified: trunk/R2WinBUGS/man/as.bugs.array.Rd =================================================================== --- trunk/R2WinBUGS/man/as.bugs.array.Rd 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/man/as.bugs.array.Rd 2008-01-16 12:50:28 UTC (rev 80) @@ -51,7 +51,7 @@ \author{Jouni Kerman, \email{ke...@st...} with modification by Andrew Gelman, \email{ge...@st...}, packaged by Uwe - Ligges, \email{li...@st...}.} + Ligges, \email{li...@st...}.} \seealso{\code{\link{bugs}}} \keyword{interface} Modified: trunk/R2WinBUGS/man/bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.Rd 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/man/bugs.Rd 2008-01-16 12:50:28 UTC (rev 80) @@ -203,7 +203,7 @@ \author{Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; modifications and - packaged by Sibylle Sturtz, \email{st...@st...}, + packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges.} \seealso{\code{\link{print.bugs}}, \code{\link{plot.bugs}}, as well as Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2008-01-08 21:11:35 UTC (rev 79) +++ trunk/R2WinBUGS/man/openbugs.Rd 2008-01-16 12:50:28 UTC (rev 80) @@ -63,7 +63,7 @@ \author{Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; modifications and - packaged by Sibylle Sturtz, \email{st...@st...}, + packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-08 21:12:15
|
Revision: 79 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=79&view=rev Author: ligges Date: 2008-01-08 13:11:35 -0800 (Tue, 08 Jan 2008) Log Message: ----------- bugs in monitor() reported by Andrew Gelman: - exported from NS (for making code in his book work) - extracts the default number of chains from the object by default Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/NAMESPACE trunk/R2WinBUGS/R/monitor.R trunk/R2WinBUGS/man/bugs.log.Rd trunk/R2WinBUGS/man/monitor.Rd Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2008-01-06 18:56:18 UTC (rev 78) +++ trunk/R2WinBUGS/DESCRIPTION 2008-01-08 21:11:35 UTC (rev 79) @@ -1,6 +1,6 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2008-01-06 +Date: 2008-01-08 Version: 2.1-7 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> Modified: trunk/R2WinBUGS/NAMESPACE =================================================================== --- trunk/R2WinBUGS/NAMESPACE 2008-01-06 18:56:18 UTC (rev 78) +++ trunk/R2WinBUGS/NAMESPACE 2008-01-08 21:11:35 UTC (rev 79) @@ -8,6 +8,7 @@ bugs.data, read.bugs, bugs.log, + monitor, openbugs, as.bugs.array, write.model) Modified: trunk/R2WinBUGS/R/monitor.R =================================================================== --- trunk/R2WinBUGS/R/monitor.R 2008-01-06 18:56:18 UTC (rev 78) +++ trunk/R2WinBUGS/R/monitor.R 2008-01-08 21:11:35 UTC (rev 79) @@ -1,15 +1,15 @@ "monitor" <- -function (a, n.chains, trans=NULL, keep.all=FALSE, Rupper.keep=FALSE) { +function (a, n.chains=dim(a)[2], trans=NULL, keep.all=FALSE, Rupper.keep=FALSE) { -# If keep.all=T: a is a n x m x k array: -# m sequences of length n, k variables measured -# If keep.all=F: a is a 2n x m x k array (first half will be discarded) -# -# trans is a vector of length k: "" if no transformation, or "log" or "logit" -# (If trans is not defined, it will be set to "log" for parameters that -# are all-positive and 0 otherwise.) -# -# If Rupper.keep=T: keep Rupper. (Otherwise don't display it.) +## If keep.all=T: a is a n x m x k array: +## m sequences of length n, k variables measured +## If keep.all=F: a is a 2n x m x k array (first half will be discarded) +## +## trans is a vector of length k: "" if no transformation, or "log" or "logit" +## (If trans is not defined, it will be set to "log" for parameters that +## are all-positive and 0 otherwise.) +## +## If Rupper.keep=TRUE: keep Rupper. (Otherwise don't display it.) invlogit <- function (x) {1 / (1 + exp(-x))} nparams <- if(length(dim(a)) < 3) 1 else dim(a)[length(dim(a))] # Calculation and initialization of the required matrix "output" @@ -30,9 +30,9 @@ confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) } else if (trans[i]=="logit"){ - if (!is.R()){ - logit <- function (x) { log(x /(1- x)) } - } + if (!is.R()){ + logit <- function (x) { log(x /(1- x)) } + } conv.p <- conv.par(logit(ai), n.chains, Rupper.keep=Rupper.keep) conv.p <- list(quantiles = invlogit(conv.p$quantiles), confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) Modified: trunk/R2WinBUGS/man/bugs.log.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.log.Rd 2008-01-06 18:56:18 UTC (rev 78) +++ trunk/R2WinBUGS/man/bugs.log.Rd 2008-01-08 21:11:35 UTC (rev 79) @@ -18,5 +18,6 @@ \pkg{WinBUGS}.} } \seealso{The main function that generates the log file is \code{\link{bugs}}.} +\author{Jouni Kerman} \keyword{IO} \keyword{file} Modified: trunk/R2WinBUGS/man/monitor.Rd =================================================================== --- trunk/R2WinBUGS/man/monitor.Rd 2008-01-06 18:56:18 UTC (rev 78) +++ trunk/R2WinBUGS/man/monitor.Rd 2008-01-08 21:11:35 UTC (rev 79) @@ -3,15 +3,13 @@ \alias{conv.par} \title{Special summary statistics} -\description{Special summary statistics of the WinBUGS output - intended - for internal use} +\description{Special summary statistics of the WinBUGS output.} \usage{ -monitor(a, n.chains, trans = NULL, keep.all = FALSE, Rupper.keep = FALSE) +monitor(a, n.chains = dim(a)[2], trans = NULL, keep.all = FALSE, Rupper.keep = FALSE) conv.par(x, n.chains, Rupper.keep = TRUE) } \arguments{ - \item{x}{} \item{a}{a \code{n * m * k} array: \code{m} sequences of length \code{n}, \code{k} variables measured} \item{n.chains}{number of Markov chains} @@ -21,9 +19,10 @@ \item{keep.all}{if \code{FALSE} (default), first half of \code{a} will be discarded} \item{Rupper.keep}{if \code{FALSE}, don't return \code{Rupper}} + \item{x}{for internal use only} } -\details{See the well documented code for details.} +\details{\code{conv.par} is intended for internal use only.} \value{ for \code{monitor}: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2008-01-06 18:56:13
|
Revision: 78 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=78&view=rev Author: ligges Date: 2008-01-06 10:56:18 -0800 (Sun, 06 Jan 2008) Log Message: ----------- two typos during last commit not found by R CMD check before... Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/bugs.script.R Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:17:57 UTC (rev 77) +++ trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:56:18 UTC (rev 78) @@ -104,7 +104,7 @@ if(codaPkg) return(file.path(getwd(), paste("coda", 1:n.chains, ".txt", sep=""))) if (summary.only) { - return(log("log.txt")) + return(bugs.log("log.txt")) } sims <- c(bugs.sims(parameters.to.save, n.chains, n.iter, n.burnin, Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:17:57 UTC (rev 77) +++ trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:56:18 UTC (rev 78) @@ -5,8 +5,6 @@ newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, save.history=TRUE, bugs.data.file, bugs.inits.files) { - - output.coda <- (!summary.only) ## Write file script.txt for Bugs if((ceiling(n.iter/n.thin) - ceiling(n.burnin/n.thin)) < 2) stop ("(n.iter-n.burnin)/n.thin must be at least 2") @@ -64,7 +62,8 @@ savelist, if(DIC) "dic.set()\n", rep(c("update (", formatC(ceiling(bin), format = "d"), ")\n", - if (output.coda) c("coda (*, '", coda, "')\n")), + #if (!summary.only) ## Hmm, if coda files are not written, we do not know if WinBUGS did not fail + c("coda (*, '", coda, "')\n")), redo), "stats (*)\n", if(DIC) "dic.stats()\n", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Uwe L. <li...@st...> - 2008-01-06 18:25:10
|
Dear Jouni, after a serious delay due to work-overload, I finally found the time to incorporate your changes into R2WinBUGS, most of them unchanged. So thank you again for your nice code!!! I replaced bugs.log() by your function bugs.summary() and tried to update all the help pages. The current version is committed to the repository at: https://sourceforge.net/projects/bugs-r/ If you like, we can give you access as a developer. If not, for the next time, please send changes as diffs against the sources on the sourceforge address mentioned above. Dear Dawn, can you quickly test under S-PLUS, please? I think we could release this one pretty soon now. Best wishes, Uwe jou...@no... wrote: > Dear Uwe > > I noticed that Sibylle Sturtz is the maintainer of R2WinBUGS so I sent her > the following message. I don't know if you're interested any more but > maybe you have some comments? > > best regards > > Jouni Kerman > > > ----------- > > I've made some improvements and additions to the R2WinBUGS code to make it > more flexible. > > However I would like to make the changes available for everyone. How could > I help you best to get them incorporated in the package? > > ---- > My current code is attached. > > I have currently 5 rewritten functions for the package. Most are just > small modifications and affect only small parts of the functions. I tried > not to change too much of the old code just to make it easier to review. > > In summary the additions and changes are: > > (In function bugs:) > - Add bugs.seed parameter and the corresponding bugs script entry to > specify random seed in WinBUGS > - Add summary.only parameter (default FALSE) which prevents outputting the > coda and only returns the parameter summary > - Add save.history parameter (default TRUE) which controls whether the > trace plots are generated at end > - Add n.sims parameter (number of simulations to keep). I often specify > this and n.iter only. > - Fix definition of n.thin which assumes output of 1000 simulations > (divide by n.sims instead) > - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses it for > the R2WinBUGS directory > - Allow specification of data file that can be named something else than > data.txt > - Allow specification of inits file names > > I have also rewritten the bugs.log routine so it does not crash if DIC is > not specified; it also does not make assumptions about the column names. > > These improvements are all quite useful for us. Especially, bugs.seed is > crucial and summary.only helps a lot if one repeats the same analysis many > times and only needs some quick summary. > > If you agree, I would like to have these changes implemented in the next > version of R2WinBUGS. > > I've tried them out for some time now and there are no known bugs. I have > not tried it with openbugs. > > Best regards, Mit freundlichen Grüssen, Meilleures salutations, > Jouni Kerman, Ph.D. > Novartis Pharma AG > PH3483, CIS - METHODOLOGY > CHBS, WSJ-027.3.017 > Phone: +41 61 324 3600 > Fax: +41 61 324 3781 > Email : jou...@no... > > |
From: <li...@us...> - 2008-01-06 18:17:53
|
Revision: 77 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=77&view=rev Author: ligges Date: 2008-01-06 10:17:57 -0800 (Sun, 06 Jan 2008) Log Message: ----------- Some major changes contributed by Jouni Kerman, citing from his message the relevant changes: (In function bugs:) - Add bugs.seed parameter and the corresponding bugs script entry to specify random seed in WinBUGS - Add summary.only parameter (default FALSE) which prevents outputting the coda and only returns the parameter summary - Add save.history parameter (default TRUE) which controls whether the trace plots are generated at end - Add n.sims parameter (number of simulations to keep). I often specify this and n.iter only. - Fix definition of n.thin which assumes output of 1000 simulations (divide by n.sims instead) - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses it for the R2WinBUGS directory - Allow specification of data file that can be named something else than data.txt - Allow specification of inits file names I have also rewritten the bugs.log routine so it does not crash if DIC is not specified; it also does not make assumptions about the column names. Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/bugs.data.R trunk/R2WinBUGS/R/bugs.inits.R trunk/R2WinBUGS/R/bugs.log.R trunk/R2WinBUGS/R/bugs.script.R trunk/R2WinBUGS/R/openbugs.R trunk/R2WinBUGS/man/bugs.Rd trunk/R2WinBUGS/man/bugs.data.Rd trunk/R2WinBUGS/man/bugs.inits.Rd trunk/R2WinBUGS/man/bugs.log.Rd trunk/R2WinBUGS/man/bugs.script.Rd trunk/R2WinBUGS/man/openbugs.Rd Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/DESCRIPTION 2008-01-06 18:17:57 UTC (rev 77) @@ -1,6 +1,6 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2007-09-25 +Date: 2008-01-06 Version: 2.1-7 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,21 +1,26 @@ "bugs" <- function(data, inits, parameters.to.save, model.file="model.bug", n.chains=3, n.iter=2000, n.burnin=floor(n.iter / 2), - n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / 1000)), + n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), n.sims = 1000, bin=(n.iter - n.burnin) / n.thin, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, bugs.directory="c:/Program Files/WinBUGS14/", program=c("WinBUGS", "OpenBUGS", "winbugs", "openbugs"), working.directory=NULL, clearWD=FALSE, useWINE=.Platform$OS.type != "windows", WINE=NULL, - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=!summary.only) { program <- match.arg(program) + if (missing(bugs.directory) && + !is.null(bugs.dir <- getOption("R2WinBUGS.bugs.directory"))) { # requested by Jouni Kerman + bugs.directory <- bugs.dir + } if(program %in% c("openbugs", "OpenBUGS", "OpenBugs")) { if(!is.R()) stop("OpenBUGS is not yet available in S-PLUS") ## If OpenBUGS, we only call openbugs() and exit... return(openbugs(data, inits, parameters.to.save, model.file, - n.chains, n.iter, n.burnin, n.thin, DIC=DIC, + n.chains, n.iter, n.burnin, n.thin, n.sims, DIC=DIC, bugs.directory, working.directory, digits)) } ## Checking number of inits, which is NOT save here: @@ -52,12 +57,32 @@ stop(paste(model.file, "does not exist.")) if(file.info(model.file)$isdir) stop(paste(model.file, "is a directory, but a file is required.")) - if(!(length(data) == 1 && is.vector(data) && is.character(data) && data == "data.txt")) { - bugs.data(data, dir=getwd(), digits) + if (!(length(data) == 1 && is.vector(data) && is.character(data) && + (regexpr("\\.txt$", data) > 0))) { + bugs.data.file <- bugs.data(data, dir = getwd(), digits) } else { - if(!file.exists(data)) stop("File data.txt does not exist.") + if(!file.exists(data)) + stop("File", data, "does not exist.") + bugs.data.file <- data } - bugs.inits(inits, n.chains, digits) + + + if (is.character(inits)) { + if (!all(file.exists(inits))) { + stop("One or more inits files are missing") + } + if (length(inits)!=n.chains) { + stop("Need one inits file for each chain") + } + bugs.inits.files <- inits + } else { + if (!is.function(inits) && !is.null(inits) && (length(inits) != n.chains)) { + stop("Number of initialized chains (length(inits)) != n.chains") + } + bugs.inits.files <- bugs.inits(inits, n.chains, digits) + } + + if(DIC) parameters.to.save <- c(parameters.to.save, "deviance") ## Model files with extension ".bug" need to be renamed to ".txt" if(length(grep("[.]bug$", model.file))) { @@ -70,17 +95,24 @@ bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, new.model.file, debug=debug, is.inits=!is.null(inits), bin=bin, DIC=DIC, useWINE=useWINE, newWINE=newWINE, - WINEPATH=WINEPATH) + WINEPATH=WINEPATH, bugs.seed=bugs.seed, + summary.only=summary.only, save.history=save.history, + bugs.data.file = bugs.data.file, + bugs.inits.files = bugs.inits.files) bugs.run(n.burnin, bugs.directory, WINE=WINE, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) if(codaPkg) return(file.path(getwd(), paste("coda", 1:n.chains, ".txt", sep=""))) + if (summary.only) { + return(log("log.txt")) + } + sims <- c(bugs.sims(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, DIC), model.file=model.file, program=program) if(clearWD) { - file.remove(c("data.txt", "log.odc", "log.txt", "codaIndex.txt", - paste("inits", 1:n.chains, ".txt", sep=""), + file.remove(c(bugs.data.file, "log.odc", "log.txt", "codaIndex.txt", + bugs.inits.files, paste("coda", 1:n.chains, ".txt", sep=""))) } class(sims) <- "bugs" Modified: trunk/R2WinBUGS/R/bugs.data.R =================================================================== --- trunk/R2WinBUGS/R/bugs.data.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.data.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,26 +1,27 @@ "bugs.data" <- -function(data, dir = getwd(), digits = 5){ +function(data, dir = getwd(), digits = 5, data.file = "data.txt"){ if(is.numeric(unlist(data))) if(is.R()) { write.datafile(lapply(data, formatC, digits = digits, format = "E"), - file.path(dir, "data.txt")) + file.path(dir, data.file)) } else { - writeDatafileS4(data, towhere = "data.txt") + writeDatafileS4(data, towhere = data.file) } else { if(is.R()) { data.list <- lapply(as.list(data), get, pos = parent.frame(2)) names(data.list) <- as.list(data) write.datafile(lapply(data.list, formatC, digits = digits, format = "E"), - file.path(dir, "data.txt")) + file.path(dir, data.file)) } else { data.list <- lapply(as.list(data), get, where = parent.frame(2)) names(data.list) <- unlist(data) - writeDatafileS4(data.list, towhere = "data.txt") + writeDatafileS4(data.list, towhere = data.file) } - } + } + return(data.file) } Modified: trunk/R2WinBUGS/R/bugs.inits.R =================================================================== --- trunk/R2WinBUGS/R/bugs.inits.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.inits.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,22 +1,22 @@ "bugs.inits" <- -function (inits, n.chains, digits){ +function (inits, n.chains, digits, + inits.files = paste("inits", 1:n.chains, ".txt", sep = "")){ if(!is.null(inits)) { for(i in 1:n.chains) { if(is.function(inits)) if(is.R()) { write.datafile(lapply(inits(), formatC, digits = digits, format = "E"), - paste("inits", i, ".txt", sep = "")) + inits.files[i]) } else { - writeDatafileS4(inits(), towhere = - paste("inits", i, ".txt", sep = "")) + writeDatafileS4(inits(), towhere = inits.files[i]) } else if(is.R()) { write.datafile(lapply(inits[[i]], formatC, digits = digits, format = "E"), - paste("inits", i, ".txt", sep = "")) + inits.files[i]) } else { - writeDatafileS4(inits[[i]], towhere = paste( - "inits", i, ".txt", sep = "")) + writeDatafileS4(inits[[i]], towhere = inits.files[i]) } } } + return(inits.files) } Modified: trunk/R2WinBUGS/R/bugs.log.R =================================================================== --- trunk/R2WinBUGS/R/bugs.log.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.log.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,49 +1,34 @@ -bugs.log <- function(file) +bugs.log <- function (file) { - if(!file.exists(file)) - stop("Log file", file, "does not exist") - logfile <- readLines(file) + # Extracts the summary statistics from log.txt written by WinBUGS. + # Jouni Kerman 2007-01-30 + # does essentially the same thing as bugs.log() but + # - won't crash if DIC is not there + # - makes fewer assumptions about the structure of the matrix - ## --- Stats --- - - statsStart <- which(logfile == "Node statistics") + 2 - if(!length(statsStart)) - stop("Log file", file, "does not contain node statistics.") - ## + 2 to remove - ## "Node statistics" - ## "\t node\t mean\t sd\t MC error\t2.5%\tmedian\t97.5%\tstart\tsample" - - statsEnd <- which(logfile == "dic.stats()") - 1 - ## - 1 to remove - ## "dic.stats()" - - statsTable <- logfile[statsStart:statsEnd] - statsTable <- sub("\t", "", statsTable) - statsTable <- sapply(strsplit(statsTable, "\t"), "[") - colnames(statsTable) <- statsTable[1,] - statsTable <- t(apply(statsTable[-1,], 2, as.numeric)) - colnames(statsTable) <- c("mean", "sd", "MC error", "2.5%", "median", "97.5%", "start", "sample") - - ## --- DIC --- - - DICStart <- which(logfile == "DIC") + 3 - ## + 3 to remove - ## "DIC" - ## "Dbar = post.mean of -2logL; Dhat = -2LogL at post.mean of stochastic nodes" - ## "\tDbar\tDhat\tpD\tDIC\t" - - DICEnd <- grep("history(", logfile, fixed=TRUE) - 1 - ## - 1 to remove - ## "history(..." - - if(!length(DICEnd) || !length(DICStart) || (DICEnd < DICStart)){ - DICTable <- NA - } else { - DICTable <- logfile[DICStart:DICEnd] - DICTable <- sapply(strsplit(DICTable, "\t"), "[") - colnames(DICTable) <- DICTable[1,] - DICTable <- t(apply(DICTable[-1,], 2, as.numeric)) - colnames(DICTable) <- c("Dbar", "Dhat", "pD", "DIC") - } - list(stats=statsTable, DIC=DICTable) + if(!file.exists(file)) + stop("Log file", file, "does not exist") + log.txt <- readLines(file) + extract <- function (m, line.match, skip=0, empty.left.col=TRUE) { + start <- (skip + which(log.txt == line.match)[1]) + if(is.na(start)) return(NULL) + if(length(start) < 1) return(NULL) + mx <- strsplit(m[-(1:start)], "\t") + n.cols <- length(mx[[1]]) + mxlen <- sapply(mx, length) + end <- which(mxlen!=n.cols)[1] - 1 + mx <- mx[1:end] + cm <- matrix(unlist(mx), ncol=n.cols, byrow=TRUE) # character format + if(empty.left.col) cm <- cm[,-1] # empty column + col.names <- cm[1, -1] # first column is just "node" + row.names <- cm[,1][-1] # first row is just "" + col.names <- gsub("[[:space:]]+", "", col.names) # get rid of spaces + cm <- cm[-1,-1] # delete dimname row/columns + m <- matrix(as.numeric(cm), nrow=nrow(cm)) # convert to numeric + dimnames(m) <- list(row.names, col.names) + return(m) + } + stats <- extract(log.txt, "Node statistics") + DIC <- extract(log.txt, "DIC", skip=1, empty.left.col=FALSE) + list(stats=stats, DIC=DIC) } Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:17:57 UTC (rev 77) @@ -2,20 +2,28 @@ function(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, model.file, debug=FALSE, is.inits, bin, DIC=FALSE, useWINE=.Platform$OS.type != "windows", - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=TRUE, bugs.data.file, bugs.inits.files) { + + output.coda <- (!summary.only) ## Write file script.txt for Bugs - if((ceiling(n.iter/n.thin) - ceiling(n.burnin/n.thin)) < 2) stop ("(n.iter-n.burnin)/n.thin must be at least 2") working.directory <- getwd() script <- "script.txt" - test <- length(grep("\\\\", model.file)) || length(grep("/", model.file)) - model <- ifelse(test, model.file, file.path(working.directory, model.file)) + model <- + if (length(grep("\\\\", model.file)) || length(grep("/", model.file))) { + model.file + } + else file.path(working.directory, model.file) model <- native2win(model, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) - data <- file.path(working.directory, "data.txt") + history <- file.path(working.directory, "history.odc") + history <- native2win(history, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) + + data <- file.path(working.directory, bugs.data.file) data <- native2win(data, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) coda <- file.path(working.directory, "coda") @@ -26,16 +34,21 @@ logFileTxt <- file.path(working.directory, "log.txt") logFileTxt <- native2win(logFileTxt, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) - inits <- paste(working.directory, "/inits", 1:n.chains, ".txt", sep="") + inits <- paste(working.directory, "/", bugs.inits.files, sep="") inits <- sapply(inits, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH, - function(x, useWINE, newWINE, WINEPATH) - {native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)}) + function(x, useWINE, newWINE, WINEPATH) + {native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)}) initlist <- paste("inits (", 1:n.chains, ", '", inits, "')\n", sep="") savelist <- paste("set (", parameters.to.save, ")\n", sep="") redo <- ceiling((n.iter-n.burnin)/(n.thin*bin)) + bugs.seed.cmd <- "" + if (!is.null(bugs.seed)) { + bugs.seed.cmd <- paste("set.seed(", bugs.seed, ")\n", sep="") + } + thinUpdate <- paste("thin.updater (", n.thin, ")\n", "update (", ceiling(n.burnin/n.thin), ")\n", sep="") @@ -43,18 +56,19 @@ "display ('log')\n", "check ('", model, "')\n", "data ('", data, "')\n", + bugs.seed.cmd, "compile (", n.chains, ")\n", if(is.inits) initlist, "gen.inits()\n", thinUpdate, - savelist, + savelist, if(DIC) "dic.set()\n", - rep( - c("update (", formatC(ceiling(bin), format="d"), ")\n", - "coda (*, '", coda, "')\n"),redo), + rep(c("update (", formatC(ceiling(bin), format = "d"), ")\n", + if (output.coda) c("coda (*, '", coda, "')\n")), + redo), "stats (*)\n", if(DIC) "dic.stats()\n", - "history (*)\n", + if (save.history) c("history (*, '", history, "')\n"), "save ('", logFile, "')\n", "save ('", logFileTxt, "')\n", file=script, sep="", append=FALSE) Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/openbugs.R 2008-01-06 18:17:57 UTC (rev 77) @@ -3,7 +3,7 @@ openbugs <- function(data, inits, parameters.to.save, model.file="model.txt", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), - n.thin = max(1, floor(n.chains *(n.iter - n.burnin)/1000)), + n.thin = max(1, floor(n.chains *(n.iter - n.burnin) / n.sims)), n.sims = 1000, DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", working.directory=NULL, digits = 5) { Modified: trunk/R2WinBUGS/man/bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -9,28 +9,31 @@ \usage{ bugs(data, inits, parameters.to.save, model.file="model.bug", n.chains=3, n.iter=2000, n.burnin=floor(n.iter/2), - n.thin=max(1, floor(n.chains * (n.iter - n.burnin)/1000)), - bin=(n.iter - n.burnin) / n.thin, + n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), + n.sims = 1000, bin=(n.iter - n.burnin) / n.thin, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, bugs.directory="c:/Program Files/WinBUGS14/", program=c("WinBUGS", "OpenBUGS", "winbugs", "openbugs"), working.directory=NULL, clearWD=FALSE, useWINE=.Platform$OS.type != "windows", WINE=NULL, - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=!summary.only) } \arguments{ \item{data}{either a named list (names corresponding to variable names in the \code{model.file}) of the data for the \pkg{WinBUGS} model, \emph{or} a vector or list of the names of the data objects used by - the model. If \code{data="data.txt"}, it is assumed that data have - already been written to the working directory in a file called - \file{data.txt}, e.g. by the function \code{\link{bugs.data}}.} + the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), + it is assumed that data have already been written to the working directory into that file, + e.g. by the function \code{\link{bugs.data}}.} \item{inits}{a list with \code{n.chains} elements; each element of the list is itself a list of starting values for the \pkg{WinBUGS} model, \emph{or} a function creating (possibly random) initial values. Alternatively, if \code{inits=NULL}, initial values are generated - by \pkg{WinBUGS}.} + by \pkg{WinBUGS}. If \code{inits} is a character vector with \code{n.chains} elements, + it is assumed that inits have already been written to the working directory into those files, + e.g. by the function \code{\link{bugs.inits}}.} \item{parameters.to.save}{character vector of the names of the parameters to save which should be monitored} \item{model.file}{file containing the model written in \pkg{WinBUGS} code. @@ -52,6 +55,7 @@ \code{n.iter} is large. Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} which will only thin if there are at least 2000 simulations.} + \item{n.sims}{The approximate number of simulations to keep after thinning.} \item{bin}{number of iterations between saving of results (i.e. the coda files are saved after each \code{bin} iterations); default is to save only at the end.} @@ -68,7 +72,9 @@ is returned, if \code{TRUE} file names of \pkg{WinBUGS} output are returned for easy access by the \pkg{coda} package through function \code{\link{read.bugs}} (not used if \code{program="OpenBUGS"}).} - \item{bugs.directory}{directory that contains the \pkg{WinBUGS} executable} + \item{bugs.directory}{directory that contains the \pkg{WinBUGS} executable. + If the global option \code{R2WinBUGS.bugs.directory} is not \code{NULL}, + it will be used as the default.} \item{program}{the program to use, either \code{winbugs}/\code{WinBUGS} or \code{openbugs}/\code{OpenBUGS}, the latter makes use of function \code{\link{openbugs}} and requires @@ -92,6 +98,10 @@ utility} \item{WINEPATH}{character, path to \file{winepath} binary file, it is tried hard to get the information automatically if not given.} + \item{bugs.seed}{random seed for \pkg{WinBUGS} (default is no seed)} + \item{summary.only}{If \code{TRUE}, only a parameter summary for very quick analyses is given, + temporary created files are not removed in that case.} + \item{save.history}{If \code{TRUE} (the default), trace plots are generated at the end.} } \details{ Modified: trunk/R2WinBUGS/man/bugs.data.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.data.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.data.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -2,11 +2,11 @@ \alias{bugs.data} \title{Writing input for WinBUGS} -\description{Write file \file{data.txt} for \pkg{WinBUGS} to read - for +\description{Write file for \pkg{WinBUGS} to read - for internal use.} \usage{ -bugs.data(data, dir = getwd(), digits = 5) +bugs.data(data, dir = getwd(), digits = 5, data.file = "data.txt") } \arguments{ \item{data}{either a named list (names corresponding to variable names @@ -16,10 +16,11 @@ \item{dir}{the directory to write the file \file{data.txt} to} \item{digits}{number of significant digits used for \pkg{WinBUGS} input, see \code{\link{formatC}}} + \item{data.file}{name for the file R writes the data into.} } -\value{Nothing, but as a side effect, the data file \file{data.txt} is - written} +\value{The name of \code{data.file} is returned and as a side effect, + the data file is written} \seealso{The main function to be called by the user is \code{\link{bugs}}.} \keyword{internal} Modified: trunk/R2WinBUGS/man/bugs.inits.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.inits.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.inits.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -6,7 +6,8 @@ the working directory for \pkg{WinBUGS} to read - for internal use.} \usage{ -bugs.inits(inits, n.chains, digits) +bugs.inits(inits, n.chains, digits, + inits.files = paste("inits", 1:n.chains, ".txt", sep = "")) } \arguments{ \item{inits}{a list with \code{n.chains} elements; each element of the @@ -15,9 +16,10 @@ \item{n.chains}{number of Markov chains} \item{digits}{number of significant digits used for \pkg{WinBUGS} input, see \code{\link{formatC}}} + \item{inits.file}{name for the inits files R write the inits into.} } -\value{Nothing, but as a side effect, the inits files \file{inits*.txt} +\value{Vector of names of \code{inits.files}; as a side effect, the inits files \file{inits*.txt} are written} \seealso{The main function to be called by the user is \code{\link{bugs}}.} Modified: trunk/R2WinBUGS/man/bugs.log.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.log.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.log.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -17,11 +17,6 @@ \item{DIC}{A matrix containing the DIC statistics as returned from \pkg{WinBUGS}.} } - -\details{ In later releases of \pkg{R2WinBUGS}, this function is -considered to read the relevant data from the log file rather than -analysing and calculating the relevant data in \R / S-PLUS again. } - \seealso{The main function that generates the log file is \code{\link{bugs}}.} \keyword{IO} \keyword{file} Modified: trunk/R2WinBUGS/man/bugs.script.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.script.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.script.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -9,7 +9,9 @@ \usage{ bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, model.file, debug=FALSE, is.inits, bin, DIC=FALSE, - useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL) + useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL, + bugs.seed=NULL, summary.only=FALSE, save.history=TRUE, + bugs.data.file, bugs.inits.files) } \arguments{ \item{parameters.to.save}{parameters that should be monitored} @@ -28,6 +30,12 @@ \item{useWINE}{as in \code{\link{bugs}} meta function} \item{newWINE}{as in \code{\link{bugs}} meta function} \item{WINEPATH}{as in \code{\link{bugs}} meta function} + \item{bugs.seed}{random seed for \pkg{WinBUGS} (default is no seed)} + \item{summary.only}{If \code{TRUE}, only a parameter summary for very quick analyses is given, + temporary created files are not removed in that case.} + \item{save.history}{If \code{TRUE} (the default), trace plots are generated at the end.} + \item{bugs.data.file}{character name of the data file} + \item{bugs.inits.files}{character vector of names of the inits files} } \value{Nothing, but as a side effect, the script file \file{script.txt} Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/openbugs.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -10,8 +10,9 @@ openbugs(data, inits, parameters.to.save, model.file = "model.txt", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), - n.thin = max(1, floor(n.chains * (n.iter - n.burnin) / 1000)), - DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", + n.thin = max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), + n.sims = 1000, DIC = TRUE, + bugs.directory = "c:/Program Files/OpenBUGS/", working.directory = NULL, digits = 5) } @@ -19,9 +20,9 @@ \item{data}{either a named list (names corresponding to variable names in the \code{model.file}) of the data for the \pkg{OpenBUGS} model, \emph{or} a vector or list of the names of the data objects used by - the model. If \code{data = "data.txt"}, it is assumed that data - have already been written to the working directory in a file called - \file{data.txt}, e.g. by the function \code{\link{bugs.data}}.} + the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), + it is assumed that data have already been written to the working directory into that file, + e.g. by the function \code{\link{bugs.data}}.} \item{inits}{a list with \code{n.chains} elements; each element of the list is itself a list of starting values for the \pkg{OpenBUGS} model, \emph{or} a function creating (possibly random) initial values. @@ -45,7 +46,8 @@ \code{n.iter} is large. Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} which will only thin if there are at least 2000 simulations.} - \item{DIC}{logical; if \code{TRUE} (default), compute deviance, pD, and + \item{n.sims}{The approximate number of simulations to keep after thinning.} + \item{DIC}{logical; if \code{TRUE} (default), compute deviance, pD, and DIC. This is done in \pkg{BRugs} directly.} \item{digits}{number of significant digits used for \pkg{OpenBUGS} input, see \code{\link{formatC}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2007-10-17 10:09:44
|
Revision: 76 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=76&view=rev Author: ligges Date: 2007-10-17 03:09:41 -0700 (Wed, 17 Oct 2007) Log Message: ----------- version information updated for R-2.7.x Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/R2WinBUGS/DESCRIPTION Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2007-10-04 10:11:12 UTC (rev 75) +++ trunk/BRugs/DESCRIPTION 2007-10-17 10:09:41 UTC (rev 76) @@ -7,5 +7,5 @@ Maintainer: Uwe Ligges <li...@st...> Depends: R (>= 2.5.0), coda SystemRequirements: currently the only supported OS is Windows, we expect to support Linux in future releases -License: GPL version 2 +License: GPL-2 URL: http://mathstat.helsinki.fi/openbugs/ Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2007-10-04 10:11:12 UTC (rev 75) +++ trunk/R2WinBUGS/DESCRIPTION 2007-10-17 10:09:41 UTC (rev 76) @@ -18,5 +18,5 @@ SystemRequirements: WinBUGS 1.4 URL: http://www.stat.columbia.edu/~gelman/bugsR/ Maintainer: Uwe Ligges <li...@st...> -License: GPL version 2 +License: GPL-2 Dialect: R, S-PLUS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Dawn W. <dwo...@in...> - 2007-10-05 18:54:55
|
=20 The modelDisable function in BRugs allows the user to turn off = particular updaters during model fitting. It is hard to tell whether it does what = it is intended to do, however, since there is no function that lists all of = the currently enabled updaters. How hard would it be to write such a = function? Alternatively, we could provide a function that is the equivalent of infoUpdatersbyName or infoNodeMethods in the scripting language. Here = is my (incomplete) attempt at such a function, which is intended to write the updaters to the buffer file and then display that file. It is patterned after the modelModules function in BRugs. =20 infoUpdatersbyName <- function(){ command <- "BugsEmbed.UpdatersByName" .C("CmdInterpreter", command, nchar(command), integer(1), = PACKAGE=3D"BRugs") buffer <- file.path(tempdir(), "buffer.txt") file.show(buffer) } =20 The information never gets written to the buffer, however. Any ideas? =20 Thank you! Dawn |
From: <li...@us...> - 2007-10-04 10:11:54
|
Revision: 75 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=75&view=rev Author: ligges Date: 2007-10-04 03:11:12 -0700 (Thu, 04 Oct 2007) Log Message: ----------- bugfix for not dropping dimensions in the matrix object sims Modified Paths: -------------- trunk/R2WinBUGS/R/as.bugs.array.R trunk/R2WinBUGS/R/bugs.sims.R Modified: trunk/R2WinBUGS/R/as.bugs.array.R =================================================================== --- trunk/R2WinBUGS/R/as.bugs.array.R 2007-09-25 11:33:02 UTC (rev 74) +++ trunk/R2WinBUGS/R/as.bugs.array.R 2007-10-04 10:11:12 UTC (rev 75) @@ -87,7 +87,7 @@ } } } - sims <- sims[sample(n.sims), ] + sims <- sims[sample(n.sims), , drop = FALSE] sims.list <- summary.mean <- summary.sd <- summary.median <- vector(n.roots, mode = "list") names(sims.list) <- names(summary.mean) <- names(summary.sd) <- names(summary.median) <- root.short Modified: trunk/R2WinBUGS/R/bugs.sims.R =================================================================== --- trunk/R2WinBUGS/R/bugs.sims.R 2007-09-25 11:33:02 UTC (rev 74) +++ trunk/R2WinBUGS/R/bugs.sims.R 2007-10-04 10:11:12 UTC (rev 75) @@ -92,7 +92,7 @@ rev(n.indexes.short[[j]])), dimension.short[j]:1) } } - sims <- sims [sample(n.sims),] # scramble (for convenience in analysis) + sims <- sims [sample(n.sims), , drop = FALSE] # scramble (for convenience in analysis) sims.list <- summary.mean <- summary.sd <- summary.median <- vector(n.roots, mode = "list") names(sims.list) <- names(summary.mean) <- names(summary.sd) <- names(summary.median) <- root.short for (j in 1:n.roots){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Uwe L. <li...@st...> - 2007-10-04 10:07:56
|
Gorjanc Gregor wrote: > A better idea would be top write a sample() method for > bugs class. This would be the most natural way in my > opinion. Sure, that would be much cleaner code, but it might break code of people using the package. Even if the original design decision is R-unlike (and it was my fault not to change it - and insist on such a change - while moving Andrew's code into an R package), we should stay with it, I think. Note that it is also documented for quite a long time now. ?bugs tells us: sims.matrix matrix of simulation output, with n.chains*n.keep rows and one column for each element of each saved parameter (for convenience, the n.keep*n.chains simulations in sims.matrix and sims.list (but NOT sims.array) have been randomly permuted) Best, Uwe > sample(bugs) > ... > ________________________________________ > From: bug...@li... [bug...@li...] On Behalf Of Andrew Gelman [ge...@st...] > Sent: Thursday, October 04, 2007 12:55 AM > To: Anon. > Cc: bug...@li... > Subject: Re: [Bugs-r-devel] R2WinBUGS bug fix > > I'm confused because bugs has sims.list, sims.matrix, and sims.array, > but I don't see sims. In the ?bugs help, it says that "for convenience, > the 'n.keep * n.chains' simulations in sims.matrix and sims.list (but > NOT sims.array) have been randomly permuted" > > The reason why we scramble the simulations is so we can more easily > access random draws from the posterior distribution. We can then just > use the first 10 simulations or the first 100 or whatever to do > posterior simulations (see chapter 6 of BDA for various examples). > > Checking for convergence--which is the same thing as assessing > mixing--isn't a problem since we check convergence on the unscrambled > series that are in sims.array. You can always use sims.array if you > want to work with these. > > Andrew > > Anon. wrote: >> Uwe Ligges wrote: >>> I think this was proposed by Andrew Gelman in the original code and I >>> already had the discussion but forgot the outcome (people would like >>> to have it randomized?, Andrew?). >>> >>> Anyway, a fix would be to add drop = FALSE as in >>> >>> sims <- sims [sample(n.sims), , drop = FALSE] # scramble (for >>> convenience in analysis) >>> >>> >> I'm curious - how can you check for convergence if the order is >> randomised? I'm thinking of cases where both chains are moving in the >> same direction towards the part of the posterior with high probability >> mass. It also makes mixing more difficult to assess, although this is >> less critical. >> >> I would certainly prefer not to have this randomised - there are >> disadvantage, and if you want the results randomise, it's easy to do >> (hey, it's one line of code!). OTOH, if it's already randomised, it's >> difficult to impossible to unscramble it. >> >> Bob >> > > -- > Andrew Gelman > Professor, Department of Statistics > Professor, Department of Political Science > Director, Applied Statistics Center > Columbia University, New York > ge...@st... > www.stat.columbia.edu/~gelman > > Usual schedule: > > Mon, Tues, Fri in Statistics Dept ofc: > Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 > phone 212-851-2142, fax 212-851-2164 > Wed, Thurs in Political Science Dept ofc: > International Affairs Bldg (Amsterdam Ave at 118 St), Room 731 > phone 212-854-7075, fax 212-222-0598 > Wed, Thurs from 2:30pm onward in Playroom: > International Affairs Bldg, Room 707 > > I'm out of town 11-12 Oct, 26 Oct, and 15-23 Nov. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Gorjanc G. <Gre...@bf...> - 2007-10-04 08:28:36
|
A better idea would be top write a sample() method for bugs class. This would be the most natural way in my opinion. sample(bugs) ... ________________________________________ From: bug...@li... [bugs-r-devel-bounces@list= s.sourceforge.net] On Behalf Of Andrew Gelman [ge...@st...] Sent: Thursday, October 04, 2007 12:55 AM To: Anon. Cc: bug...@li... Subject: Re: [Bugs-r-devel] R2WinBUGS bug fix I'm confused because bugs has sims.list, sims.matrix, and sims.array, but I don't see sims. In the ?bugs help, it says that "for convenience, the 'n.keep * n.chains' simulations in sims.matrix and sims.list (but NOT sims.array) have been randomly permuted" The reason why we scramble the simulations is so we can more easily access random draws from the posterior distribution. We can then just use the first 10 simulations or the first 100 or whatever to do posterior simulations (see chapter 6 of BDA for various examples). Checking for convergence--which is the same thing as assessing mixing--isn't a problem since we check convergence on the unscrambled series that are in sims.array. You can always use sims.array if you want to work with these. Andrew Anon. wrote: > Uwe Ligges wrote: >> I think this was proposed by Andrew Gelman in the original code and I >> already had the discussion but forgot the outcome (people would like >> to have it randomized?, Andrew?). >> >> Anyway, a fix would be to add drop =3D FALSE as in >> >> sims <- sims [sample(n.sims), , drop =3D FALSE] # scramble (for >> convenience in analysis) >> >> > I'm curious - how can you check for convergence if the order is > randomised? I'm thinking of cases where both chains are moving in the > same direction towards the part of the posterior with high probability > mass. It also makes mixing more difficult to assess, although this is > less critical. > > I would certainly prefer not to have this randomised - there are > disadvantage, and if you want the results randomise, it's easy to do > (hey, it's one line of code!). OTOH, if it's already randomised, it's > difficult to impossible to unscramble it. > > Bob > -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science Director, Applied Statistics Center Columbia University, New York ge...@st... www.stat.columbia.edu/~gelman Usual schedule: Mon, Tues, Fri in Statistics Dept ofc: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 phone 212-851-2142, fax 212-851-2164 Wed, Thurs in Political Science Dept ofc: International Affairs Bldg (Amsterdam Ave at 118 St), Room 731 phone 212-854-7075, fax 212-222-0598 Wed, Thurs from 2:30pm onward in Playroom: International Affairs Bldg, Room 707 I'm out of town 11-12 Oct, 26 Oct, and 15-23 Nov. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Bugs-r-devel mailing list Bug...@li... https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Andrew G. <ge...@st...> - 2007-10-03 22:56:25
|
I'm confused because bugs has sims.list, sims.matrix, and sims.array, but I don't see sims. In the ?bugs help, it says that "for convenience, the 'n.keep * n.chains' simulations in sims.matrix and sims.list (but NOT sims.array) have been randomly permuted" The reason why we scramble the simulations is so we can more easily access random draws from the posterior distribution. We can then just use the first 10 simulations or the first 100 or whatever to do posterior simulations (see chapter 6 of BDA for various examples). Checking for convergence--which is the same thing as assessing mixing--isn't a problem since we check convergence on the unscrambled series that are in sims.array. You can always use sims.array if you want to work with these. Andrew Anon. wrote: > Uwe Ligges wrote: >> I think this was proposed by Andrew Gelman in the original code and I >> already had the discussion but forgot the outcome (people would like >> to have it randomized?, Andrew?). >> >> Anyway, a fix would be to add drop = FALSE as in >> >> sims <- sims [sample(n.sims), , drop = FALSE] # scramble (for >> convenience in analysis) >> >> > I'm curious - how can you check for convergence if the order is > randomised? I'm thinking of cases where both chains are moving in the > same direction towards the part of the posterior with high probability > mass. It also makes mixing more difficult to assess, although this is > less critical. > > I would certainly prefer not to have this randomised - there are > disadvantage, and if you want the results randomise, it's easy to do > (hey, it's one line of code!). OTOH, if it's already randomised, it's > difficult to impossible to unscramble it. > > Bob > -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science Director, Applied Statistics Center Columbia University, New York ge...@st... www.stat.columbia.edu/~gelman Usual schedule: Mon, Tues, Fri in Statistics Dept ofc: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 phone 212-851-2142, fax 212-851-2164 Wed, Thurs in Political Science Dept ofc: International Affairs Bldg (Amsterdam Ave at 118 St), Room 731 phone 212-854-7075, fax 212-222-0598 Wed, Thurs from 2:30pm onward in Playroom: International Affairs Bldg, Room 707 I'm out of town 11-12 Oct, 26 Oct, and 15-23 Nov. |
From: Anon. <bob...@he...> - 2007-10-03 18:42:36
|
Uwe Ligges wrote: > I think this was proposed by Andrew Gelman in the original code and I=20 > already had the discussion but forgot the outcome (people would like to= =20 > have it randomized?, Andrew?). > > Anyway, a fix would be to add drop =3D FALSE as in > > sims <- sims [sample(n.sims), , drop =3D FALSE] # scramble (for=20 > convenience in analysis) > > =20 I'm curious - how can you check for convergence if the order is=20 randomised? I'm thinking of cases where both chains are moving in the=20 same direction towards the part of the posterior with high probability=20 mass. It also makes mixing more difficult to assess, although this is=20 less critical. I would certainly prefer not to have this randomised - there are=20 disadvantage, and if you want the results randomise, it's easy to do=20 (hey, it's one line of code!). OTOH, if it's already randomised, it's=20 difficult to impossible to unscramble it. Bob --=20 Bob O'Hara Department of Mathematics and Statistics P.O. Box 68 (Gustaf H=E4llstr=F6min katu 2b) FIN-00014 University of Helsinki Finland Telephone: +358-9-191 51479 Mobile: +358 50 599 0540 Fax: +358-9-191 51400 WWW: http://www.RNI.Helsinki.FI/~boh/ Blog: http://deepthoughtsandsilliness.blogspot.com/ Journal of Negative Results - EEB: www.jnr-eeb.org |
From: Uwe L. <li...@st...> - 2007-10-03 17:36:45
|
I think this was proposed by Andrew Gelman in the original code and I already had the discussion but forgot the outcome (people would like to have it randomized?, Andrew?). Anyway, a fix would be to add drop = FALSE as in sims <- sims [sample(n.sims), , drop = FALSE] # scramble (for convenience in analysis) Best wishes, Uwe Dawn Woodard wrote: > I found a bug in R2WinBUGS, which can be reproduced using the code below. As > a fix, I propose removing a single line of code in bugs.sims: > > sims <- sims [sample(n.sims),] # scramble (for convenience in analysis) > > This line of code scrambles the samples for each parameter. What is the > reason for doing this? For some reason, when sims is a matrix with a single > column (when the user has requested that only one parameter be returned) this > line changes sims from a matrix object to a vector object. > > Thank you, > Dawn > > > > model.file <- function(){ > for (j in 1:J){ > y[j] ~ dnorm (theta[j], tau.y[j]) > theta[j] ~ dnorm (mu.theta, tau.theta) > tau.y[j] <- pow(sigma.y[j], -2) > } > mu.theta ~ dnorm (0.0, 1.0E-6) > tau.theta <- pow(sigma.theta, -2) > sigma.theta ~ dunif (0, 1000) > } > > > # Some example data (see ?schools for details): > data(schools) > > J <- nrow(schools) > y <- schools$estimate > sigma.y <- schools$sd > data <- list ("J", "y", "sigma.y") > inits <- function(){ > list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100), > sigma.theta=runif(1, 0, 100)) > } > ## or alternatively something like: > # inits <- list( > # list(theta=rnorm(J, 0, 90), mu.theta=rnorm(1, 0, 90), > # sigma.theta=runif(1, 0, 90)), > # list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100), > # sigma.theta=runif(1, 0, 100)) > # list(theta=rnorm(J, 0, 110), mu.theta=rnorm(1, 0, 110), > # sigma.theta=runif(1, 0, 110))) > > parameters <- c("mu.theta") > > ## Not run: > ## You may need to edit "bugs.directory", > ## also you need write access in the working directory: > schools.sim <- bugs(data, inits, parameters, model.file, > n.chains=1, n.iter=5000, > bugs.directory="c:/Program Files/WinBUGS14/", > working.directory=NULL, clearWD=TRUE, DIC = F) > print(schools.sim) > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |