[R] problem with BRugs

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Aug 25 12:13:21 CEST 2009



Vitalie S. wrote:
> Hello Uwe,
> 
> Just a related question, OpenBugs is using C and T for Censoring and 
> Truncation. But this does not seem to work with BRugs.
> 
> I am using this document 
> http://mathstat.helsinki.fi/openbugs/Manuals/ModelSpecification.html#TheBUGSLanguageStochasticNodes 
> 


What's the problem? Error message? Reproducible code?

Specifying, e.g.

model <- function()
     x ~ dnorm(mu, tau)%_%T(lower, upper)
writeModel(model)

works for me.

Best,
Uwe




> Thanks,
> Vitalie.
> 
> On Tue, 25 Aug 2009 10:00:44 +0200, Uwe Ligges 
> <ligges at statistik.tu-dortmund.de> wrote:
> 
>>
>>
>> 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,
>> Uwe
>>
>>
>>> , 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.
>>
>> ______________________________________________
>> 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