How do you specify a heterogeneity random effect using sparse.sglmm in package ngspatial?

99 views Asked by At

I have created a spatial Poisson model using package ngspatial (Hughes). My data is aggregated to census tracts with the variables violent, g5prop, and conc_dis. I would like to fit a hetereogeneity random effect (i.e. random effect for each census tract). How is this accomplished?

Here is what I have for my model, and it works beautifully:

library(ngspatial)

Z = stl$violent
X = cbind(1, stl$g5prop, stl$conc_dis)
load("A.Rda") # adjacency matrix
set.seed(123456)
fit = sparse.sglmm(Z ~ X - 1 + offset(log(stl$total_pop)), 
    random = 1|stl$id, family=poisson, A=A, 
    attractive=40,tune=list(sigma.s = 0.02), 
    verbose = TRUE)
summary(fit)

Now, how do I specify a random effect? It doesn't function like lme4 (for example (1|subject)) or other formulas (random = 1~subject).

Thanks!

0

There are 0 answers