Hello,
I have a relatively large spatial transcriptomics dataset for which I am trying to fit an INLA model. I can't share the data but I was able to create a simulation to reproduce the bug below:
library(Matrix)
library(INLA)
library(fmesher)
set.seed(1)
N <- 15000
coords_std <- cbind(runif(N), runif(N))
colnames(coords_std) <- c("x","y")
bnd <- fm_nonconvex_hull(x = coords_std,
convex = -0.03, # negative => non-convex
concave = 0.03,
resolution = 100)
mesh <- fm_mesh_2d_inla(
boundary = bnd,
max.edge = c(0.05, 0.12), # inner, outer target edges (in [0,1] units)
cutoff = 0.005, # de-duplicate near-coincident data points
offset = c(0.03, 0.08)
)
plot(mesh)
spde <- inla.spde2.pcmatern(
mesh = mesh,
alpha = 2, # smoothness ν = 1
prior.range = c(0.15, 0.5), # median-ish range ~0.15
prior.sigma = c(1.0, 0.01) # fairly weak; tighten if needed
)
A <- inla.spde.make.A(mesh = mesh, loc = coords_std)
y_counts <- rpois(N, lambda=1)
stk.e <- inla.stack(
tag='est', ## tag id
data=list(y=y_counts), ## response
A=list(1, A), ## two projection matrices
effects=list(## intercept:
data.frame(b0=rep(1, N)), ## covariate
idx.u=1:spde$n.spde)
) ## RF index
mf <- y ~ 0 + b0 + f(idx.u, model=spde)
res <- inla(mf, family = "poisson",
data=inla.stack.data(stk.e), ## data
control.predictor=list(compute=TRUE,
A=inla.stack.A(stk.e)))# full projector
When I run this code, I get an error when calling "inla". The error message says
Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts, :
no slot of name "i" for this object of class "dsparseModelMatrix"
I can't figure this issue out, and when I look at inla.stack.A(stk.e)@i I do get values, so I'm not really sure what's going on.
Here is my sessionInfo in case there is a version issue perhaps?
R version 4.5.2 (2025-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] fmesher_0.6.1.9000 ggplot2_4.0.1 dplyr_1.1.4 INLA_25.10.19
[5] Matrix_1.7-4
Any help would be greatly appreciated! I am new to INLA so I'm sorry if the solution to this is obvious but I haven't been able to find much help via googling.
Eric.