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:
callCall
formulaModel formula
familyFamily
coordCoordinates used in the model
bEstimate of regression parameters
s.e.Standard errors
zDepending on the family, either a z or t value
pp-values
fittedFitted values from the model
residPearson residuals
b.smParameter estimates of neglected smooth part
fitted.smFitted values of neglected smooth part
levelSelected level of wavelet decomposition
waveletSelected wavelet
wtrafoSelected wavelet transformation
padzoneSelected padding zone expansion factor
padformSelected matrix padding type
n.effEffective number of observations
AICAkaike information criterion
AICcAIC score corrected for small sample sizes
LogLikLog likelihood of the model
ac.glmAutocorrelation of GLM residuals
ac.wrmAutocorrelation of WRM residuals
b.iniInitial parameter values
controlControl parameters for the fitting process
moran.paramsParameters for calculating Moran's I
padList of parameters for padding wavelet coefficients
plotAn 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