mgwnbr {mgwnbr}R Documentation

Multiscale Geographically Weighted Negative Binomial Regression

Description

Fits a geographically weighted regression model with different scales for each covariate. Uses the negative binomial distribution as default, but also accepts the normal, Poisson, or logistic distributions. Can fit the global versions of each regression and also the geographically weighted alternatives with only one scale, since they are all particular cases of the multiscale approach.

Usage

mgwnbr(
  data,
  formula,
  weight = NULL,
  lat,
  long,
  globalmin = TRUE,
  method,
  model = "negbin",
  mgwr = TRUE,
  bandwidth = "cv",
  offset = NULL,
  distancekm = FALSE,
  int = 50,
  h = NULL
)

Arguments

data

name of the dataset.

formula

regression model formula as in lm.

weight

name of the variable containing the sample weights, default value is NULL.

lat

name of the variable containing the latitudes in the dataset.

long

name of the variable containing the longitudes in the dataset.

globalmin

logical value indicating whether to find a global minimum in the optimization process, default value is TRUE.

method

indicates the method to be used for the bandwidth calculation (adaptive_bsq, fixed_bsq, fixed_g).

model

indicates the model to be used for the regression (gaussian, poisson, negbin, logistic), default value is"negbin".

mgwr

logical value indicating if multiscale should be used (TRUE, FALSE), default value is TRUE.

bandwidth

indicates the criterion to be used for the bandwidth calculation (cv, aic), default value is "cv".

offset

name of the variable containing the offset values, if null then is set to a vector of zeros, default value is NULL.

distancekm

logical value indicating whether to calculate the distances in km, default value is FALSE.

int

integer indicating the number of iterations, default value is 50.

h

integer indicating a predetermined bandwidth value, default value is NULL.

Value

A list that contains:

Examples

## Data


data(georgia)

for (var in c("PctFB", "PctBlack")){
  georgia[, var] <- as.data.frame(scale(georgia[, var]))
}


## Model

mod <- mgwnbr(data=georgia, formula=PctBach~PctBlack+PctFB,
 lat="Y", long="X", globalmin=FALSE, method="adaptive_bsq", bandwidth="cv",
  model="gaussian", mgwr=FALSE, h=136)

## Bandwidths
mod$general_bandwidth

## Goodness of fit measures
mod$measures


[Package mgwnbr version 0.2.0 Index]