I am trying to run the below code in R but I got an error message:
install.packages("INLA", repos=c(getOption("repos"), INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE)
df=read.xlsx("E:/data.xlsx", sheetName = "data", header=TRUE)
result<- inla(Count ~ Year + f(iYear, model='ar1'), family=poisson, data=df)
Error in `as.character(x)` :
cannot coerce type 'closure' to vector of type 'character'
Any help would be highly appreciated.
This message in this case basically means that one of your arguments is meant to be a character string, but isn't quoted (thus it being interpreted as type closure). I don't have the INLA package installed (and can't quite figure out how to navigate to its man pages on the r-inla site), but looking at code in the tutorial below, it seems that the family argument should be quoted:
inla(y ~ x, family = c("gaussian"), data = data, control.predictor = list(link = 1))