Hello,
I'm trying to use INLA to predict a binary variable (called empty, that can be either 0 or 1) over a grid of points, using a spatial approach.
This is the code that I run:
formula <- empty ~ -1 + Intercept + f(field, model = spde)
mod <- inla(formula, data=inla.stack.data(stack, spde=spde),
family="binomial",
control.predictor=list(A=inla.stack.A(stack), compute=TRUE, link = 1))
index.pred = inla.stack.index(stack,"pred")$data
lp.mean.pred = mod$summary.linear.predictor[index.pred, "mean"]
lp.sd.pred = mod$summary.linear.predictor[index.pred, "sd"]
However, the lp.mean.pred vector takes negative values sometimes, which is of course absurd, since I'm trying to predict a binary variable. I then tried to transform the empty variable into a factor but I get this error:
Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts, :
The response for family[1] is not of type 'numeric|list|matrix'; don't know what to do.
The inla program failed and the maximum number of tries has been reached.
I want, if possible that the model predicts P(empty=1) if possible, as a logistic regression does for example. What am I doing wrong? Am I using the wrong family?
Best regards,
Samuel