hgwr {hgwrr}R Documentation

Hierarchical and Geographically Weighted Regression

Description

A Hierarchical Linear Model (HLM) with local fixed effects.

Usage

hgwr(
  formula,
  data,
  local.fixed,
  coords,
  bw = "CV",
  kernel = c("gaussian", "bisquared"),
  alpha = 0.01,
  eps_iter = 1e-06,
  eps_gradient = 1e-06,
  max_iters = 1e+06,
  max_retries = 1e+06,
  ml_type = c("D_Only", "D_Beta"),
  verbose = 0
)

Arguments

formula

A formula. Its structure is similar to lmer function in lme4 package.

data

A DataFrame.

local.fixed

A character vector. It contains names of local fixed effects.

coords

A 2-column matrix. It consists of coordinates for each group.

bw

A numeric value. It is the value of bandwidth or "CV". In this stage this function only support adaptive bandwidth. And its unit must be the number of nearest neighbours. If "CV" is specified, the algorithm will automatically select an optimized bandwidth value.

kernel

A character value. It specify which kernel function is used in GWR part. Possible values are

gaussian

Gaussian kernel function k(d)=\exp\left(-\frac{d^2}{b^2}\right)

bisquared

Bi-squared kernel function. If d<b then k(d)=\left(1-\frac{d^2}{b^2}\right)^2 else k(d)=0

alpha

A numeric value. It is the size of the first trial step in maximum likelihood algorithm.

eps_iter

A numeric value. Terminate threshold of back-fitting.

eps_gradient

A numeric value. Terminate threshold of maximum likelihood algorithm.

max_iters

An integer value. The maximum of iteration.

max_retries

An integer value. If the algorithm tends to be diverge, it stops automatically after trying max_retires times.

ml_type

An integer value. Represent which maximum likelihood algorithm is used. Possible values are:

D_Only

Only D is specified by maximum likelihood.

D_Beta

Both D and beta is specified by maximum likelihood.

verbose

An integer value. Determine the log level. Possible values are:

0

no log is printed.

1

only logs in back-fitting are printed.

2

all logs are printed.

Value

A list describing the model with following fields.

gamma

Coefficients of local fixed effects.

beta

Coefficients of global fixed effects.

mu

Coefficients of random effects.

D

Variance-covariance matrix of random effects.

sigma

Variance of errors.

effects

A list including names of all effects.

call

Calling of this function.

frame

The DataFrame object sent to this call.

frame.parsed

Variables extracted from the data.

groups

Unique group labels extracted from the data.

Examples

data(multisampling)
hgwr(formula = y ~ g1 + g2 + x1 + (z1 | group),
     data = multisampling$data,
     local.fixed = c("g1", "g2"),
     coords = multisampling$coords,
     bw = 10)


[Package hgwrr version 0.3-0 Index]