Dear group,
I tried to build a SPDE model on a complex boundary.
The following piece of code (using the attached data) should generate an error.
Error in model.frame.default(new.fix.formula, data.same.len, na.action = inla.na.action) :
variable lengths differ (found for 'intercept')
load("question1.rda")
max.edge <- c(5000,1000000) ## max edge parameter
cutoff <- 1000 ## cutoff parameter
mesh <- inla.mesh.2d(loc,boundary=boundary, max.edge=max.edge, cutoff=cutoff)
## define SPDE
spde <- inla.spde2.matern(mesh)
spatial.A <- inla.spde.make.A(mesh,loc)
## stack
n <- length(y)
stack <- inla.stack(data=list(y=y), A=list(spatial.A,1),
effects=list(list(i=1:spde$n.spde),list(E=E,intercept=rep(1,n),j=seq(1,n))),tag="data")
## define model
f.geo <- y ~ -1 + intercept + f(i,model=spde) + f(j,model="iid")
## fit model
dat <- inla.stack.data(stack)
ts0 <- proc.time()
r <- inla(f.geo,family="zeroinflatedpoisson0",
data=dat,
E=E, verbose=T,
control.predictor=list(compute=TRUE))
ts1 <- proc.time()
The same code worked on a boundary with simpler geometry.
Thanks
Dong