0

I am relatively new to R. I am attempting to use the gwrr package because I suspect that local collinearity may be an issue in my geographic weighted regression model.

If I am not mistaken, I first estimate the kernel bandwidth function using cross-validation. Below please find my R script. Diab is a spatial data set projected in Albers Equal Area Conic.

tt<-gwr.bw.est(dia2013~pctblacks + pcthis + pctpov+ lcollege+ newden+hosden10 +optden13 + totmdden13 + phyden13 + den13  +  nurseden13 + nohealthin + unemploy + transport, data=diab, kernel = "gauss", cv.tol=30)

However, I get the following error:

Error in (function (classes, fdef, mtable)  : 

unable to find an inherited method for function ‘geometry’ for signature ‘"numeric"’

Does anyone know what is going on?

0

The issue is that you haven't actually specified the coordinates to perform the function.

In the vignette example found below. They had the data parameter set to a variable 'columbus' then they set the locs paramter to

c(columbus$x,columbus$y). 

https://cran.r-project.org/web/packages/gwrr/gwrr.pdf

I'm not sure how your data is set out but you would need to change it to something like this

 tt<-gwr.bw.est(dia2013~pctblacks + pcthis + pctpov+ lcollege+ newden+hosden10 +optden13 + totmdden13 + phyden13 + den13 + nurseden13 + nohealthin + unemploy + transport, locs = c(diab$X,diab$Y) data=diab, kernel = "gauss", cv.tol=30)

You would just need to change the X and Y to whatever your coordinate labels are in your data frame.

  • Thank you for your response. My object is of a spatial polygon class. I read in a shapefile using package rgdal. How do I extract the x and y coordinates to work with this formula? – Smky29 Nov 8 '17 at 23:51
  • I just figured this part out, but I still have the error! #Fetch coordinates cordy<-coordinates(diab) #Add coordinates to data frame newz<-cbind(diab, cordy) locs <- cbind(newz$X1, newz$X2) tt<-gwr.bw.est(dia2013~pctblacks + pcthis + pctpov+ lcollege+ newden+hosden10 +optden13 + totmdden13 + phyden13 + den13 + nurseden13 + nohealthin + unemploy + transport, locs, data=newz, kernel = "gauss", cv.tol=30) – Smky29 Nov 9 '17 at 1:17
  • With polygon data, your ariel units are non-uniform and as such, violate assumptions of the spatial model. In evaluating autocorrelation on lattice data one defines Wij as Nth-order neighbor contingency and not distance. Since you cannot account for contingency in the spatial relationships nor correct for variable polygon size, the resulting GWR model will be biased if not outright erroneous. – Jeffrey Evans Jun 30 '18 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.