A Hierarchical Linear Model (HLM) with local fixed effects.
hgwr(
formula,
data,
...,
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
)# S3 method for sf
hgwr(
formula,
data,
...,
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
)
# S3 method for data.frame
hgwr(
formula,
data,
...,
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
)
hgwr_fit(
formula,
data,
coords,
bw = c("CV", "AIC"),
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
)
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.
A formula.
Its structure is similar to lmer
function
in lme4 package.
Models can be specified with the following form:
response ~ L(local.fixed) + global.fixed + (random | group)
For more information, please see the formula
subsection in details.
The data.
Further arguments for the specified type of data
.
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.
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\)
A numeric value. It is the size of the first trial step in maximum likelihood algorithm.
A numeric value. Terminate threshold of back-fitting.
A numeric value. Terminate threshold of maximum likelihood algorithm.
An integer value. The maximum of iteration.
An integer value. If the algorithm tends to be diverge, it stops automatically after trying max_retires times.
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.
An integer value. Determine the log level. Possible values are:
no log is printed.
only logs in back-fitting are printed.
all logs are printed.
A 2-column matrix. It consists of coordinates for each group.
hgwr_fit()
: Fit a HGWR model
In the HGWR model, there are three types of effects specified by the
formula
argument:
Effects wrapped by functional symbol L
.
Effects specified outside the functional symbol L
but to the left of symbol |
.
Other effects
For example, the following formula in the example of this function below is written as
y ~ L(g1 + g2) + x1 + (z1 | group)
where g1
and g2
are local fixed effects,
x1
is the global fixed effects,
and z1
is the random effects grouped by the group indicator group
.
Note that random effects can only be specified once!
data(multisampling)
hgwr(formula = y ~ L(g1 + g2) + x1 + (z1 | group),
data = multisampling$data,
coords = multisampling$coords,
bw = 10)
Run the code above in your browser using DataLab