indexing: replicate vs group

1,640 views
Skip to first unread message

Aritz Alberdi

unread,
Jul 4, 2013, 1:43:45 PM7/4/13
to r-inla-disc...@googlegroups.com
Hello,

I am trying to fit a spatio-temporal model and I have some problems to construct my model in INLA. I have been looking at SPDE-tutorial but still.

I have 10 year point referenced data. this locations are different every year. Also, I´d like to fit a AR1 temporal structure in the vertices from year to year. So, I would like to do the estimation for each year using that years data and predict in the other vertices while fitting the AR1 structure in each of the vertices.

how should I proceed? What is the difference between replicate and group when indexing for the stack functionality.

many thanks for your time,

Aritz




Elias Teixeira Krainski

unread,
Jul 4, 2013, 3:39:53 PM7/4/13
to r-inla-disc...@googlegroups.com
On 04/07/13 14:43, Aritz Alberdi wrote:
>
> how should I proceed? What is the difference between replicate and
> group when indexing for the stack functionality.
There are in INLA some functions to help the work with the index
construction for SPDE models.
1 - the inla.spde.make.index() make all the index set for you to use it
on the inla.stack()
2 - you must be have to make the prediction matrix. It is made by
inla.spde.make.A() and on that function you have to put the coordinates,
and index set that you have for the observations.
So, you don't need to know the internal indexing.


Aritz Alberdi

unread,
Jul 23, 2013, 9:46:05 AM7/23/13
to r-inla-disc...@googlegroups.com
tha was usefull Elias, thank you. and... what if I would like to implement the spatio-temporal model in an irregular grid?
I am playing with some datasets and I thought about using the ID as group indexing but not sure what I am telling INLA to compute.

my dataset (dt) is only ID(of the location * 10 years) and counts. I would like to implement a spatio-temporal model. I´ve been checking tutorials, and case studies but only get how to do it for spde models.

this is what I wrote:

"g" is my graph

form = counts~1+f(ID,model="besag", graph.file = g)+f(inla.group(ID), model="ar1")
res = inla(form,family="zeroinflatedpoisson1",data=dt,
          control.compute = list(return.marginals=TRUE, dic=TRUE, cpo=TRUE))

is that correct? I assume not...


Finn Lindgren

unread,
Jul 23, 2013, 10:06:19 AM7/23/13
to Aritz Alberdi, r-inla-disc...@googlegroups.com
On 23/07/13 14:46, Aritz Alberdi wrote:
> tha was usefull Elias, thank you. and... what if I would like to
> implement the spatio-temporal model in an irregular grid?
> I am playing with some datasets and I thought about using the ID as
> group indexing but not sure what I am telling INLA to compute.
>
> my dataset (dt) is only ID(of the location * 10 years) and counts. I
> would like to implement a spatio-temporal model. I�ve been checking
> tutorials, and case studies but only get how to do it for spde models.

I find it helps a lot to start by writing the desired model on
mathematical form instead of starting with an R formula; "a
spatio-temporal model" can mean many different things. ;-)

> form = counts~1+f(ID,model="besag", graph.file = g)+f(inla.group(ID),
> model="ar1")
> res = inla(form,family="zeroinflatedpoisson1",data=dt,

I assume that you really meant inla.group(temporal.ID), so that ID
contains graph node indices and temporal.ID contains temporal indices or
timepoints?
In that case the above gives a model

eta_ij = beta_0 + x_i + z_j
counts_ij ~ ZIP(eta_ij)

where x_i is a spatial/graph model and z_j is a temporal AR model.
If what you really want is a full space-time interaction model, i.e. you
want

eta_ij = beta_0 + x_ij

then that can be obtained in the same way as for spde space-time models,
e.g. something like this:

form = counts~1+f(ID,model="besag", graph.file = g,
group=inla.group(temporal.ID), control.group=list(model="ar1"))

/Finn

> control.compute = list(return.marginals=TRUE, dic=TRUE, cpo=TRUE))
>
> is that correct? I assume not...
>
>
> --
> 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 post to this group, send an email to
> r-inla-disc...@googlegroups.com.
> Visit this group at http://groups.google.com/group/r-inla-discussion-group.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Aritz Alberdi

unread,
Jul 23, 2013, 10:30:19 AM7/23/13
to r-inla-disc...@googlegroups.com, Aritz Alberdi
yes, you are sooo right. I am looking for space-time interaction model ( eta_ij = beta_0 + x_ij ).

yes, I´ll create the temporal ID and do it as you say. INLA makes it look kind of easy to implement really complicated models...

congratulations and many thanks
Aritz


El martes, 23 de julio de 2013 16:06:19 UTC+2, Finn Lindgren escribió:
On 23/07/13 14:46, Aritz Alberdi wrote:
> tha was usefull Elias, thank you. and... what if I would like to
> implement the spatio-temporal model in an irregular grid?
> I am playing with some datasets and I thought about using the ID as
> group indexing but not sure what I am telling INLA to compute.
>
> my dataset (dt) is only ID(of the location * 10 years) and counts. I
> would like to implement a spatio-temporal model. I�ve been checking
> an email to r-inla-discussion-group+unsub...@googlegroups.com.

SpNine

unread,
Mar 18, 2015, 12:50:04 PM3/18/15
to r-inla-disc...@googlegroups.com, ipa...@gmail.com

My question is new but has the same heading so I post here…

Sorry for a simple question but I am struggling to understand the difference between replicate and group. For instance, in the following models:

inla1<-inla(distance~1+f(age, group=groupID,model="ar1"), data=mydata)

inla1<-inla(distance~1+f(age, replicate=groupID),model="ar1"),data=mydata)

Basically, I have time series data for multiple groups. I would like to fit an ar1 model but avoid assuming that the underlying ar1 correlation is the same across all groups. I think using “replicate” assumes that it is, but I can't find much documentation about what “group” is doing?!

Thanks for your help!


INLA help

unread,
Mar 18, 2015, 2:28:52 PM3/18/15
to SpNine, r-inla-disc...@googlegroups.com, ipa...@gmail.com
replicate produce iid replicates. group produce dependent replicates.
you can mix both, to produce iid replicates of dependent replicates.

the problem is that this is not well documented. I attach slides for
which this is all based upon. current group models are


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



for an AR1 model, then if you group or replicate it, the the marginal
variance and the lag-one correlations are all the same. if they are all
different, you need to use multiple AR1 models.

Best
H


--
Håvard Rue
he...@r-inla.org
group-models.pdf
Reply all
Reply to author
Forward
0 new messages