[R-sig-Geo] sphet errors
Smit, M.J.
martijn.smit at vu.nl
Wed Aug 21 14:35:07 CEST 2013
Dear List,
I try to estimate a spatial HAC model with sphet, but I run into errors creating the distance object. First I try (where centroids is a 262x2 matrix with labels according to NUTS_ID, and NUTS_ID is a variable in an attached dataset of 262 observations):
distances <- distance(coord=centroids,type="NN",nn=5,
measure="euclidean",firstline=TRUE,
file.name="dist.GWT",region.id=NUTS_ID)
but that gives me:
Error in Weights[Weights[, 1] == i, ][1:nn, ] : subscript out of bounds
In addition: There were 50 or more warnings (use warnings() to see the first 50)
so instead, I run
distances <- distance(coord=centroids,type="NN",nn=5,
measure="euclidean",firstline=TRUE,
file.name="dist.GWT",region.id=NULL)
and that gives:
In distance(coord = centroids, type = "NN", nn = 5, measure = "euclidean", :
region.id variable not specified
but still produces the dist.GWT I asked for. This file opens with 0 262, as I expected it to, and then gives origin, destination and distance, as I think it should. It ends with a blank line. However, I cannot read this file:
> dist <- read.gwt2dist(file="dist.GWT",skip=1)
Error in read.gwt2dist(file = "dist.GWT", skip = 1) :
Invalid header line format for GWT file
What am I doing wrong?
Best regards,
Martijn
Vrije Universiteit Amsterdam
More information about the R-sig-Geo
mailing list