rgeospatialgwrgwmodel

Error when running multiscale GWR: Error in gw_weight_vec: Not compatible > with requested type: [type=NULL; target=double]


I am trying to run multiscale geographically weighted regression (MGWR) using the GWmodel package in R. When running the function gwr.multiscale this error is shown:

Error in gw_weight_vec(vdist, bw, kernel, adaptive): Not compatible with requested type: [type=NULL; target=double].

An example:

library(GWmodel)

data(LondonHP)

dist <- gw.dist(coordinates(londonhp))

ab_gwr <- gwr.multiscale(PURCHASE ~ FLOORSZ + PROF, 
                         data = londonhp, 
                         criterion = "dCVR", 
                         kernel = "gaussian", 
                         adaptive = FALSE,
                         var.dMat.indx = 2,
                         bws0 = c(100, 
                                  100, 
                                  100), 
                         bw.seled = rep(T, 3), 
                         dMats = list(dist, 
                                      dist, 
                                      dist), 
                         parallel.method = "omp", 
                         parallel.arg = "omp")

I have tried other parameters as well, like adaptive bandwidth, to include fewer covariates, to change the bws0 parameter etc etc. Other kinds of errors occur depending on what I have tried.

I am following the example from the package's PDF.


Solution

  • The parameter var.dMat.indx is defined for the usage of distance matrix for each variable, and was used wrongly in my code. The solution:

    library(GWmodel)
    
    data(LondonHP)
    
    dist <- gw.dist(coordinates(londonhp))
    
    ab_gwr <- gwr.multiscale(PURCHASE ~ FLOORSZ + PROF, 
                             data = londonhp, 
                             criterion = "dCVR", 
                             kernel = "gaussian", 
                             adaptive = FALSE,
                             var.dMat.indx = 1:3,
                             bws0 = c(100, 
                                      100, 
                                      100), 
                             bw.seled = rep(TRUE, 3), 
                             dMats = list(dist, 
                                          dist, 
                                          dist), 
                             parallel.method = "omp", 
                             parallel.arg = "omp")