-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
project.org] On Behalf Of Dan Rosauer
Sent: 5. november 2014 03:21
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Cause of error in spdep::errorsarlm
Hi Roger et al
I hope someone can help me with the following error with a call to the spdep
function errorsarlm()
Calling the function returns this: Error: $ operator is invalid for atomic vectors
Things I have already tried:
* testing with real and simulated data - error occurs
* running it on windows and linux - error is identical
* omitting various arguments to the function to see which one is the cause -
error occurs with or without the data or listw arguments. So it apparently
triggers this error before it even gets to the problem of the missing
arguments, and apparently they don't relate to the actual content of the data
or spatial weights.
Here is a test script which generates the error:
######################
library(spdep)
# create a sample data frame
df <- data.frame(lat=runif(100,0,3),long=runif(100,0,3),
pred1=runif(100,0,1), pred2=runif(100,0,1), resp=runif(100,0,10))
cat("\nPreparing neighbourhood weights for SARLM\n\n")
coords <-as.matrix(cbind(df$long, df$lat))
cont.nb <- dnearneigh(coords,d1=0, d2=100,longlat=TRUE)
weight_list <- nb2listw(cont.nb, glist=NULL, style="W", zero.policy=TRUE)
my_formula <- "resp ~ pred1 + pred2"
# this line gives the error: $ operator is invalid for atomic vectors
SAR.mod <- errorsarlm(my_formula, data=df, listw=weight_list)
######################
The R version is 3.1.0, and spdep 0.5-77
Any advice on how to fix this problem would be much appreciated.
The best possibility is that I've made a dumb mistake which can be easily
fixed... :-)
thanks
Dan
~~~~~~~~~~~~~~~~~~~~~~
Dan Rosauer
Postdoctoral Researcher
Moritz Lab
Ecology, Evolution & Genetics
Research School of Biology
Gould Building, Daley Road
Australian National University
Canberra ACT 0200
+61 413 950 275 (mobile)
+61 2 6125 1028 (office)
dan.rosauer at anu.edu.au
sites.google.com/site/danielrosauer