From: Gorjanc G. <Gre...@bf...> - 2008-09-10 06:50:13
|
... >>> 1. The working.directory is assumed to be the same directory as the >>> model.file and setting working.directory to something else doesn't help. >> >> Working directory and model.file can be in separate directories, you >> can you tell me an example where it does not work. >> > Doesn't work. See below: > > > schools.sim <- bugs (data, inits, parameters, > "/usr/local/doc/r2winbugs/schools.bug", > + n.chains=3, n.iter=1000, working.directory=".") > Warning message: > In file.create(to[okay]) : > cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason > 'Permission denied' Rodney, this is a problem with permissions and not with R2WinBUGS! /usr/local/doc folders are usually not writable for regular users. If you want to avoid this problem, you can do either: A. Put modelfile somewhere else. If there will be many users (say a whole class), you do not want that they will be overwritting the same files, do you? Putting the modelfile to a home folder of each user, makes much more sense. B. You also might change the permissions of the /usr/local/doc/r2winbugs/ folder. Actually, this is needed since the R2WinBUGS package changes some parameters related to burnin and metropolis acceptance rate in a file that resides in /usr/local/doc/r2winbugs/. I am not really aware what actually is done, since the code was written by Andrew Gelman and I just make it sure that some bits run under linux. So my recommendation is: - change permissions in /usr/local/doc/r2winbugs/ via chmod -R uga+w /usr/local/doc/r2winbugs/ - make sure that each user is using its own modelfile Regards, Gregor |
From: Rodney S. <rsp...@mc...> - 2008-09-10 13:40:18
|
Gorjanc Gregor wrote: > ... > >>>> 1. The working.directory is assumed to be the same directory as the >>>> model.file and setting working.directory to something else doesn't help. >>>> >>> Working directory and model.file can be in separate directories, you >>> can you tell me an example where it does not work. >>> >>> >> Doesn't work. See below: >> >> > schools.sim <- bugs (data, inits, parameters, >> "/usr/local/doc/r2winbugs/schools.bug", >> + n.chains=3, n.iter=1000, working.directory=".") >> Warning message: >> In file.create(to[okay]) : >> cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason >> 'Permission denied' >> > > Rodney, this is a problem with permissions and not with R2WinBUGS! /usr/local/doc folders > are usually not writable for regular users. If you want to avoid this problem, you can do either: > > A. Put modelfile somewhere else. If there will be many users (say a whole class), you do not want > that they will be overwritting the same files, do you? Putting the modelfile to a home folder of each > user, makes much more sense. > > B. You also might change the permissions of the /usr/local/doc/r2winbugs/ folder. Actually, this is needed > since the R2WinBUGS package changes some parameters related to burnin and metropolis acceptance rate in > a file that resides in /usr/local/doc/r2winbugs/. I am not really aware what actually is done, since the code > was written by Andrew Gelman and I just make it sure that some bits run under linux. > > So my recommendation is: > - change permissions in /usr/local/doc/r2winbugs/ via chmod -R uga+w /usr/local/doc/r2winbugs/ > > - make sure that each user is using its own modelfile > > Regards, Gregor > Hi Gregor: My current working directory is $HOME which is writeable. R2WinBUGS is ignoring that and using the directory of the source file. Attempting to over-ride this behavior with working-directory does not workaround the problem. Please fix. Thanks, Rodney -- Rodney Sparapani Center for Patient Care & Outcomes Research (PCOR) Sr. Biostatistician Department of Medicine Was 'Name That Tune' rigged? Medical College of Wisconsin (MCW) WWLD: What Would Lombardi Do Milwaukee, WI, USA |
From: Gorjanc G. <Gre...@bf...> - 2008-09-10 19:47:17
|
Hi Rodney, > My current working directory is $HOME which is writeable. > R2WinBUGS is ignoring that and using the directory of the source file. > Attempting to over-ride this behavior with working-directory does not > workaround the problem. Please fix. Can you please post a reproducible example so that we can check what is going on. gg |
From: Rodney S. <rsp...@mc...> - 2008-09-10 19:58:17
|
Gorjanc Gregor wrote: > > Can you please post a reproducible example so that we can check what > is going on. > > gg > > > > You will find it attached. -- Rodney Sparapani Center for Patient Care & Outcomes Research (PCOR) Sr. Biostatistician Department of Medicine Was 'Name That Tune' rigged? Medical College of Wisconsin (MCW) WWLD: What Would Lombardi Do Milwaukee, WI, USA |
From: Uwe L. <li...@st...> - 2008-09-12 09:39:54
|
I cannot reproduce on Windows even when using 3 different directories: - one for data - one as working directory - one for the model file schools <- read.table ("d:/schools.dat", header=T) 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)) parameters <- c("theta", "mu.theta", "sigma.theta") setwd("d:/temp") schools.sim <- bugs (data, inits, parameters, "d:/uwe/schools.bug", n.chains=3, n.iter=1000, working.directory="d:/temp") Simply works for me .... Uwe Rodney Sparapani wrote: > Gorjanc Gregor wrote: >> >> Can you please post a reproducible example so that we can check what >> is going on. >> >> gg >> >> >> >> > You will find it attached. > |
From: Rodney S. <rsp...@mc...> - 2008-09-12 14:03:50
|
Uwe Ligges wrote: > I cannot reproduce on Windows even when using 3 different directories: > > - one for data > - one as working directory > - one for the model file > > > > schools <- read.table ("d:/schools.dat", header=T) > 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)) > parameters <- c("theta", "mu.theta", "sigma.theta") > setwd("d:/temp") > schools.sim <- bugs (data, inits, parameters, "d:/uwe/schools.bug", > n.chains=3, n.iter=1000, working.directory="d:/temp") > > > Simply works for me .... > > Uwe Hi Uwe: But, you have the command setwd("d:/temp") and I don't. However, this does not work around the problem either: library(R2WinBUGS) schools <- read.table ("/usr/local/doc/r2winbugs/schools.dat", header=T) 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)) parameters <- c("theta", "mu.theta", "sigma.theta") setwd(".") schools.sim <- bugs (data, inits, parameters, "/usr/local/doc/r2winbugs/schools.bug", n.chains=3, n.iter=1000, working.directory=".") Warning message: In file.create(to[okay]) : cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason 'Permission denied' -- Rodney Sparapani Center for Patient Care & Outcomes Research (PCOR) Sr. Biostatistician Department of Medicine Was 'Name That Tune' rigged? Medical College of Wisconsin (MCW) WWLD: What Would Lombardi Do Milwaukee, WI, USA |
From: Uwe L. <li...@st...> - 2008-09-12 15:08:34
|
Rodney Sparapani wrote: > Uwe Ligges wrote: >> I cannot reproduce on Windows even when using 3 different directories: >> >> - one for data >> - one as working directory >> - one for the model file >> >> >> >> schools <- read.table ("d:/schools.dat", header=T) >> 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)) >> parameters <- c("theta", "mu.theta", "sigma.theta") >> setwd("d:/temp") >> schools.sim <- bugs (data, inits, parameters, "d:/uwe/schools.bug", >> n.chains=3, n.iter=1000, working.directory="d:/temp") >> >> >> Simply works for me .... >> >> Uwe > Hi Uwe: > > But, you have the command setwd("d:/temp") and I don't. However, this does > not work around the problem either: > > library(R2WinBUGS) > schools <- read.table ("/usr/local/doc/r2winbugs/schools.dat", header=T) > 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)) > parameters <- c("theta", "mu.theta", "sigma.theta") > setwd(".") > schools.sim <- bugs (data, inits, parameters, > "/usr/local/doc/r2winbugs/schools.bug", > n.chains=3, n.iter=1000, working.directory=".") > > > Warning message: > In file.create(to[okay]) : > cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason > 'Permission denied' So, what exactly is your working directory? If it is "/usr/local/doc/r2winbugs/schools.txt", I am not surprised. Uwe Ligges |
From: Rodney S. <rsp...@mc...> - 2008-09-12 16:21:30
|
Uwe Ligges wrote: > >> Hi Uwe: >> >> But, you have the command setwd("d:/temp") and I don't. However, >> this does >> not work around the problem either: >> >> library(R2WinBUGS) >> schools <- read.table ("/usr/local/doc/r2winbugs/schools.dat", header=T) >> 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)) >> parameters <- c("theta", "mu.theta", "sigma.theta") >> setwd(".") >> schools.sim <- bugs (data, inits, parameters, >> "/usr/local/doc/r2winbugs/schools.bug", >> n.chains=3, n.iter=1000, working.directory=".") >> >> >> Warning message: >> In file.create(to[okay]) : >> cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason >> 'Permission denied' > > > > So, what exactly is your working directory? If it is > "/usr/local/doc/r2winbugs/schools.txt", I am not surprised. > > Uwe Ligges > As I said in the original post, $HOME -- Rodney Sparapani Center for Patient Care & Outcomes Research (PCOR) Sr. Biostatistician Department of Medicine Was 'Name That Tune' rigged? Medical College of Wisconsin (MCW) WWLD: What Would Lombardi Do Milwaukee, WI, USA |
From: Uwe L. <li...@st...> - 2008-09-15 16:07:20
|
Rodney Sparapani wrote: > Uwe Ligges wrote: >> I cannot reproduce on Windows even when using 3 different directories: >> >> - one for data >> - one as working directory >> - one for the model file >> >> >> >> schools <- read.table ("d:/schools.dat", header=T) >> 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)) >> parameters <- c("theta", "mu.theta", "sigma.theta") >> setwd("d:/temp") >> schools.sim <- bugs (data, inits, parameters, "d:/uwe/schools.bug", >> n.chains=3, n.iter=1000, working.directory="d:/temp") >> >> >> Simply works for me .... >> >> Uwe > Hi Uwe: > > But, you have the command setwd("d:/temp") and I don't. However, this does > not work around the problem either: > > library(R2WinBUGS) > schools <- read.table ("/usr/local/doc/r2winbugs/schools.dat", header=T) > 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)) > parameters <- c("theta", "mu.theta", "sigma.theta") > setwd(".") > schools.sim <- bugs (data, inits, parameters, > "/usr/local/doc/r2winbugs/schools.bug", > n.chains=3, n.iter=1000, working.directory=".") > > > Warning message: > In file.create(to[okay]) : > cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason > 'Permission denied' OK, I still canoot reproduce on Windows. Can you please try to say: options(warn=2) # Run the example code again that produces some error now traceback() Can you please show us that traceback() stack? Thank you, Uwe |
From: Rodney S. <rsp...@mc...> - 2008-09-15 16:25:29
|
Uwe Ligges wrote: > OK, I still canoot reproduce on Windows. > > Can you please try to say: > > options(warn=2) > # Run the example code again that produces some error now > traceback() > > Can you please show us that traceback() stack? > > Thank you, > Uwe > > traceback() 10: doWithOneRestart(return(expr), restart) 9: withOneRestart(expr, restarts[[1]]) 8: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 7: .signalSimpleWarning("cannot create file '/usr/local/doc/r2winbugs/schools.txt', reason 'Permission denied'", quote(file.create(to[okay]))) 6: file.create(to[okay]) 5: file.copy(model.file, new.model.file, overwrite = TRUE) 4: bugs(data, inits, parameters, "/usr/local/doc/r2winbugs/schools.bug", n.chains = 3, n.iter = 1000, working.directory = ".") 3: eval.with.vis(expr, envir, enclos) 2: eval.with.vis(ei, envir) 1: source("/usr/local/doc/r2winbugs/schools.r") > -- Rodney Sparapani Center for Patient Care & Outcomes Research (PCOR) Sr. Biostatistician Department of Medicine Was 'Name That Tune' rigged? Medical College of Wisconsin (MCW) WWLD: What Would Lombardi Do Milwaukee, WI, USA |
From: Gorjanc G. <Gre...@bf...> - 2008-09-16 06:54:10
|
Hi! Sorry for jumping in so late ... The problem seems to be the file.copy function since it tries to convert the schools.bug into schools.txt file in a folder where user does not have permission i.e. in /usr/local/doc/r2winbugs. The problematic code is on line 64 of bugs.R in the R2WinBUGS package. The WinBUGS executable only recognizes ASCII files as such if they have "txt" extension. However, a lot of us use "bug" extension to emphasize that this a BUGS model file. Therefore, the bugs() function tries to copy model_file_name.bug to model_file_name.txt. Rodney, since you are having the model_file_name.bug in a place where your user does not have permissions to write new files file copying can not be performed. I agree that this is not the behaviour we want. This issue has been raised due to two facts: stringent permissions on unix like machines and Rodneys' setup - i.e. the /usr/local/doc/r2winbugs is not writable for regular users. Perhaps, we could in such cases copy the model.file to a working directory in order to avoid this problem. This should work in any setting since the working directory must be writtable anyway. I will try to implement this so that Rodney can check. P.S. However, note the R2WinBUGS needs a write permission for the WinBUGS folder, since there is a part of the code that reads in one of the ODC files, changes something in relation with the burnin period and writes the file back. I am not familiar with the rational of this. Maybe, anyone else can enlighten me/us ... gg |