[R] R2WinBUGS sending variables as factors

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Sat Jan 5 14:35:46 CET 2008


 <James.Dell <at> csiro.au> writes:
...
> 1) I can't seem to send variables classed as factors (Month), is there a
> way do this?

You can not use factors per se in BUGS. You have to convert them to numeric
(integer) variables before.

> 2) Checking the Log in WinBUGS I can see that the model is Syntactically
> correct, but Bugs is not able to recognise the the initial values for
> each of the chains.
...
> model
> {
>     #Centre variables
>  mSeaW <- mean(SeaW[])
>  s_dSeaW <- sd(SeaW[])
> 
>  #normalise Variables             
>    nSeaWiFS <- mSeaW/s_dSeaW
> 
>  for(i in 1:N) {
>   log(lambda[i]) <- delta0 + alpha1 * Month[i] + alpha2 * Lat[i]  +
> beta1 * (SeaW[i] - nSeaW) 

I guess you want to use mSeaW here instead of nSeaW!
                        ^                     ^
>  # recalculate the original intercept term
>  Intercept <- delta0 - beta1 * nSeaW 

I guess you want to use nSeaWiFS here instead of nSeaW!
...
> 
> ##And the Error Message from WinBUGS
> 
> model is syntactically correct
> 
> data(C:/Program Files/R/R-2.6.0/data.txt)
> 
> data loaded
> 
> compile(3)
> 
> made use of undefined node nSeaW

This warned you that the model is not OK!

Gregor




More information about the R-help mailing list