inlabru-org / inlabru

inlabru
https://inlabru-org.github.io/inlabru/
76 stars 21 forks source link

random effects error in 'backend-clean' #58

Closed stanbiryukov closed 5 years ago

stanbiryukov commented 5 years ago

Hi all,

I'm using the 'backend-clean' branch and encountered an error when attempting to add an observation level random effect:

hsN$obs_id = as.integer(factor(1:nrow(hsN))) n_obs = max(hsN$obs_id) mxmdl <- layer ~ -1 + beta.tri(map = f.tri(x, y), model = "linear") + field(map = coordinates, model = spde) + re(map = obs_id, model = "iid", n = n_obs) hmxfit <- bru(mxmdl, hsN, family='lognormal')

Error in missing(fvals$n) : invalid use of 'missing'

Here's the full traceback:

11. make.default.mesh(component, model, model.type, fvals) 10. component.character("re", map = obs_id, model = "iid", n = n_obs) 9. component("re", map = obs_id, model = "iid", n = n_obs) at #1 8. eval(component.expression, envir = environment(object)) 7. eval(component.expression, envir = environment(object)) 6. FUN(X[[i]], ...) 5. lapply(parsed, function(component.expression) eval(component.expression, envir = environment(object))) 4. component.formula(components) 3. component(components) 2. make.model(components) 1. bru(mxmdl, hsN, family = "lognormal")

finnlindgren commented 5 years ago

Thanks for the report! Looks like some ”missing()” uses should have been ”is.null()”. I’ll look into it!