A wavelet-based method to remove spatial autocorrelation in multiple linear regressions. Wavelet transforms are implemented using waveslim (Whitcher, 2005).
WRM(
formula,
family,
data,
coord,
level = 1,
wavelet = "haar",
wtrafo = "dwt",
b.ini = NULL,
pad = list(),
control = list(),
moran.params = list(),
plot = FALSE,
customize_plot = NULL
)# S3 method for WRM
plot(x, ...)
# S3 method for WRM
summary(object, ...)
# S3 method for WRM
predict(object, newdata, sm = FALSE, newcoord = NA, ...)
Model formula. Variable names must match variables in data
.
gaussian
, binomial
, or poisson
are supported.
A data frame with variable names that match the variables specified in formula
.
A matrix of two columns with corresponding cartesian coordinates. Currently only supports integer coordinates.
An integer specifying the degree of wavelet decomposition
0 - Without autocorrelation removal (equivalent to a GLM)
1 - For best autocorrelation removal
... - Higher integers possible. The limit depends on sample size
Name of wavelet family. haar
, d4
, and la8
.
are possible. haar
is the default.
Type of wavelet transform. Either dwt
or modwt
.
dwt
is the default.
Initial parameter values. Default is NULL.
A list of parameters for padding wavelet coefficients.
padform - 0, 1, and 2 are possible.
padform
is automatically set to
0 when either level
=0 or
a formula
including an intercept and a non-gaussian family
0 - Padding with 0s.
1 - Padding with mean values.
2 - Padding with mirror values.
padzone - Factor for expanding the padding zone
a list of parameters for controlling the fitting process.
eps
- Positive convergence tolerance. Smaller values of
eps
provide better parameter estimates, but also reduce the probability
of the iterations converging. In case of issues with convergence, test larger
values of eps
. Default is 10^-5.
denom.eps
- Default is 10^-20.
itmax
- Integer giving the maximum number of iterations.
Default is 200.
A list of parameters for calculating Moran's I.
lim1
- Lower limit for first bin. Default is 0.
increment
- Step size for calculating Moran's I. Default is 1.
A logical value indicating whether to plot autocorrelation of
residuals by distance bin. NOW DEPRECATED in favor of plot.WRM
method.
Additional plotting parameters passed to ggplot
.
NOW DEPRECATED in favor of plot.WRM
method.
An object of class GEE
or WRM
Not used
An object of class WRM
A data frame containing variables used to make predictions.
Logical. Should part of smooth components be included?
New coordinates corresponding to observations in newdata
.
An object of class WRM
. This consists of a list with the
following elements:
call
Call
formula
Model formula
family
Family
coord
Coordinates used in the model
b
Estimate of regression parameters
s.e.
Standard errors
z
Depending on the family
, either a z or t value
p
p-values
fitted
Fitted values from the model
resid
Pearson residuals
b.sm
Parameter estimates of neglected smooth part
fitted.sm
Fitted values of neglected smooth part
level
Selected level of wavelet decomposition
wavelet
Selected wavelet
wtrafo
Selected wavelet transformation
padzone
Selected padding zone expansion factor
padform
Selected matrix padding type
n.eff
Effective number of observations
AIC
Akaike information criterion
AICc
AIC score corrected for small sample sizes
LogLik
Log likelihood of the model
ac.glm
Autocorrelation of GLM residuals
ac.wrm
Autocorrelation of WRM residuals
b.ini
Initial parameter values
control
Control parameters for the fitting process
moran.params
Parameters for calculating Moran's I
pad
List of parameters for padding wavelet coefficients
plot
An object of class ggplot
containing information
on the autocorrelation of residuals from the fitted WRM
and a
GLM
WRM can be used to fit linear models for response vectors of different
distributions: gaussian
, binomial
, or poisson
.
As a spatial model, it is a generalized linear model in which the residuals
may be autocorrelated. It corrects for 2-dimensional residual
autocorrelation for regular gridded data sets using the wavelet
decomposition technique. The grid cells are assumed to be square.
Furthermore, this function requires that all predictor variables
be continuous.
Carl, G., Kuehn, I. (2010): A wavelet-based extension of generalized linear models to remove the effect of spatial autocorrelation. Geographical Analysis 42 (3), 323 - 337
Whitcher, B. (2005) Waveslim: basic wavelet routines for one-, two- and three-dimensional signal processing. R package version 1.5.
# NOT RUN {
data(musdata)
coords <- musdata[,4:5]
# }
# NOT RUN {
mwrm <- WRM(musculus ~ pollution + exposure,
family = "poisson",
data = musdata,
coord = coords,
level = 1)
pred <- predict(mwrm, newdata = musdata)
summary(mwrm)
plot(mwrm)
library(ggplot2)
my_wrm_plot <- mwrm$plot
# increase axis text size
print(my_wrm_plot + ggplot2::theme(axis.text = element_text(size = 15)))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab