[R] problem with BRugs
Vitalie S.
vitosmail at rambler.ru
Tue Aug 25 13:38:28 CEST 2009
On Tue, 25 Aug 2009 12:13:21 +0200, Uwe Ligges
<ligges at statistik.tu-dortmund.de> wrote:
>
>
> 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?
>
Oh, sorry,I justs assumed it would be an easy answer, like "not
implemented yet".
Here is the code:
fModel<- function()
{
beta ~ dnorm(0,1) %_% T(0, 1)
}
writeModel(fModel,"Model.txt");
modelCheck("Model.txt");
#ERROR: this density cannot be truncated error pos 33 (error on line 3)
Note that C and I work fine in the code above.
My info:
> sessionInfo("BRugs")
R version 2.9.0 (2009-04-17)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
character(0)
other attached packages:
[1] BRugs_0.5-1
Vitalie.
> 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