Re: [R] R2WinBUGS results not different with different runs
Gregor Gorjanc wrote: toby909 at gmail.com writes: Is this a specialty with R2WinBUGS? Does it have something to do with the seed value? Isnt the seed value reset everytime I restart winbugs? I always have the same seed if I start WinBUGS multiple times. So you get exactly the same chain, numerically, when rerunning the same model, with the same number of iterations, everything the same.? Wouldnt that be problematic if every researcher in the world who uses winbugs uses the same sequence of random numbers? R's random numbers are different each time, because the seed is linked to the clock in your PC. T Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS results not different with different runs
toby909 at gmail.com writes: Gregor Gorjanc wrote: toby909 at gmail.com writes: Is this a specialty with R2WinBUGS? Does it have something to do with the seed value? Isnt the seed value reset everytime I restart winbugs? I always have the same seed if I start WinBUGS multiple times. So you get exactly the same chain, numerically, when rerunning the same model, with the same number of iterations, everything the same.? I just tried now with Gelman's schools example from bugs() help page. I runned the same job twice, with exactly the same initial values. Notes that WinBUGS uses always the same starting seed. I got this schools.sim$last.values [[1]] [[1]]$theta [1] 23.700 10.060 12.760 13.090 1.693 14.390 7.599 3.961 [[1]]$mu.theta [1] 25.03 [[1]]$sigma.theta [1] 20.08 schools.sim2$last.values [[1]] [[1]]$theta [1] 23.700 10.060 12.760 13.090 1.693 14.390 7.599 3.961 [[1]]$mu.theta [1] 25.03 [[1]]$sigma.theta [1] 20.08 Wouldnt that be problematic if every researcher in the world who uses winbugs uses the same sequence of random numbers? R's random numbers are different each time, because the seed is linked to the clock in your PC. You can reset the seed if you want. Having the same seed is also nice for repeatability. Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBUGS results not different with different runs
Hi All I dont know if anyone else has noticed the same thing, but with 2 subsequent runs of the same syntax, I am getting exactly the same results. I was expecting that results differ slighlty, say in the 4th or 5th decimal place. Is this a specialty with R2WinBUGS? Does it have something to do with the seed value? Isnt the seed value reset everytime I restart winbugs? Thanks Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS results not different with different runs
toby909 at gmail.com writes: Is this a specialty with R2WinBUGS? Does it have something to do with the seed value? Isnt the seed value reset everytime I restart winbugs? I always have the same seed if I start WinBUGS multiple times. Gregor __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS more updates after model did not converge
[EMAIL PROTECTED] wrote: After running a model for a while and seeing that it did not converge yet, how can I continue to run, ie not starting anew, the model? I know if I manually/interactively use winbugs, this is possible anytime, but how can I do this in r2winbugs, so that my existing sim$sims.array and other stuff in the object that bugs() returns gets extended? This is not possible with R2WinBUGS. But you can use BRugs, which is much more flexible, has an improved interface and uses OpenBUGS. It's CRAN version is based on OpenBUGS 2.x.y, but we (i.e. currently mainly Insightful people and myself) are on the way to release a new version based on OpenBUGS 3.x.y. Uwe Ligges Thanks Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBUGS more updates after model did not converge
After running a model for a while and seeing that it did not converge yet, how can I continue to run, ie not starting anew, the model? I know if I manually/interactively use winbugs, this is possible anytime, but how can I do this in r2winbugs, so that my existing sim$sims.array and other stuff in the object that bugs() returns gets extended? Thanks Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS awkward to use
[EMAIL PROTECTED] wrote: Hi All Does anyone know if I can avoid to use the write.model() function below? I dont want to do this. Can't bugs() do that automatically for me just by specifying the 4th argument 'model'? Just I like I am also using the 'inits' object! If I use 'model' in the same way as I use 'inits' I am getting the error: sim - bugs(data, inits, parameters, model, n.chains=1, n.iter=5000, bugs.directory=c:/Program Files/WinBUGS14, working.directory=NULL, clearWD=TRUE, DIC=0) Error in file.exists(c(...)) : invalid 'file' argument The idea is that people in general write their model files more or less while interactively using WinBUGS / OpenBUGS and later on start automizing with R2WinBUGS or BRugs. Then the file already exists. Of course, we can add dome fancy stuff that applies write.model if an expression is given in the argument model. I'll put it on the ToDo list. Best, Uwe Ligges Thanks Toby data - list(.) model - function() { [omitted] } write.model(model, cwk.txt) inits - function() {.} parameters - c(b, nu, S1, S2) sim - bugs(data, inits, parameters, cwk.txt, n.chains=1, n.iter=5000, bugs.directory=c:/Program Files/WinBUGS14, working.directory=NULL, clearWD=TRUE, DIC=0) print(sim) plot(sim) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBUGS awkward to use
Hi All Does anyone know if I can avoid to use the write.model() function below? I dont want to do this. Can't bugs() do that automatically for me just by specifying the 4th argument 'model'? Just I like I am also using the 'inits' object! If I use 'model' in the same way as I use 'inits' I am getting the error: sim - bugs(data, inits, parameters, model, n.chains=1, n.iter=5000, bugs.directory=c:/Program Files/WinBUGS14, working.directory=NULL, clearWD=TRUE, DIC=0) Error in file.exists(c(...)) : invalid 'file' argument Thanks Toby data - list(.) model - function() { [omitted] } write.model(model, cwk.txt) inits - function() {.} parameters - c(b, nu, S1, S2) sim - bugs(data, inits, parameters, cwk.txt, n.chains=1, n.iter=5000, bugs.directory=c:/Program Files/WinBUGS14, working.directory=NULL, clearWD=TRUE, DIC=0) print(sim) plot(sim) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBugs and Compare DIC versus BIC or AIC
Thanks for your answer ! But If I have understood correctly, the procedure is correct and this only means that I have already generated the initial values From R. I define a function to generate the initial values as: inits. - function(){list(sdesp=runif(1),sdhet=runif(1),beta0=runif(1), beta1=runif(1), b=rnorm(n), phi=rnorm(n))} then It is not necessary to generate initial values, that why gen.inits() is greyed out , is it ok? Here is what Winbugs show == display(log) check(D:/model.txt) model is syntactically correct data(D://data.txt) data loaded compile(3) model compiled inits(1,D:/inits1.txt) chain initialized but other chain(s) contain uninitialized variables inits(2,D:/inits2.txt) chain initialized but other chain(s) contain uninitialized variables inits(3,D:/inits3.txt) model is initialized gen.inits() command #Bugs:gen.inits cannot be executed (is greyed out) thin.updater(1) update(5000) == Thank again in advance Dae-Jin 2007/1/13, Uwe Ligges [EMAIL PROTECTED] : Dae-Jin Lee wrote: Dear All 1) I'm fitting spatial CAR models using R2Winbugs and although everything seems to go reasonably well (or I think so) the next message appears from WINBUGS 1.4 window: gen.inits() Command #Bugs: gen.inits cannot be executed (is greyed out) greyed out refers to the corresponding GUI. In this case it could mean that either your preparations before were not successful or you have already specified all initial values and no further have to be generated. But this is a WinBUGS question and not R related. Perhaps you have transposed some matrix? This is always extremely confusing ... The question is if this message means that something is wrong and the results are consequently wrong, or Can I assume it as a simple warning message???... I've tried to fit the model using just WinBugs (not calling form R) and gen.inits command is available and the results obtain are practically the same... 2) The other question is, once several bayesian CAR models are fitted I use DIC to model selection How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean for example: - DIC of 300 and Pd of 32 versus - BIC of 220 and Effective dimension (measured of trace of hat matrix) equal to 14 * I've read that DIC is intended as a generalisation of Akaike's Information Criterion (AIC), but is it possible to compare them simply looking which is the lowest??? Well they are intended to be compared (DIC with DIC, AIC with AIC, but do not mix them!) that way given you are comparing within the same class of models. And then, there is a bit of fortunetelling with all these information criterion, at least in my personal opinion (and I know that others disagree). Uwe Ligges Thanks, Dae-Jin Lee [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBugs and Compare DIC versus BIC or AIC
Dae-Jin Lee wrote: Thanks for your answer ! But If I have understood correctly, the procedure is correct and this only means that I have already generated the initial values From R. I define a function to generate the initial values as: inits. - function(){list(sdesp=runif(1),sdhet=runif(1),beta0=runif(1), beta1=runif(1), b=rnorm(n), phi=rnorm(n))} then It is not necessary to generate initial values, that why gen.inits() is greyed out , is it ok? Yes, alright. Uwe Here is what Winbugs show == display(log) check(D:/model.txt) model is syntactically correct data(D://data.txt) data loaded compile(3) model compiled inits(1,D:/inits1.txt) chain initialized but other chain(s) contain uninitialized variables inits(2,D:/inits2.txt) chain initialized but other chain(s) contain uninitialized variables inits(3,D:/inits3.txt) model is initialized gen.inits() command #Bugs:gen.inits cannot be executed (is greyed out) thin.updater(1) update(5000) == Thank again in advance Dae-Jin 2007/1/13, Uwe Ligges [EMAIL PROTECTED] : Dae-Jin Lee wrote: Dear All 1) I'm fitting spatial CAR models using R2Winbugs and although everything seems to go reasonably well (or I think so) the next message appears from WINBUGS 1.4 window: gen.inits() Command #Bugs: gen.inits cannot be executed (is greyed out) greyed out refers to the corresponding GUI. In this case it could mean that either your preparations before were not successful or you have already specified all initial values and no further have to be generated. But this is a WinBUGS question and not R related. Perhaps you have transposed some matrix? This is always extremely confusing ... The question is if this message means that something is wrong and the results are consequently wrong, or Can I assume it as a simple warning message???... I've tried to fit the model using just WinBugs (not calling form R) and gen.inits command is available and the results obtain are practically the same... 2) The other question is, once several bayesian CAR models are fitted I use DIC to model selection How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean for example: - DIC of 300 and Pd of 32 versus - BIC of 220 and Effective dimension (measured of trace of hat matrix) equal to 14 * I've read that DIC is intended as a generalisation of Akaike's Information Criterion (AIC), but is it possible to compare them simply looking which is the lowest??? Well they are intended to be compared (DIC with DIC, AIC with AIC, but do not mix them!) that way given you are comparing within the same class of models. And then, there is a bit of fortunetelling with all these information criterion, at least in my personal opinion (and I know that others disagree). Uwe Ligges Thanks, Dae-Jin Lee [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBugs and Compare DIC versus BIC or AIC
Dae-Jin Lee wrote: Dear All 1) I'm fitting spatial CAR models using R2Winbugs and although everything seems to go reasonably well (or I think so) the next message appears from WINBUGS 1.4 window: gen.inits() Command #Bugs: gen.inits cannot be executed (is greyed out) greyed out refers to the corresponding GUI. In this case it could mean that either your preparations before were not successful or you have already specified all initial values and no further have to be generated. But this is a WinBUGS question and not R related. Perhaps you have transposed some matrix? This is always extremely confusing ... The question is if this message means that something is wrong and the results are consequently wrong, or Can I assume it as a simple warning message???... I've tried to fit the model using just WinBugs (not calling form R) and gen.inits command is available and the results obtain are practically the same... 2) The other question is, once several bayesian CAR models are fitted I use DIC to model selection How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean for example: - DIC of 300 and Pd of 32 versus - BIC of 220 and Effective dimension (measured of trace of hat matrix) equal to 14 * I've read that DIC is intended as a generalisation of Akaike's Information Criterion (AIC), but is it possible to compare them simply looking which is the lowest??? Well they are intended to be compared (DIC with DIC, AIC with AIC, but do not mix them!) that way given you are comparing within the same class of models. And then, there is a bit of fortunetelling with all these information criterion, at least in my personal opinion (and I know that others disagree). Uwe Ligges Thanks, Dae-Jin Lee [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBugs and Compare DIC versus BIC or AIC
Dear All 1) I'm fitting spatial CAR models using R2Winbugs and although everything seems to go reasonably well (or I think so) the next message appears from WINBUGS 1.4 window: gen.inits() Command #Bugs: gen.inits cannot be executed (is greyed out) The question is if this message means that something is wrong and the results are consequently wrong, or Can I assume it as a simple warning message???... I've tried to fit the model using just WinBugs (not calling form R) and gen.inits command is available and the results obtain are practically the same... 2) The other question is, once several bayesian CAR models are fitted I use DIC to model selection How can I compare DIC with AIC or BIC obtain for a spatial glm? I mean for example: - DIC of 300 and Pd of 32 versus - BIC of 220 and Effective dimension (measured of trace of hat matrix) equal to 14 * I've read that DIC is intended as a generalisation of Akaike's Information Criterion (AIC), but is it possible to compare them simply looking which is the lowest??? Thanks, Dae-Jin Lee [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS and calling WinBUGS in Crossover MAC BETA
Ben Bolker wrote: Kenneth Benoit kbenoit at tcd.ie writes: Hi there - I have a question for any of you who use R2WinBUGS to call WinBUGS using the useWINE option in that package. I have Codeweaver's Crossover emulator installed on my Intel Mac with WinBUGS working fine if I start it from Crossover. But there is supposed to be a way to start it directly from a command line, which I could pass to the R2WinBUGS using the bugs(..., useWINE=something) argument. Has anyone tried this yet? Thanks! useWINE=TRUE. You may have to set some environment variables (e.g. WINE is the path to your WINE executable). It's supposed to just work out of the box. I have some fixes that I've been meaning to upload to complement the existing stuff, but haven't. If you run into trouble drop me a line. Ben Bolker Many thanks for that quick reply. I have tried useWINE=TRUE but this does not work on the Mac. I am using CrossOver for Mac Beta (6.0.0b2). When I call: bugs(..., useWINE=TRUE, newWINE=TRUE) then I get this message: Error in if (!nchar(WINEPATH)) { : argument is of length zero I think the problem is that the command line call for cxoffice (similar to wine) is different on the Mac from the Linux version. For instance I have the following application bundles: /Applications/CrossOver.app/ ~/Applications/CrossOver/WinBUGS14.app but I cannot figure out how to start WinBUGS14.app from the command line. If I did then I could supply this command to bugs(..., WINE=). Best, Ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBUGS - parameter monitor seting
R2WinBUGS users, I'm getting the error message monitor could not be set when I try to monitor (and output to R) a response variable that includes missing data (NAs)...ie.e imputing for y. Setting monitors for other parameters works OK and running the R-generated WinBUGS script file in WinBUGS, also works OK. Below is my R code and the log.txt file output by R2WinBUGS. As I want to run this model 100+ times, i'd prefer to write some looping code rather than cut and paste 100 times..can anyone help? thanks doug R-code: bayesimp.sim - bugs(data, inits, parameters,bayesimp.bug, n.chains = 1, n.iter = 4000, bugs.directory = c:/Program Files/WinBUGS14/, working.directory = NULL, clearWD = TRUE, debug = TRUE) script.txt: display ('log') check ('D:/Work/SpatialEpi/Water/THM Imputation/Rwork/bayesimp.txt') data ('D:/Work/SpatialEpi/Water/THM Imputation/Rwork/data.txt') compile (1) inits (1, 'D:/Work/SpatialEpi/Water/THM Imputation/Rwork/inits1.txt') gen.inits() thin.updater (2) update (1000) set (y) set (u) set (deviance) dic.set() update (1000) coda (*, 'D:/Work/SpatialEpi/Water/THM Imputation/Rwork/coda') stats (*) dic.stats() history (*, 'D:/Work/SpatialEpi/Water/THM Imputation/Rwork/history.odc') save ('D:/Work/SpatialEpi/Water/THM Imputation/Rwork/log.odc') save ('D:/Work/SpatialEpi/Water/THM Imputation/Rwork/log.txt') log.txt: display(log) check(D:/Work/SpatialEpi/Water/THM Imputation/Rwork/bayesimp.txt) model is syntactically correct data(D:/Work/SpatialEpi/Water/THM Imputation/Rwork/data.txt) data loaded compile(1) model compiled inits(1,D:/Work/SpatialEpi/Water/THM Imputation/Rwork/inits1.txt) this chain contains uninitialized variables gen.inits() initial values generated, model initialized thin.updater(2) update(1000) set(y) monitor could not be set set(u) set(deviance) dic.set() update(1000) coda(*,D:/Work/SpatialEpi/Water/THM Imputation/Rwork/coda) stats(*) This email and any files transmitted with it are confidentia...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBugs
We had set R2WinBugs to use the burnin as the adaptive phase. I think this was changed very slightly in the latest version of R2WinBUGS so that the adaptive phase would equal burnin minus 1. This was to allow DIC to be calculated. So I think it should work OK now. If you send an example I can take a look. Andrew Uwe Ligges wrote: Bowden, J.M. wrote: Hi all, I am having problems using the R2Winbugs function When I perform an analysis directly in Winbugs I can specify that the first 'n' iterations are to be done using an 'adaptive' phase. After this phase the markov chain seems to mix a lot better. I don't seem to be able to specify R2winbugs to carry out this adaptive phase, I can just specify the burnin length but this (to my knowledge) is not the same thing. As a result my models are not fitting as well as I would like, has anyone had a similar experience? I think this is a question for Andrew Gelman (CCing), who wrote the underlying code for automatically setting the adaptive phase. Uwe Ligges Jack __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science [EMAIL PROTECTED] www.stat.columbia.edu/~gelman Statistics department office: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 212-851-2142 Political Science department office: International Affairs Bldg (Amsterdam Ave at 118 St), Room 731 212-854-7075 Mailing address: 1255 Amsterdam Ave, Room 1016 Columbia University New York, NY 10027-5904 212-851-2142 (fax) 212-851-2164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R2WinBugs
Hi all, I am having problems using the R2Winbugs function When I perform an analysis directly in Winbugs I can specify that the first 'n' iterations are to be done using an 'adaptive' phase. After this phase the markov chain seems to mix a lot better. I don't seem to be able to specify R2winbugs to carry out this adaptive phase, I can just specify the burnin length but this (to my knowledge) is not the same thing. As a result my models are not fitting as well as I would like, has anyone had a similar experience? Jack __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBugs
Bowden, J.M. wrote: Hi all, I am having problems using the R2Winbugs function When I perform an analysis directly in Winbugs I can specify that the first 'n' iterations are to be done using an 'adaptive' phase. After this phase the markov chain seems to mix a lot better. I don't seem to be able to specify R2winbugs to carry out this adaptive phase, I can just specify the burnin length but this (to my knowledge) is not the same thing. As a result my models are not fitting as well as I would like, has anyone had a similar experience? I think this is a question for Andrew Gelman (CCing), who wrote the underlying code for automatically setting the adaptive phase. Uwe Ligges Jack __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R2WinBUGS error
Joseph Retzer wrote: Dear R-help, I'm using the R2WinBUGS package and getting an error message: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt', reason 'No such file or directory' Looks like there was an error in WinBUGS: R cannot access the file, because WinBUGS has not written it before. You can use bugs(.., debug = TRUE) Then WinBUGS stays open and you can look at its error messages in order to correct the code/data/inits or whatever Uwe Ligges I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code and WinBUGS code is given below. The complete WinBUGS program executes correctly in WinBUGS however I'm generating some of my inits using WinBUGS so I may be making an error there. On the other hand, the error generated in R seems to imply it cannot locate a file. I've checked my paths and they are correct. Also, my data is loading correctly. Many thanks, Joe # # R code # Runs Bayesian Ordered Logit by calling WinBUGS from R # ologit2.txt: WinBUGS commands library(R2WinBUGS) setwd(c:/docume~1/admini~1/mydocu~1/r_tuto~1) load(oldat.Rdata) # R data file containing data frame ol.dat # with vars: q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2 q02 -ol.dat$q02 bf23f - ol.dat$bf23f bf23b - ol.dat$bf23b bf22 - ol.dat$bf22 bf34a - ol.dat$bf34a bf34.1 - ol.dat$bf34.1 bf34.2 - ol.dat$bf34.2 N=nrow(ol.dat) Ncut=5 data - list(N, q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2, Ncut) inits - function() { list(k=c(-5, -4, -3, -2, -1), tau=2, theta=rnorm(7, -1, 100)) } parameters - c(k) olog.out - bugs(data, inits, parameters, model.file=c:/Documents and Settings/Administrator/My Documents/r_tutorial/ologit2.txt, n.chains = 2, n.iter = 1000, bugs.directory = c:/Program Files/WinBUGS14/) # WinBUGS code model exec; { # Priors on regression coefficients theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0) theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0) theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0) theta[7] ~ dnorm( -1,1.0) # Priors on latent variable cutpoints k[1] ~ dnorm(0, 0.1)I(, k[2]); k[2] ~ dnorm(0, 0.1)I(k[1], k[3]) k[3] ~ dnorm(0, 0.1)I(k[2], k[4]); k[4] ~ dnorm(0, 0.1)I(k[3], k[5]) k[5] ~ dnorm(0, 0.1)I(k[4], ) # Prior on precision tau ~ dgamma(0.001, 0.001) # Some defs sigma - sqrt(1 / tau); log.sigma - log(sigma); for (i in 1 : N) { # Prior on b[i] ~ dnorm(0.0, tau) # Model Mean mu[i] - theta[1] + theta[2]*bf22[i] + theta[3]*bf23b[i] + theta[4]*bf23f[i] + theta[5]*bf34a[i] + theta[6]*bf34.1[i] + theta[7]*bf34.2[i] for (j in 1 : Ncut) { # Logit Model # cumulative probability of lower response than j logit(Q[i, j]) - -(k[j] + mu[i] + b[i]) } # probability that response = j p[i,1] - max( min(1 - Q[i,1], 1), 0) for (j in 2 : Ncut) { p[i,j] - max( min(Q[i,j-1] - Q[i,j],1), 0) } p[i,(Ncut+1)] - max( min(Q[i,Ncut], 1), 0) q02[i] ~ dcat(p[i, ]) } } [[alternative HTML version deleted]] __ 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 __ 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
Re: [R] R2WinBUGS error Solved, THANK YOU!
Thanks very much Uwe! There was a problem reading my data which I would not have discovered without careful examination of the WinBUGS log file. The program is working now! Take care, Joe -Original Message- From: Uwe Ligges [mailto:[EMAIL PROTECTED] Sent: Thursday, April 06, 2006 1:30 AM To: Joseph Retzer Cc: r-help@stat.math.ethz.ch Subject: Re: [R] R2WinBUGS error Joseph Retzer wrote: Dear R-help, I'm using the R2WinBUGS package and getting an error message: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt', reason 'No such file or directory' Looks like there was an error in WinBUGS: R cannot access the file, because WinBUGS has not written it before. You can use bugs(.., debug = TRUE) Then WinBUGS stays open and you can look at its error messages in order to correct the code/data/inits or whatever Uwe Ligges I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code and WinBUGS code is given below. The complete WinBUGS program executes correctly in WinBUGS however I'm generating some of my inits using WinBUGS so I may be making an error there. On the other hand, the error generated in R seems to imply it cannot locate a file. I've checked my paths and they are correct. Also, my data is loading correctly. Many thanks, Joe # # R code # Runs Bayesian Ordered Logit by calling WinBUGS from R # ologit2.txt: WinBUGS commands library(R2WinBUGS) setwd(c:/docume~1/admini~1/mydocu~1/r_tuto~1) load(oldat.Rdata) # R data file containing data frame ol.dat # with vars: q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2 q02 -ol.dat$q02 bf23f - ol.dat$bf23f bf23b - ol.dat$bf23b bf22 - ol.dat$bf22 bf34a - ol.dat$bf34a bf34.1 - ol.dat$bf34.1 bf34.2 - ol.dat$bf34.2 N=nrow(ol.dat) Ncut=5 data - list(N, q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2, Ncut) inits - function() { list(k=c(-5, -4, -3, -2, -1), tau=2, theta=rnorm(7, -1, 100)) } parameters - c(k) olog.out - bugs(data, inits, parameters, model.file=c:/Documents and Settings/Administrator/My Documents/r_tutorial/ologit2.txt, n.chains = 2, n.iter = 1000, bugs.directory = c:/Program Files/WinBUGS14/) # WinBUGS code model exec; { # Priors on regression coefficients theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0) theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0) theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0) theta[7] ~ dnorm( -1,1.0) # Priors on latent variable cutpoints k[1] ~ dnorm(0, 0.1)I(, k[2]); k[2] ~ dnorm(0, 0.1)I(k[1], k[3]) k[3] ~ dnorm(0, 0.1)I(k[2], k[4]); k[4] ~ dnorm(0, 0.1)I(k[3], k[5]) k[5] ~ dnorm(0, 0.1)I(k[4], ) # Prior on precision tau ~ dgamma(0.001, 0.001) # Some defs sigma - sqrt(1 / tau); log.sigma - log(sigma); for (i in 1 : N) { # Prior on b[i] ~ dnorm(0.0, tau) # Model Mean mu[i] - theta[1] + theta[2]*bf22[i] + theta[3]*bf23b[i] + theta[4]*bf23f[i] + theta[5]*bf34a[i] + theta[6]*bf34.1[i] + theta[7]*bf34.2[i] for (j in 1 : Ncut) { # Logit Model # cumulative probability of lower response than j logit(Q[i, j]) - -(k[j] + mu[i] + b[i]) } # probability that response = j p[i,1] - max( min(1 - Q[i,1], 1), 0) for (j in 2 : Ncut) { p[i,j] - max( min(Q[i,j-1] - Q[i,j],1), 0) } p[i,(Ncut+1)] - max( min(Q[i,Ncut], 1), 0) q02[i] ~ dcat(p[i, ]) } } [[alternative HTML version deleted]] __ 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 __ 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
[R] R2WinBUGS error
Dear R-help, I'm using the R2WinBUGS package and getting an error message: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt', reason 'No such file or directory' I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code and WinBUGS code is given below. The complete WinBUGS program executes correctly in WinBUGS however I'm generating some of my inits using WinBUGS so I may be making an error there. On the other hand, the error generated in R seems to imply it cannot locate a file. I've checked my paths and they are correct. Also, my data is loading correctly. Many thanks, Joe # # R code # Runs Bayesian Ordered Logit by calling WinBUGS from R # ologit2.txt: WinBUGS commands library(R2WinBUGS) setwd(c:/docume~1/admini~1/mydocu~1/r_tuto~1) load(oldat.Rdata) # R data file containing data frame ol.dat # with vars: q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2 q02 -ol.dat$q02 bf23f - ol.dat$bf23f bf23b - ol.dat$bf23b bf22 - ol.dat$bf22 bf34a - ol.dat$bf34a bf34.1 - ol.dat$bf34.1 bf34.2 - ol.dat$bf34.2 N=nrow(ol.dat) Ncut=5 data - list(N, q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2, Ncut) inits - function() { list(k=c(-5, -4, -3, -2, -1), tau=2, theta=rnorm(7, -1, 100)) } parameters - c(k) olog.out - bugs(data, inits, parameters, model.file=c:/Documents and Settings/Administrator/My Documents/r_tutorial/ologit2.txt, n.chains = 2, n.iter = 1000, bugs.directory = c:/Program Files/WinBUGS14/) # WinBUGS code model exec; { # Priors on regression coefficients theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0) theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0) theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0) theta[7] ~ dnorm( -1,1.0) # Priors on latent variable cutpoints k[1] ~ dnorm(0, 0.1)I(, k[2]); k[2] ~ dnorm(0, 0.1)I(k[1], k[3]) k[3] ~ dnorm(0, 0.1)I(k[2], k[4]); k[4] ~ dnorm(0, 0.1)I(k[3], k[5]) k[5] ~ dnorm(0, 0.1)I(k[4], ) # Prior on precision tau ~ dgamma(0.001, 0.001) # Some defs sigma - sqrt(1 / tau); log.sigma - log(sigma); for (i in 1 : N) { # Prior on b[i] ~ dnorm(0.0, tau) # Model Mean mu[i] - theta[1] + theta[2]*bf22[i] + theta[3]*bf23b[i] + theta[4]*bf23f[i] + theta[5]*bf34a[i] + theta[6]*bf34.1[i] + theta[7]*bf34.2[i] for (j in 1 : Ncut) { # Logit Model # cumulative probability of lower response than j logit(Q[i, j]) - -(k[j] + mu[i] + b[i]) } # probability that response = j p[i,1] - max( min(1 - Q[i,1], 1), 0) for (j in 2 : Ncut) { p[i,j] - max( min(Q[i,j-1] - Q[i,j],1), 0) } p[i,(Ncut+1)] - max( min(Q[i,Ncut], 1), 0) q02[i] ~ dcat(p[i, ]) } } [[alternative HTML version deleted]] __ 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
Re: [R] R2WinBUGS error
Dear R-help, I'm using the R2WinBUGS package and getting an error message: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt', reason 'No such file or directory' I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code and WinBUGS code is given below. The complete WinBUGS program executes correctly in WinBUGS however I'm generating some of my inits using WinBUGS so I may be making an error there. On the other hand, the error generated in R seems to imply it cannot locate a file. I've checked my paths and they are correct. Also, my data is loading correctly. Many thanks, Joe # # R code # Runs Bayesian Ordered Logit by calling WinBUGS from R # ologit2.txt: WinBUGS commands library(R2WinBUGS) setwd(c:/docume~1/admini~1/mydocu~1/r_tuto~1) load(oldat.Rdata) # R data file containing data frame ol.dat # with vars: q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2 q02 -ol.dat$q02 bf23f - ol.dat$bf23f bf23b - ol.dat$bf23b bf22 - ol.dat$bf22 bf34a - ol.dat$bf34a bf34.1 - ol.dat$bf34.1 bf34.2 - ol.dat$bf34.2 N=nrow(ol.dat) Ncut=5 data - list(N, q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2, Ncut) inits - function() { list(k=c(-5, -4, -3, -2, -1), tau=2, theta=rnorm(7, -1, 100)) } parameters - c(k) olog.out - bugs(data, inits, parameters, model.file=c:/Documents and Settings/Administrator/My Documents/r_tutorial/ologit2.txt, n.chains = 2, n.iter = 1000, bugs.directory = c:/Program Files/WinBUGS14/) # WinBUGS code model exec; { # Priors on regression coefficients theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0) theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0) theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0) theta[7] ~ dnorm( -1,1.0) # Priors on latent variable cutpoints k[1] ~ dnorm(0, 0.1)I(, k[2]); k[2] ~ dnorm(0, 0.1)I(k[1], k[3]) k[3] ~ dnorm(0, 0.1)I(k[2], k[4]); k[4] ~ dnorm(0, 0.1)I(k[3], k[5]) k[5] ~ dnorm(0, 0.1)I(k[4], ) # Prior on precision tau ~ dgamma(0.001, 0.001) # Some defs sigma - sqrt(1 / tau); log.sigma - log(sigma); for (i in 1 : N) { # Prior on b[i] ~ dnorm(0.0, tau) # Model Mean mu[i] - theta[1] + theta[2]*bf22[i] + theta[3]*bf23b[i] + theta[4]*bf23f[i] + theta[5]*bf34a[i] + theta[6]*bf34.1[i] + theta[7]*bf34.2[i] for (j in 1 : Ncut) { # Logit Model # cumulative probability of lower response than j logit(Q[i, j]) - -(k[j] + mu[i] + b[i]) } # probability that response = j p[i,1] - max( min(1 - Q[i,1], 1), 0) for (j in 2 : Ncut) { p[i,j] - max( min(Q[i,j-1] - Q[i,j],1), 0) } p[i,(Ncut+1)] - max( min(Q[i,Ncut], 1), 0) q02[i] ~ dcat(p[i, ]) } } [[alternative HTML version deleted]] __ 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
[R] R2WinBUGS erro
Dear R-help, I'm using the R2WinBUGS package and getting an error message: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt', reason 'No such file or directory' I'm using R 2.2.1 and WinBUGS 1.4.1 on a windows machine (XP). My R code and WinBUGS code is given below. The complete WinBUGS program executes correctly in WinBUGS however I'm generating some of my inits using WinBUGS so I may be making an error there. On the other hand, the error generated in R seems to imply it cannot locate a file. I've checked my paths and they are correct. Also, my data is loading correctly. Many thanks, Joe # # R code # Runs Bayesian Ordered Logit by calling WinBUGS from R # ologit2.txt: WinBUGS commands library(R2WinBUGS) setwd(c:/docume~1/admini~1/mydocu~1/r_tuto~1) load(oldat.Rdata) # R data file containing data frame ol.dat # with vars: q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2 q02 -ol.dat$q02 bf23f - ol.dat$bf23f bf23b - ol.dat$bf23b bf22 - ol.dat$bf22 bf34a - ol.dat$bf34a bf34.1 - ol.dat$bf34.1 bf34.2 - ol.dat$bf34.2 N=nrow(ol.dat) Ncut=5 data - list(N, q02, bf23f, bf23b, bf22, bf34a, bf34.1, bf34.2, Ncut) inits - function() { list(k=c(-5, -4, -3, -2, -1), tau=2, theta=rnorm(7, -1, 100)) } parameters - c(k) olog.out - bugs(data, inits, parameters, model.file=c:/Documents and Settings/Administrator/My Documents/r_tutorial/ologit2.txt, n.chains = 2, n.iter = 1000, bugs.directory = c:/Program Files/WinBUGS14/) # WinBUGS code model exec; { # Priors on regression coefficients theta[1] ~ dnorm( -1,1.0) ; theta[2] ~ dnorm(-1,1.0) theta[3] ~ dnorm( 1,1.0) ; theta[4] ~ dnorm(-1,1.0) theta[5] ~ dnorm( -1,1.0) ; theta[6] ~ dnorm( 1,1.0) theta[7] ~ dnorm( -1,1.0) # Priors on latent variable cutpoints k[1] ~ dnorm(0, 0.1)I(, k[2]); k[2] ~ dnorm(0, 0.1)I(k[1], k[3]) k[3] ~ dnorm(0, 0.1)I(k[2], k[4]); k[4] ~ dnorm(0, 0.1)I(k[3], k[5]) k[5] ~ dnorm(0, 0.1)I(k[4], ) # Prior on precision tau ~ dgamma(0.001, 0.001) # Some defs sigma - sqrt(1 / tau); log.sigma - log(sigma); for (i in 1 : N) { # Prior on b[i] ~ dnorm(0.0, tau) # Model Mean mu[i] - theta[1] + theta[2]*bf22[i] + theta[3]*bf23b[i] + theta[4]*bf23f[i] + theta[5]*bf34a[i] + theta[6]*bf34.1[i] + theta[7]*bf34.2[i] for (j in 1 : Ncut) { # Logit Model # cumulative probability of lower response than j logit(Q[i, j]) - -(k[j] + mu[i] + b[i]) } # probability that response = j p[i,1] - max( min(1 - Q[i,1], 1), 0) for (j in 2 : Ncut) { p[i,j] - max( min(Q[i,j-1] - Q[i,j],1), 0) } p[i,(Ncut+1)] - max( min(Q[i,Ncut], 1), 0) q02[i] ~ dcat(p[i, ]) } } [[alternative HTML version deleted]] __ 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
Re: [R] R2WinBUGS - formating data for winbugs
Chris Behr wrote: I am currently running analyses in winbugs with two different formats of data: matrix and list. The data in the list have different dimensions than the matrix. Do I need to create a single format for entry into R which R passes to WinBUGS? It is not quite clear to me what you mean, you have to be more precise and give some code example (possibly in a private mail to Sibylle Sturtz or me). I guess you need to have to types of objects inR that you want to pass to WinBUGS, in this case, simply specify a list of those objects as the data argument to the bugs() function. Uwe Ligges Thanks, Chris Christopher Behr Principal Analyst eDesign Dynamics www.edesigndynamics.com 4024 Calvert St. NW Washington DC 20007 (202) 298-6437 (t/f) (551) 998-4823 (c) __ 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 __ 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
[R] R2WinBUGS - formating data for winbugs
I am currently running analyses in winbugs with two different formats of data: matrix and list. The data in the list have different dimensions than the matrix. Do I need to create a single format for entry into R which R passes to WinBUGS? Thanks, Chris Christopher Behr Principal Analyst eDesign Dynamics www.edesigndynamics.com 4024 Calvert St. NW Washington DC 20007 (202) 298-6437 (t/f) (551) 998-4823 (c) __ 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
[R] R2WinBUGS: Comparison to WinBUGS
Hi R-Users! I know I posted the question before (see archives) but I have not been able to find the mistake. Again using R2WinBUGS and WinBUGS does not yield the same result (although to my opinion the commands are the same). The variance of the parameters is much bigger and the parameter estimates are a bit different, too. If anybody has the time and interest to get the files and data and see if he/she has the same problems, I would be happy to provide these (and to discuss it further). It seems though that it must be my mistake SOMEWHERE because nobody else reported any problems yet... Thanks. Hadassa -- Hadassa Brunschwig Birmannsgasse 10A CH-4055 Basel Switzerland Phone: +41 78 797 6065 Email: [EMAIL PROTECTED] __ 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
Re: [R] R2WinBUGS: Comparison to WinBUGS
Hadassa Brunschwig wrote: Hi R-Users! I know I posted the question before (see archives) but I have not been able to find the mistake. Again using R2WinBUGS and WinBUGS does not yield the same result (although to my opinion the commands are the same). The variance of the parameters is much bigger and the parameter estimates are a bit different, too. If anybody has the time and interest to get the files and data and see if he/she has the same problems, I would be happy to provide these (and to discuss it further). It seems though that it must be my mistake SOMEWHERE because nobody else reported any problems yet... Thanks. Hadassa Please send me your data in a private message. Perhaps we (let me include Sibylle Sturtz here, since she certainly knows better) find some time during the next week to look into it. Uwe Ligges __ 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
[R] R2WinBUGS: Comparison to WinBUGS
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!! -- Hadassa Brunschwig Birmannsgasse 10A CH-4055 Basel Switzerland Phone: +41 78 797 6065 Email: [EMAIL PROTECTED] __ 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
Re: [R] R2WinBUGS: Data loading error
Hadassa Brunschwig wrote: Hi R-Help! I am trying to use R2WinBUGS but I get the following error message in WinBUGS (and there must be something wrong with my R statement as I tried it directly in WinBUGS and it worked): display(log) check(C:/Documents and Settings/Daikon/Roche/pop_model.txt) model is syntactically correct data(C:/Documents and Settings/Daikon/Roche/data.txt) expected key word structure compile(7) ...(and of course nothing works after that) and when I close WinBUGS i get: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt' Does anyone know what this 'expected key word structure' means? This is my R code (and I guess my model file is ok): modelA - c(C:/Documents and Settings/Daikon/Roche/pop_model.txt) n - length(unique(subsetA$subject))#number of subjects nt - 13 #number of days Y - subsetA$concentr #concentration per day/subject t - 1:13 #days dataA - list(n,nt,Y,t) parameters - c(tau,C0,st90,C0.pop,st90.pop,tau.cpop,tau.stpop) inits - list(tau=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),C0=5,st90=4,C0.pop=5,st90.pop=4,tau.cpop=0.2,tau.stpop=1) mcmcA - bugs(dataA,inits,parameters,modelA,debug=T,n.chains=7,bugs.directory=c:/Program Files/WinBUGS14,working.directory=C:/Documents and Settings/Daikon/Roche) Which versions of R, WinBUGS and R2WinBUGS? Your example is not reproducible for us. I'd take a look whether dimensions are OK and whether subsetA$concentr is in appropriate object, but without data and model file I am unable to help for the data part. For the inits part, please see ?bugs: inits: a list with n.chains elements; each element of the list is itself a list of starting values for the WinBUGS model, or a function creating (possibly random) initial values. Alternatively, if inits = NULL, initial values are generated by WinBUGS Looks like you want to have the same inits for each chain. In order not to repeat the inits 7 times, you might want to specify them simply as a function such as: inits - function(){ list(tau = rep(1, 17), C0 = 5, st90 = 4, C0.pop = 5, st90.pop = 4, tau.cpop = 0.2, tau.stpop = 1) } Uwe Ligges [Further correspondence on this particular topic, please respond to to the package maintainer (Sibylle) and me directly rather than to R-help.] Thanks so much... Hadassa __ 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
Re: [R] R2WinBUGS: Data loading error
Thank you for your answer. I found out the mistake and it finally works!! Hadassa -- Hadassa Brunschwig Birmannsgasse 10A CH-4055 Basel Switzerland Phone: +41 78 797 6065 Email: [EMAIL PROTECTED] Quoting Uwe Ligges [EMAIL PROTECTED]: Hadassa Brunschwig wrote: Hi R-Help! I am trying to use R2WinBUGS but I get the following error message in WinBUGS (and there must be something wrong with my R statement as I tried it directly in WinBUGS and it worked): display(log) check(C:/Documents and Settings/Daikon/Roche/pop_model.txt) model is syntactically correct data(C:/Documents and Settings/Daikon/Roche/data.txt) expected key word structure compile(7) ...(and of course nothing works after that) and when I close WinBUGS i get: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'codaIndex.txt' Does anyone know what this 'expected key word structure' means? This is my R code (and I guess my model file is ok): modelA - c(C:/Documents and Settings/Daikon/Roche/pop_model.txt) n - length(unique(subsetA$subject))#number of subjects nt - 13 #number of days Y - subsetA$concentr #concentration per day/subject t - 1:13 #days dataA - list(n,nt,Y,t) parameters - c(tau,C0,st90,C0.pop,st90.pop,tau.cpop,tau.stpop) inits - list(tau=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),C0=5,st90=4,C0.pop=5,st90.pop=4,tau.cpop=0.2,tau.stpop=1) mcmcA - bugs(dataA,inits,parameters,modelA,debug=T,n.chains=7,bugs.directory=c:/Program Files/WinBUGS14,working.directory=C:/Documents and Settings/Daikon/Roche) Which versions of R, WinBUGS and R2WinBUGS? Your example is not reproducible for us. I'd take a look whether dimensions are OK and whether subsetA$concentr is in appropriate object, but without data and model file I am unable to help for the data part. For the inits part, please see ?bugs: inits: a list with n.chains elements; each element of the list is itself a list of starting values for the WinBUGS model, or a function creating (possibly random) initial values. Alternatively, if inits = NULL, initial values are generated by WinBUGS Looks like you want to have the same inits for each chain. In order not to repeat the inits 7 times, you might want to specify them simply as a function such as: inits - function(){ list(tau = rep(1, 17), C0 = 5, st90 = 4, C0.pop = 5, st90.pop = 4, tau.cpop = 0.2, tau.stpop = 1) } Uwe Ligges [Further correspondence on this particular topic, please respond to to the package maintainer (Sibylle) and me directly rather than to R-help.] Thanks so much... Hadassa __ 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