inla.spde.make.A for spatio-temporal models

961 views
Skip to first unread message

Linh Nguyen

unread,
May 16, 2013, 11:48:36 PM5/16/13
to r-inla-disc...@googlegroups.com
Dear F. Lindgren, H. Rue,

Now I am using INLA for spatio-temporal applications. I got a problem as I used the function "inla.spde.make.A", which is at arguments of group and n.group.
I saw the code from M. Cameletti et. al., the group is an argument of time and the n.group is a max value of group, and all are integer.
Now my issue is that the time is real and number of group is integer. For example, time is from 1.00 to 1366.00, and is saperated by 92 group; so n.group should be 92. However, my code was getting an error: all(dims >= dims.min) is not TRUE

Could you please help me to resolve this issue?

Thank you so much for your attention!

Kind Regards,

Linh
 

INLA help

unread,
May 17, 2013, 2:00:00 AM5/17/13
to Linh Nguyen, r-inla-disc...@googlegroups.com
you have to recode the group membership into 1, 2, ..., 92.

H


--
Håvard Rue
he...@r-inla.org

Finn Lindgren

unread,
May 17, 2013, 3:54:48 AM5/17/13
to he...@r-inla.org, Linh Nguyen, r-inla-disc...@googlegroups.com
The intended way of doing that with inla.spde.make.A() is to define a
mapping between continuous space/time and the discrete model
representation using a "1d mesh".
The default is to assume that the user has already computed that
mapping, and that is why you get the error.

In your case, and using the latest inla version, you can do this
directly in the inla.spde.make.A() call:

inla.spde.make.A(...,
group=time,
group.mesh=inla.mesh.1d(time, degree=0))

In older versions, you need

inla.spde.make.A(...,
group=time,
group.mesh=inla.mesh.1d(time),
group.method="nearest")

Finn

Iosu

unread,
Feb 16, 2016, 11:54:44 AM2/16/16
to R-inla discussion group, he...@r-inla.org, linh.vaw...@gmail.com
Hello,

I have another question related to the indexation and stack functionality when predicting.

I have 25 years of spatial data and I would like to predict the distribution of the process for each year. Is there any more elegant way of doing so than repeating the indexation and stacking the data for every year independently and then bind it all together?

e.g. using semi-code

for i in 1:25
A.i <- inla.spde.make.A(mesh,
                               group=i,
                               n.group=25)
pred.i<-inla.stack(data=list(y=data$Y),
                      A=list(A.i, 1),
                     effects=list(mesh.index,list(b0=1,covar=covar)),
                     tag='pred.i')

all.year.pred=inla.stack(pred.1, ...., pred.25)



Thank you very much,
Iosu

Finn Lindgren

unread,
Feb 16, 2016, 12:54:28 PM2/16/16
to Iosu, R-inla discussion group, he...@r-inla.org, linh.vaw...@gmail.com

On 16 Feb 2016, at 16:54, Iosu <ipa...@gmail.com>:
I have 25 years of spatial data and I would like to predict the distribution of the process for each year. Is there any more elegant way of doing so than repeating the indexation and stacking the data for every year independently and then bind it all together?

Yes, when you call inla.spde.make.A, supply
 index=rep(1:spde$n, times=25), group=rep(1:25, each=spde$n)
and then replace the loop with a single inla.stack call.

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 post to this group, send email to r-inla-disc...@googlegroups.com.
Visit this group at https://groups.google.com/group/r-inla-discussion-group.
For more options, visit https://groups.google.com/d/optout.

Iosu

unread,
Feb 16, 2016, 1:23:47 PM2/16/16
to R-inla discussion group, ipa...@gmail.com, he...@r-inla.org, linh.vaw...@gmail.com

Thanks!
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