[R-sig-Geo] R encounters fatal error in errorsarlm - sdpep package

Roger Bivand Roger.Bivand at nhh.no
Wed Sep 25 09:53:44 CEST 2013

On Wed, 25 Sep 2013, Philine Gaffron wrote:

> Hello,
> I am trying to run a spatial regression analysis using the errorsarlm 
> function in the sdpep package. I first ran into memory problems (on a larger 
> dataset than the one described below) but have adjusted the memory size 
> limit:
>> memory.limit(size = 800000)
> [1] 8e+05

Which sets your memory limit under Windows to 781 Gb (size is in Mb) - 
that probably explains the error exit unless you have a lot of memory. 
Best avoid making any changes from the default in a fresh session unless 
you know exactly what you are doing.

> However, when I try to execute the following code in R Studio, I receive the 
> message "R Session aborted - R encountered a fatal error - The session was 
> terminated"

Always rerun any code with problems outside R Studio, because it can 
interfere with the reporting of warnings and errors. Certainly 
errorsarlm() has no reason to cause R to crash - and this is what you are 
suggesting. If you can reproduce this outside R Studio, and without 
setting memory limits, I may need to see your data to try to reproduce any 
error exit from the R session.

>> ElDU.slm.PM25.white <- errorsarlm(PM_PM25 ~ race_white, data = 
>> ElDorado_urban, listw=ElDoU_listw)

Did you read the advice on ?errorsarlm about the use of alternative 
methods, such as "LU" or "Matrix" for larger data sets? You are using the 
default "eigen" method, but this should certainly have worked for the 
modest n=2081. Can you reproduce the problem with a built-in data set, 
such as elect80?

> The data was imported from an ArcGIS shape file:
>> Parcels2008_inc_POP <- readOGR(".", "Parcels_2008_inc_pop")
>> ElDorado_urban <- subset(Parcels2008_inc_POP, COUNTYFP10 == "017")
> The subset contains data from 2081 polygons
> The listw object was created as follows:
>> Eld_U_coords <- coordinates(ElDorado_urban)
>> Eld_U_IDs <- row.names(ElDorado_urban)
>> ElDoU_nb <- dnearneigh(Eld_U_coords, d1 = 0, d2 = 492, row.names = 
>> Eld_U_IDs)

Is 492 a well-chosen upper distance threshold? I assume that the input 
data are projected, so that these are measures in the units of the 
projection - metres? If Eld_U_coords are actually geographical 
coordinates, but longlat=NULL, d2 is taken as a planar measure, if 
you declare longlat=TRUE, it is in km. There is no easy way to trap 
undeclared geographical coordinates.

>> ElDoU_listw <- nb2listw(ElDoU_nb, glist=NULL, style="S", zero.policy=NULL)

Does choosing a different style make a difference ("S" is not often used)?


> Is there anything inherent in my approach that could cause this problem or 
> would one need to look at the data? I include the session info below.
> Thanks for any help,
> Philine
>> sessionInfo()
> R version 3.0.1 (2013-05-16)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
> States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> other attached packages:
> [1] spdep_0.5-65    Matrix_1.0-12   lattice_0.20-15 rgdal_0.8-11    sp_1.0-13
> loaded via a namespace (and not attached):
> [1] boot_1.3-9      coda_0.16-1     deldir_0.0-22   grid_3.0.1 
> LearnBayes_2.12 MASS_7.3-26     nlme_3.1-109    splines_3.0.1   tools_3.0.1
>> library(help=spdep)
> Information on package ?spdep?
> Description:
> Package:            spdep
> Version:            0.5-65
> Date:               2013-09-04

Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list