On Wed, 1 Aug 2012, Shishir Mathur wrote:
Hello All:
I am working on parcel-level housing dataset to estimate the impact of
various variables on home sale prices (N is approx. 90,000).
I created the spatial weight metrics using sale year of four nearest houses
to assign weights. Next, I ran LM tests and the spatial lag and error
models using spdep package.
I get the following error message when I try to run spatial lag or error
models using the method "eigen".
Error in matrix(0, nrow = n, ncol = n) : too many elements specified
The code is:
fecurrentcombinedlag <-lagsarlm(fecurrentcombined, data = spssall,
lw_test2.csv, na.action=na.fail, type="lag", method="eigen", quiet=TRUE,
zero.policy=FALSE, interval = c(-1, 0.999), tol.solve=1.0e-20)
Since the dataset is large, I replaced "eigen" with "LU" or "MC". However,
I get the following error:
Error in validObject(.Object) :
invalid class "dgRMatrix" object: slot j is not increasing inside a
column
You are importing the k-nearest neighbour weights into R. Please do not do
that. For some purposes it appears to work, but almost certainly the
sparse representation is not in the order required by functions in the
Matrix package. Generate the same weights using knn2nb(knearneigh()) in
spdep, or in Matlab or (open)GeoDa and import them from those versions.
Roger
The traceback results are:
10: stop(msg, " ", errors, domain = NA)
9: validObject(.Object)
8: initialize(value, ...)
7: initialize(value, ...)
6: new("dgRMatrix", j = z[[1]], p = p0, Dim = as.integer(c(n, n)),
x = z[[2]])
5: as_dgRMatrix_listw(get("listw", envir = env))
4: .class1(object)
3: as(as_dgRMatrix_listw(get("listw", envir = env)), "CsparseMatrix")
2: LU_setup(env)
1: lagsarlm(fecurrentcombined, data = spssall, listw = lw_test2.csv,
na.action = na.fail, type = "lag", method = "LU", quiet = TRUE,
zero.policy = FALSE, interval = c(-1, 0.999), tol.solve = 1e-20)
The code for creating listw, and the listw summary are as follows:
test2.csv <- read.csv("C:/TIFArticle/KC Exisiting Housing/EHspwt.csv")
class(test2.csv) <- c("spatial.neighbour", class(test2.csv))
of <- ordered(test2.csv$OID)
attr(test2.csv, "region.id") <- levels(of)
test2.csv$OID <- as.integer(of)
test2.csv$NID <- as.integer(ordered(test2.csv$NID))
attr(test2.csv, "n") <- length(unique(test2.csv$OID))
lw_test2.csv <- sn2listw(test2.csv)
lw_test2.csv$style <- "W"
lw_test2.csv
Characteristics of weights list object:
Neighbour list object:
Number of regions: 87223
Number of nonzero links: 348892
Percentage nonzero weights: 0.004585946
Average number of links: 4
Non-symmetric neighbours list
Weights style: W
Weights constants summary:
n nn S0 S1 S2
W 87223 7607851729 87223 27790.89 368025.1
Million thanks in advance for your help.
Shishm
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
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: [email protected]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo