[R] problem with BRugs

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Aug 25 10:00:44 CEST 2009

R Heberto Ghezzo, Dr wrote:
> Hello, I am sorry, I have this problem before and Uwe send me the answer but I misplaced it 

Oh dear! But it is not lost, since the answer to the second part of your 
problem was: Please read the documentation!

> and can not find it.
 > writing a model for BRugs
>> library(BRugs)
> Loading required package: coda
> Loading required package: lattice
> Welcome to BRugs running on OpenBUGS version 3.0.3
>> setwd("c:/tmp")
> Error in setwd("c:/tmp") : cannot change working directory

So c:/tmp does not exist or you don't have permissions there?

>> mo <- function(){
> +   for (k in 1:p){
> +     delta[1,k] ~ dnorm(0,0.1)I(,delta[2,k])
> Error: unexpected symbol in:

The answer was: Please read the documentation!

?writeModel (which you want to use on this function) tells you:

"As a difference, BUGS syntax allows truncation specification like this: 
dnorm(...) I(...) but this is illegal in R. To overcome this 
incompatibility, use %_% before I(...): dnorm(...) %_% I(...). The dummy 
operator %_% will be removed before the BUGS code is saved. "

> "  for (k in 1:p){
>     delta[1,k] ~ dnorm(0,0.1)I"
>>     delta[2,k] ~ dnorm(0,0.1)I(delta[1,k],delta[3,k])
> Error: unexpected symbol in "    delta[2,k] ~ dnorm(0,0.1)I"
>>     delta[3,k] ~ dnorm(0,0.1)I(delta[2,k],)}
> Error: unexpected symbol in "    delta[3,k] ~ dnorm(0,0.1)I"
>> }
> Error: unexpected '}' in "}"
> so R parser does not like the I(,) construct

which is *not* the problem, see above.

Best wishes,

> , What is the alternative way of propgramming the
> constrain I(lower,upper)
> Thanks
> Heberto Ghezzo
> ______________________________________________
> R-help at r-project.org 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.

More information about the R-help mailing list