[R-sig-Geo] EBlocal() returning NaN values

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Wed Jan 5 21:14:27 CET 2022


On Tue, 4 Jan 2022, Erin Stearns wrote:

> Hello R-sig-Geo friends & happy 2022!
>
> Running EBlocal() on US county sf dataset and getting NaN values where
> Empirical Bayes and a BYM model are returning values and I do not
> understand why. Additionally, does anyone know how to examine the parameters
> attribute list from the output of the EBlocal() function? I have not been
> able to look at this and perhaps that would be informative.
>

Yes, you are right:

summary(attr(seb_icu, "parameters")$a)
summary(attr(seb_icu, "parameters")$m)

which(attr(seb_icu, "parameters")$a == 0 &
  attr(seb_icu, "parameters")$m == 0)
which(is.nan(seb_icu$est))

showing that the NaNs are caused by a division by zero:

est <- m.i + (xi - m.i) * (a.i / (a.i + (m.i/ni)))

In fact, if m.i and C.i (see Marshall's paper) are both zero, a.i becomes 
zero, and leads to the division by zero. The underlying reason is that 
Marshall never tested a setting where many ri are zero, so the count of 
cases in a small neighbourhood of neighbouring counties was almost never 
zero:

> table(thedata$icu_bed_avg == 0)

FALSE  TRUE
  1437  1783

Had tests been done on > 50% cases, the problem would have been detected, 
but probably not resolved, as the issue is with entitation - .

The same counties have NaNs if those with no neighbours are dropped (less 
the no-neighbour counties), so this is not caused by assuming that the 
lagged value of an entity with no neighbours is zero.

To get closer to the original paper, probably counties should be 
aggregated to reduce the number with no cases, and so meet the underlying 
assumptions.

Hope this helps,

Roger

>
> *Function call:*
> seb_icu <- EBlocal(thedata$icu_bed_avg, thedata$over18pop, nb = nb,
> zero.policy = TRUE)
>
> *Environment details:*
>  OS: Windows 10 x64
>  R Version: 4.1.1
>     spdep version: 1.1-11
>     sf version   : 1.0-3
>
> Full dataset and code to reproduce can be found for download here.
> <https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapp.box.com%2Fs%2Fr26ta0gl9avwlwm65ivtze7j97hyw8i7&data=04%7C01%7CRoger.Bivand%40nhh.no%7Ca717ef6fd6574eb6a40a08d9cfa5d91d%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637769134198352241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=LJEJ3SgKe0wEzD21Re3%2B4Jfl5LpSD6SpDFYPzsFP7HE%3D&reserved=0>
>
> Thank you in advance for your help!
>
> Best,
> Erin
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=04%7C01%7CRoger.Bivand%40nhh.no%7Ca717ef6fd6574eb6a40a08d9cfa5d91d%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637769134198352241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=l%2B5AwZrspCXeHPlJh1C61SSMHv6p7UacEYMvqSK4Gaw%3D&reserved=0
>

-- 
Roger Bivand
Emeritus Professor
Department of Economics, Norwegian School of Economics,
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
e-mail: Roger.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



More information about the R-sig-Geo mailing list