search for: nb2listw

Displaying 20 results from an estimated 33 matches for "nb2listw".

2007 Nov 21
1
problem with nb2listw
Hi, I am a new student to R and I was hoping someone could help me with the error message I keep getting when I try to use the nb2listw() function. I have 45 sites and I want to get an autocorrelation value for sites within 1000m of each other. coords<-cbind(EAST,NORTH) coords<-as.matrix(coords) nb1000<-dnearneigh(coords,0,1000,longlat=TRUE) then when I try to run the nb2listw(nb1000, style="W") I get an e...
2003 Jun 30
2
spatial correlation test
hello, I want to do a test for spatial correlation. I tried it with geary.test() but I don't understand the required input. x= a numeric vector the same length as the neighbours list in listw (my sampled data, I assume) listw= a listw object created for example by nb2listw (well when I check nb2listw() I get to "neighbours - an object of class nb" - but I couldn't figure out, what nb is or how I create such a class with sp.mantel.mc {spdep} I have the same problem: listw created by nb2listw isn't there a more straight forward method ;-) to chec...
2005 Dec 29
1
Repeating functions
...mber of spatial weight files and using Roger Bivand's spdep, I would like to 1. Convert them into neighbor lists using 2. Convert the neighbor lists into spatial weights For a given file, the syntax would be mygal_nb1 <- read.gal("mygalfile1", override.id = TRUE) myweight1 <- nb2listw(mygal_nb1) I have mygalfile[i] with i from 1 through to 6 and would like to repeat the above two lines through 1 to 6. something like (the syntax below is not correct...just an illustration) for (i in 1:6) { mygal_nb[i] <- read.gal("mygalfile[i]", override.id = TRUE) myweight[i] <...
2003 Nov 27
1
lagsarlm - using mixed explanatory variables (spdep package)
Hello I'm very new to R (which is excellent), so apologies if this has already been raised. In the spdep package, I'm trying to undertake an autoregressive mixed model using the lagsarlm function. This is working fine, but there does not appear to be a method of including an explanatory variable without it automatically being included as a lagged term. I'm after something along the
2009 Jul 15
1
Simulation code error
...aste(V, collapse="+") + V <- paste("SBA~", V) + rd <- round(nrow(data)*(2/3)) + d <- sample(seq(1:nrow(data)),rd) + dat1 <- data[d,] + dat2 <- data[-d,] + crd <- cbind(dat1$Longitude,dat1$Latitude) + dist80 <- dnearneigh(crd,0,100,longlat=F) + dist80sw <- nb2listw(dist80, style="B") + fm <- errorsarlm(as.formula(V), data=dat1, listw=dist60sw) + pred <- predict(fm,dat2) + C[i,1] <- cor(dat2$SBA,pred) + out <- cbind(C) + } + colMeans(out) + } > > sim.sp(df2007.5k.s2,CM,1,1000) Error in nb2listw(dist80, style = "B") : Empty...
2003 Nov 16
3
an object of class lm returned by lm?
...ving the regression results and entering these, but again this is incorrect. This language is from the following: lm.LMtests(model, listw, zero.policy=FALSE, test="LMerr", spChk=NULL) Arguments model - an object of class lm returned by lm listw - a listw object created for example by nb2listw, expected to be row-standardised (W-style) Any help is welcomed. Thanks. -Jill *************************************************** Jill L. Caviglia-Harris, Ph.D. Assistant Professor Economics and Finance Department Salisbury University Salisbury, MD 21801-6860 phone: (410) 548-5591 fax:...
2009 Jul 15
1
Error in simulation R-code
...paste("SBA~", V) rd <- round(nrow(data)*(2/3)) d <- sample(seq(1:nrow(data)),rd) dat1 <- data[d,] dat2 <- data[-d,] crd <- cbind(dat1$Longitude,dat1$Latitude) dist60 <- dnearneigh(crd,0,60,longlat=F) dist60sw <- nb2listw(dist60, style="B") fm <- errorsarlm(as.formula(V), data=dat1, listw=dist60sw) pred <- predict(fm,dat2) C[i,1] <- cor(dat2$SBA,pred) out <- cbind(C) } colMeans(out) } sim.sp(df2007.5k.s2,CM,1,1000) Error in nb2listw(dist60, style = &quot...
2003 Jul 01
0
RE: question about spatial correlation with Xs and Ys
...: >hello, > >I want to do a test for spatial correlation. >I tried it with geary.test() but I don't understand the required input. >x= a numeric vector the same length as the neighbours list in listw (my >sampled data, I assume) >listw= a listw object created for example by nb2listw (well when I check >nb2listw() I get to "neighbours - an object of class nb" - but I couldn't >figure out, what nb is or how I create such a class > >with sp.mantel.mc {spdep} I have the same problem: listw created by nb2listw > >isn't there a more straight forwa...
2004 Jun 18
1
how to store estimates results as scalars of a matrix?
...sing R. Any help will be much appreciated. All the very best, JP coords2 <- as.matrix(jcdist.data[1:87, 6:7]) col.tri.nb<-tri2nb(coords2) for(n in c(1,88,175,262,349)) { f<- n+86 work <- jcdist.data[n:f, 10:12] res <-moran.test(spNamedVec("res1", work), nb2listw(col.tri.nb, style="W")) moran<-res$estimate[1] upper<-res$estimate[1] + (qnorm(0.025, lower.tail=FALSE) *sqrt(res$estimate[3])) lower<-res$estimate[1] - (qnorm(0.025, lower.tail=FALSE) *sqrt(res$estimate[3])) print(moran) print(upper) print(lower) }...
2008 Apr 18
1
spdep question - Moran's I
...ial network analysis. I have list of poeple and for each pair of them I have a measure of their relationship strength. So my dataset looks like: Jim; Bob; 0.5 This measure of relationship strength can be interpreted like a distance measure in a spatial model. I assume that I need to work with the nb2listw function, but I am lost what to do in detail. Thanks very much for your help in advance! Michael Haenlein Assistant Professor of Marketing ESCP-EAP European School of Management Paris, France [[alternative HTML version deleted]]
2011 Jul 12
1
Subsetting NaN values in localG()
...64) for(i in 1:53235){ if(diffc[i]!=-999){ diffD[counter] = diffc[i] id[counter] = i counter = counter+1 } } ##Isolates values I want to use in localG calculation neigh = cell2nb(169,315,type=='queen') neigh2 = subset.nb(neigh,(1:length(neigh) %in% id) mylist = nb2listw(neigh2,style="B") stats = localG(diffD,mylist)/ Unfortunately, when I get to the last line of the code, I receive the following error: /"Error in matrix(0, nrow = nrow(x), ncol = ncol(x)) : invalid 'ncol' value (too large or NA)"/ I can't figure out what it is...
2013 Apr 16
1
Spatial Ananlysis: zero.policy=TRUE doesn't work for no neighbour regions??
...1286 1391 1416 1456 1478 1485 1545 1546 1548 1558 1612 1621 1663 1672 1675 1760 1794 1795 2924 2925 2952 3107 with 1 link 1 most connected region: 1385 with 14 links *As there are some regions without neighbours in my data I use the following code to create the Weights Matrix:* > W_Matrix<- nb2listw(location_nbq, style="W", zero.policy=TRUE) >W_Matrix *And get this Output:* Fehler in print.listw(list(style = "W", neighbours = list(c(23L, 31L, 42L : regions with no neighbours found, use zero.policy=TRUE /("Error in print.listw(list(style = "W", neighb...
2007 Oct 26
1
Help needed on calculation of Moran's I
..., when I do the lm.morantest() I get a Moran's I value which is the same as the expected value and a P-value of 1. I have used the following code: >attach(lowland) >coords <- as.matrix(cbind(long, $lat)) >coord.nb <- dnearneigh(coords, 0, 10000 longlat=TRUE) >coord.list <- nb2listw(coord.nb, style="W") >lianasp.lm <- lm(lianasprich ~ log(averdist) + dsl + lianadens + wooddens) >lm.morantest(lianasp.lm, coord.list, alternative="two.sided") And get the following result Global Moran's I for regression residuals data: model: lm(formul...
2009 Jun 06
1
large numbers of observations using ME() of spdep
...<-coordinates(taimin.xy); library(spdep); TaiminGabrielGraph<-gabrielneigh(coords, nnmult = 12); tai.gab.nb<-graph2nb(TaiminGabrielGraph,sym=TRUE); nbtaim_distsg <- nbdists(tai.gab.nb, coords); nbtaim_simsg <- lapply(nbtaim_distsg, function(x) (1-((x/(4*50))^2)) ); MEtaig.listw <- nb2listw(tai.gab.nb, glist=nbtaim_simsg, style="B"); sevmtaig <- ME(Presabs ~Age+Curv+Zon2005+ZoneMeiji+Wi+Sol+Slope+Seadist+Elev+Basin,data=taimin, family=binomial,listw=MEtaig.listw) Any help is welcome! Thanks Lucero Mariani, Yokohama National University, Japan.
2005 Jan 30
1
New user...tips for spdep
[This email is either empty or too large to be displayed at this time]
2005 Nov 17
1
Morans I for Spatial Surveillance
...e thus far is below - I would also like to assemble the results in a neat table if anyone has tips for this I would alo appreciate it as I am rather new to R! Thanks Serryn T1<-read.dbf("ob.dbf") N <- colnames(T1) T2nb <- read.gal("PC.gal",override=TRUE) col.W <- nb2listw(T2nb, style="W") for(i in seq(N)) { Vec1 <- spNamedVec(N[i+7], T1) Svec1<-sum(Vec1) ifelse ( Svec1> 0, res[i]<-moran.test(spNamedVec(N[i+7], T1), col.W, zero.policy=TRUE), res[i]<-"NULL") } print(res) [[alte...
2003 May 21
1
help on spatial data
Hi, I have a dataset with x and y coordinates and in each point I have an identity of point, in some cases I can have more then one identity by point. My dataset is something like this: > x <- rep(c(1:4),4) > y <- rep(c(1:4),c(4,4,4,4)) > area1 <- sample(factor(rep(c("a","b","c","d"),4))) > area2 <-
2011 May 04
1
Instrumental variable quantile estimation of spatial autoregressive models
...ed a small sample of my data and matrix. R codes: library(foreign) library(lmtest) library(spdep) library(quantreg) data<-read.table("DataSample.txt",header=TRUE, sep="") attach(data) matrix<-read.gwt2nb("matrixsample.gwt" ,region.id=no_Trans) matrix.listw<-nb2listw(matrix) OLS model OLS<-lm(lnprice~surface+d2007+LUX+tsect_ci, data=data) summary(OLS) SAR model SAR<-lagsarlm(lnprice~surface+d2007+LUX+tsect_ci, data=data, listw = matrix.listw) summary(SAR) I hope that this information is sufficient and will help you to help me :) Many thanks in advance...
2009 Jan 07
1
troubles performing Moran.I test
dear R users, I have troubles performing Moran.I test as suggested on http://www.ats.ucla.edu/stat/r/faq/morans_i.htm my spatial data are longitude and lattitide of communities. The calculation of the inverse distance matrix according to the homepage (using my data) datAL <- read.csv2("C:\\Konvergenz AL.csv", header=T) ALdist <- as.matrix(dist(cbind(datAL$L?nge,
2004 May 04
1
spdep question
...49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 Link number distribution: 0 65 # Why are there no links? Do I understand properly what a link is? # 1 is a neighbor of 2 and vice versa, so I consider them linked? Can somebody tell me how to turn my neighborhood into an object errorsarlm and nb2listw (do I need that?) can handle! Best, Christian *********************************************************************** Christian Hennig Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/ #################################...