[R] ERROR Message

Jim Lemon drjimlemon at gmail.com
Sat May 23 01:03:57 CEST 2015


Hi Ivone,
This does look a bit like homework as someone else sent a help request
with a strikingly similar problem. However, I would first do something
like this:

is.array(datalist[[1]])

as this is what the error message is saying.

Jim


On Sat, May 23, 2015 at 2:57 AM, Ivone Figueiredo <ifigueiredo at ipma.pt> wrote:
> Hi
>
> Could you please help me
>
> I am trying to fit a Multilevel Poisson regression with the following code
>
> ## BUGS CODE
>
> ## Multilevel Poisson regression
>
> model {
>
>   for (i in 1:n){
>
>     y[i] ~ dpois (lambda[i])
>
>     log(lambda[i]) <- mu +
>
>       b.species[Species[i]] + b.quarter[Quarter[i]] + epsilon[i]
>
>     epsilon[i] ~ dnorm (0, tau.epsilon)
>
>   }
>
>   mu ~ dnorm (0, .0001)
>
>   mu.adj <- mu +  mean(b.species[]) + mean(b.quarter[])
>
>   tau.epsilon <- pow(sigma.epsilon, -2)
>
>   sigma.epsilon ~ dunif (0, 100)
>
>
>
>   for (j in 1:n.species){
>
>     b.species[j] ~ dnorm (0, tau.species)
>
>     b.species.adj[j] <-  b.species[j] - mean( b.species[])
>
>   }
>
>   tau.species <- pow(sigma.species, -2)
>
>   sigma.species ~ dunif (0, 100)
>
>
>
>   for (j in 1:n.quarters){
>
>     b.quarter[j] ~ dnorm (0, tau.quarter)
>
>     b.quarter.adj[j] <- b.quarter[j] - mean(b.quarter[])
>
>   }
>
>   tau.quarter <- pow(sigma.quarter, -2)
>
>   sigma.quarter ~ dunif (0, 100)
>
> }
>
>
>
> ##
>
>
>
> skate.data <- list ("Species", "n.species", "Quarter", "n.quarters", "y")
>
>
>
> #radon.inits <- function (){
>
> #  list (a=rnorm(J), b=rnorm(1), g.0=rnorm(1), g.1=rnorm(1),
>
> #        sigma.y=runif(1), sigma.a=runif(1))
>
> #}
>
>
>
> skate.parameters <- c ("mu", "b.quarter", "b.species", "sigma.species",
> "sigma.quarter", "sigma.epsilon")
>
>
>
> skate.3 <- bugs (skate.data, inits=NULL, skate.parameters, "skates.bug",
>
>                  n.chains=3, n.iter=500,
>
>             bugs.directory="c:/ProgramFiles(x86)/OpenBUGS/OpenBUGS323",
>
>             program=c("OpenBUGS"))
>
>
>
>
>
> But I always receive this message error
>
>
>
> Loading required package: BRugs
>
> Welcome to BRugs connected to OpenBUGS version 3.2.3
>
> model is syntactically correct
>
> Error in aperm.default(datalist[[i]]) :
>
>   invalid first argument, must be an array
>
> In addition: Warning messages:
>
> 1: package 'BRugs' was built under R version 3.0.3
>
> 2: In FUN(X[[5L]], ...) : class of 'x' was discarded
>
>
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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