Individual spatial correlated random effect model

228 views
Skip to first unread message

Kevin WATJOU

unread,
Oct 9, 2017, 2:36:22 PM10/9/17
to R-inla discussion group
Hi,

I'm trying to construct build a model where I evaluate 2 outcomes (y1 and y2) at an individual level and use random effects (a spatially correlated one (v_i) and a spatially correlated one u_i)

So in short, I have these 2 models (which have a different likelihood):
y1ij ~ intercept1 + u_1i + v_1i + w_ij
y2ij ~ intercept2 + u_2i + v_2i + w_ij

The w_ij is the same for the 2 models
However i want to allow that the random effects u_1i and u_2i are correlated (same for v_1i and v_2i)

formula1 = (y1 ~  1 + 
            f(region.unstruct,model="iid", param=c(0.5,0.008)) + 
f(region.struct,model="besag", graph=graph.loc, param=c(0.5,0.008)))
mod.pred1 <- inla(formula1, family = "binomial", data = cc.data, Ntrials=1,
 control.predictor=list(compute=TRUE,link=1),
 control.compute=list(config = TRUE),
 control.fixed=list(expand.factor.strategy="inla"))

formula2 = y2~  1 + 
            f(region.unstruct,model="iid", param=c(0.5,0.008)) + 
f(region.struct,model="besag", graph=graph.loc, param=c(0.5,0.008)))
mod.pred2 <- inla(formula2, family = "binomial", data = cc.data, Ntrials=1,
 control.predictor=list(compute=TRUE,link=1),
 control.compute=list(config = TRUE),
 control.fixed=list(expand.factor.strategy="inla"))

I started with these 2 (independent) models, however I don't know how to take the correlation into account. And is there a way to say to INLA that the w_ij have to be the same?

Thanks in advance!

Kind regards,
K

Helpdesk

unread,
Oct 9, 2017, 2:45:50 PM10/9/17
to Kevin WATJOU, R-inla discussion group
On Mon, 2017-10-09 at 20:36 +0200, Kevin WATJOU wrote:
> Hi,
>
> I'm trying to construct build a model where I evaluate 2 outcomes (y1
> and y2) at an individual level and use random effects (a spatially
> correlated one (v_i) and a spatially correlated one u_i)
>
> So in short, I have these 2 models (which have a different
> likelihood):
> y1ij ~ intercept1 + u_1i + v_1i + w_ij
> y2ij ~ intercept2 + u_2i + v_2i + w_ij
>
> The w_ij is the same for the 2 models
> However i want to allow that the random effects u_1i and u_2i are
> correlated (same for v_1i and v_2i)


you can use the 'group' option, which will form a kronecker product of
the precision matrices.

> names(inla.models()$group)
[1] "exchangeable" "exchangeablepos"
"ar1" "ar"
[5]
"rw1" "rw2" "besag" "iid"


then you need to write the two formulas in one.

by replicating the indices for w_ij the terms will be identical.


Best
H
--
Håvard Rue
Helpdesk
he...@r-inla.org
group-models.pdf

Helpdesk

unread,
Oct 9, 2017, 2:53:34 PM10/9/17
to Kevin WATJOU, R-inla discussion group
On Mon, 2017-10-09 at 20:36 +0200, Kevin WATJOU wrote:
> Hi,
>
> I'm trying to construct build a model where I evaluate 2 outcomes (y1
> and y2) at an individual level and use random effects (a spatially
> correlated one (v_i) and a spatially correlated one u_i)
>
> So in short, I have these 2 models (which have a different
> likelihood):
> y1ij ~ intercept1 + u_1i + v_1i + w_ij
> y2ij ~ intercept2 + u_2i + v_2i + w_ij
>


assuming one dimensional indexing, i=1,...,n.

then you use something like this

Y = c(y1, y2)

intercept = as.factor(rep(1:2, each = n))

idx.u = rep(1:n, 2)
g.u = rep(1:2, each = n)

idx.v = idx.u
g.v = g.u

idx.w = idx.u

formula = Y ~ -1 + intercept +
f(idx.u, model="besag", graph=g, group = g.u) +
f(idx.v, model="iid",w group = g.v) +
f(idx.w, model="...")


the default group model is 'exchangable', which is just two-dimensionaal
with a correlation when there is only two groups.

Kevin WATJOU

unread,
Oct 10, 2017, 5:03:15 AM10/10/17
to he...@r-inla.org, R-inla discussion group
That did the trick. Thanks! :)

Kind regards,
K
Message has been deleted

SS

unread,
Aug 16, 2019, 9:05:53 AM8/16/19
to R-inla discussion group
Hi,

Is this possible if number of observed data y1 and y2 are different?

Thanks,
SS

SS

unread,
Aug 16, 2019, 10:36:42 AM8/16/19
to R-inla discussion group
Hi,

So, I'm trying to build a model with correlated spde spatial effect. y1 and y2 have different number of data and they have different likelihoods but same spde from the same mesh. I've managed to assign the index and grouping for the spde in their separate inla.stack() before stacking them together but how do I create the prediction stack (what should be the grouping for the prediction) ? 

Thanks,
SS

Finn Lindgren

unread,
Aug 16, 2019, 10:44:36 AM8/16/19
to SS, R-inla discussion group
Hi,
Follow the same approach for prediction as for estimation, but set the "observation" values to NA in the two prediction stacks. Then join all four stacks.

Finn

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/c96cf627-1a6a-428a-ae8a-afc47b5e51dc%40googlegroups.com.

SS

unread,
Aug 16, 2019, 10:55:55 AM8/16/19
to R-inla discussion group
Hi Finn,

That make sense. I'll do that. Thanks for the advice.

Regards.


On Friday, 16 August 2019 15:44:36 UTC+1, Finn Lindgren wrote:
Hi,
Follow the same approach for prediction as for estimation, but set the "observation" values to NA in the two prediction stacks. Then join all four stacks.

Finn

To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.

SS

unread,
Aug 16, 2019, 11:58:34 AM8/16/19
to R-inla discussion group
Hi Finn,

Does this means that there will be two sets of predictions?

Thanks.


On Friday, 16 August 2019 15:44:36 UTC+1, Finn Lindgren wrote:
Hi,
Follow the same approach for prediction as for estimation, but set the "observation" values to NA in the two prediction stacks. Then join all four stacks.

Finn

To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion-group+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages