TransWikia.com

Estimating kernel bandwidth function with cross-validation gwrr package?

Geographic Information Systems Asked by Smky29 on November 26, 2020

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?

One Answer

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.

Answered by Liam G on November 26, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP