0

I am new to R and I am trying to work out geographically weighted regressions using some code that was developed by Roger Bivand for R. Please see help(gwr) for a discussion of the code. With the help of my professor I was able to make it work with an adaptive bandwidth:

library(GWmodel)

DM<-gw.dist(dp.locat=coords)

adaptive.bs1 <- gwr.sel(OnTer_tory ~ CL + cinc + Allie_thUS + Island + Landlocked, adapt = TRUE, method = "cv", gweight = gwr.bisquare, coords = coords)

gwr1 <- gwr(OnTer_tory ~ CL + cinc + Allie_thUS + Island + Landlocked, adapt = adaptive.bs1, gweight = gwr.bisquare, coords = coords, hatmatrix = TRUE)

However, when I try with a fixed bandwidth: fixed.bs1 <- gwr.sel(OnTer_tory ~ CL + cinc + Allie_thUS + Island + Landlocked, adapt = FALSE, method = "cv", gweight = gwr.bisquare, coords = coords)

gwr2 <- gwr(OnTer_tory ~ CL + cinc + Allie_thUS + Island + Landlocked, adapt = fixed.bs1, gweight = gwr.bisquare, coords = coords, hatmatrix = FALSE)

I get the following error: gwr2 <- gwr(OnTer_tory ~ CL + cinc + Allie_thUS + Island + Landlocked, + adapt = fixed.bs1, gweight = gwr.bisquare, coords = coords, hatmatrix = FALSE) Error: (adapt <= 1) is not TRUE

What am I doing wrong?

rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
  • I don't know GWmodel. But if you read the error message carefully, it basically says that the `adapt` (which is required to be <= 1) value `fixed.bs1` is not correct. You can print out the value of `fixed.bs1` and see if it is bigger than 1. – Eric Feb 22 '16 at 00:16
  • Welcome to Stackoverflow, a few quick suggestions on your question, when you post it there is a button at the top of the text box to set code, this makes your question much more pleasant to read. Second try to always post a reproducible example with data see this post for exactly what that means http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1. You're also referencing the incorrect package the gwr command is in the `spgwr` package. – admccurdy Feb 22 '16 at 00:23
  • Thanks Adam and Eric. – user5960167 Feb 23 '16 at 13:22

0 Answers0