Is it possible to create a graph file for INLA containing region names

68 views
Skip to first unread message

James Cranston

unread,
Aug 9, 2022, 5:42:20 AM8/9/22
to R-inla discussion group

I've been trying to link a column in my data containing these regions as a factor, to an INLA model with a graph describing their spatial arrangement.

#something like this f(regions, model = "bym2", graph = gb_regions)

Is there a way to get the region names into the graph file?

Spdep ignores region.id in class nb  when using spdep::nb2INLA?

INLA help

unread,
Aug 9, 2022, 6:04:42 AM8/9/22
to James Cranston, R-inla discussion group
You have to map names to integers 1:n manually…

From: r-inla-disc...@googlegroups.com <r-inla-disc...@googlegroups.com> on behalf of James Cranston <james.c...@ons.gov.uk>
Sent: Tuesday, August 9, 2022 11:42:20 AM
To: R-inla discussion group <r-inla-disc...@googlegroups.com>
Subject: [r-inla] Is it possible to create a graph file for INLA containing region names
 
--
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/3e134dcc-a0dd-4246-b8c5-adc4b376a8dbn%40googlegroups.com.

James Cranston

unread,
Aug 10, 2022, 10:15:33 AM8/10/22
to R-inla discussion group
Thanks, I've created a graph like this manually, I've included a small example here, should this run or am I missing something else?

graph
$n 
3
$nnbs
1 2 1
$nbs
nbs$north
south
nbs$south
north west
nbs$west
south
$cc
$cc$id
1 1 1
$cc$n 
$cc$nodes
north south west

A balanced dataset with all regions presents

data.frame(
y = 1:30, 
x = 1:10,
region =  c("north", "south", "west")
)

y ~ x +
f(region, model = "bym2", graph = graph)

INLA help

unread,
Aug 11, 2022, 6:50:49 PM8/11/22
to James Cranston, R-inla discussion group
You need to use 1,2,3 as region , not north, south,west 

Sent: Wednesday, August 10, 2022 4:15:33 PM

To: R-inla discussion group <r-inla-disc...@googlegroups.com>
Subject: Re: [r-inla] Is it possible to create a graph file for INLA containing region names
 

James Cranston

unread,
Aug 12, 2022, 3:56:15 AM8/12/22
to R-inla discussion group
So the answer to the original question is no, you can't have a graph file with region names in it? Sorry just checking I understand.

INLA help

unread,
Aug 12, 2022, 8:35:32 AM8/12/22
to James Cranston, R-inla discussion group
Yes.  No names, only integers 1:n 

Sent: Friday, August 12, 2022 9:56:15 AM

To: R-inla discussion group <r-inla-disc...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages