Commit 5c9f0fe2 authored by Andreas Tille's avatar Andreas Tille

New upstream version 1.1-2+dfsg

parent d37c0789
Package: spdep
Version: 0.8-1
Date: 2018-11-21
Version: 1.1-2
Date: 2019-04-05
Title: Spatial Dependence: Weighting Schemes, Statistics and Models
Encoding: UTF-8
Authors@R: c(person("Roger", "Bivand", role = c("cre", "aut"), email = "Roger.Bivand@nhh.no", comment=c(ORCID="0000-0003-2392-6140")), person("Micah", "Altman", role = "ctb"),
......@@ -21,6 +21,7 @@ Authors@R: c(person("Roger", "Bivand", role = c("cre", "aut"), email = "Roger.Bi
person("Elias", "Krainski", role = "ctb"),
person("Pierre", "Legendre", role = "ctb"),
person("Nicholas", "Lewin-Koh", role = "ctb"),
person("Angela", "Li", role = "ctb"),
person("Hongfei", "Li", role = "ctb"),
person("Jielai", "Ma", role = "ctb"),
person("Abhirup", "Mallik", role = c("ctb", "trl")),
......@@ -33,13 +34,12 @@ Authors@R: c(person("Roger", "Bivand", role = c("cre", "aut"), email = "Roger.Bi
person("Michael", "Tiefelsdorf", role = "ctb"),
person("René", "Westerholt", role="ctb"),
person("Danlin", "Yu", role = "ctb"))
Depends: R (>= 3.3.0), methods, sp (>= 1.0), Matrix (>= 1.0.12), spData
(>= 0.2.6.0)
Imports: LearnBayes, deldir, boot (>= 1.3-1), splines, coda, nlme,
MASS, stats, gmodels, expm, graphics, grDevices, utils
Suggests: sf, parallel, spam(>= 2.1-0), RANN, rgeos, RColorBrewer,
lattice, xtable, maptools (>= 0.5-4), foreign, igraph, knitr,
rgdal, classInt
Depends: R (>= 3.3.0), methods, sp (>= 1.0), spData (>= 0.2.6.0), sf
Imports: deldir, boot (>= 1.3-1), graphics, grDevices, utils, stats,
Matrix, LearnBayes, MASS, coda, expm, gmodels, nlme
Suggests: spatialreg (>= 1.1-1), parallel, RANN, rgeos, RColorBrewer,
lattice, xtable, maptools (>= 0.5-4), foreign, igraph,
RSpectra, knitr, rgdal, classInt, tmap, spam
URL: https://github.com/r-spatial/spdep/
BugReports: https://github.com/r-spatial/spdep/issues/
Description: A collection of functions to create spatial weights matrix
......@@ -47,20 +47,37 @@ Description: A collection of functions to create spatial weights matrix
tessellations, for summarizing these objects, and for permitting their
use in spatial data analysis, including regional aggregation by minimum
spanning tree; a collection of tests for spatial 'autocorrelation',
including global 'Morans I', 'APLE', 'Gearys C', 'Hubert/Mantel' general cross
product statistic, Empirical Bayes estimates and 'Assunção/Reis' Index,
'Getis/Ord' G and multicoloured join count statistics, local 'Moran's I'
and 'Getis/Ord' G, 'saddlepoint' approximations, exact tests for global
and local 'Moran's I' and 'LOSH' local indicators of spatial heteroscedasticity;
and functions for estimating spatial simultaneous
'autoregressive' ('SAR') lag and error models, impact measures for lag
models, weighted and 'unweighted' 'SAR' and 'CAR' spatial regression models,
semi-parametric and Moran 'eigenvector' spatial filtering, 'GM SAR' error
models, and generalized spatial two stage least squares models.
including global 'Morans I' and 'Gearys C' proposed by 'Cliff' and 'Ord'
(1973, ISBN: 0850860369) and (1981, ISBN: 0850860814), 'Hubert/Mantel'
general cross product statistic, Empirical Bayes estimates and
'Assunção/Reis' (1999) <doi:10.1002/(SICI)1097-0258(19990830)18:16%3C2147::AID-SIM179%3E3.0.CO;2-I> Index, 'Getis/Ord' G ('Getis' and 'Ord' 1992)
<doi:10.1111/j.1538-4632.1992.tb00261.x> and multicoloured
join count statistics, 'APLE' ('Li 'et al.' )
<doi:10.1111/j.1538-4632.2007.00708.x>, local 'Moran's I'
('Anselin' 1995) <doi:10.1111/j.1538-4632.1995.tb00338.x> and
'Getis/Ord' G ('Ord' and 'Getis' 1995)
<doi:10.1111/j.1538-4632.1995.tb00912.x>,
'saddlepoint' approximations ('Tiefelsdorf' 2002)
<doi:10.1111/j.1538-4632.2002.tb01084.x> and exact tests
for global and local 'Moran's I' ('Bivand et al.' 2009)
<doi:10.1016/j.csda.2008.07.021> and 'LOSH' local indicators
of spatial heteroscedasticity ('Ord' and 'Getis')
<doi:10.1007/s00168-011-0492-y>. The implementation of most of
the measures is described in 'Bivand' and 'Wong' (2018)
<doi:10.1007/s11749-018-0599-x>.
'spdep' >= 1.1-1 corresponds to 'spatialreg' >= 1.1-1, in which the model
fitting functions are deprecated and pass through to 'spatialreg', but
will mask those in 'spatialreg'. From versions 1.2-1, the functions will
be made defunct in 'spdep'.
For now 'spatialreg' only has functions from 'spdep', where they are shown
as deprecated. 'spatialreg' only loads the namespace of 'spdep'; if you
attach 'spdep', the same functions in the other package will be masked.
Some feed through adequately, others do not.
License: GPL (>= 2)
VignetteBuilder: knitr
RoxygenNote: 6.1.1
NeedsCompilation: yes
Packaged: 2018-11-21 09:58:45 UTC; rsb
Packaged: 2019-04-05 17:21:04 UTC; rsb
Author: Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>),
Micah Altman [ctb],
Luc Anselin [ctb],
......@@ -80,6 +97,7 @@ Author: Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>),
Elias Krainski [ctb],
Pierre Legendre [ctb],
Nicholas Lewin-Koh [ctb],
Angela Li [ctb],
Hongfei Li [ctb],
Jielai Ma [ctb],
Abhirup Mallik [ctb, trl],
......@@ -94,4 +112,4 @@ Author: Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>),
Danlin Yu [ctb]
Maintainer: Roger Bivand <Roger.Bivand@nhh.no>
Repository: CRAN
Date/Publication: 2018-11-21 11:30:03 UTC
Date/Publication: 2019-04-05 19:40:03 UTC
This diff is collapsed.
This diff is collapsed.
......@@ -20,8 +20,8 @@ setOldClass(c("listw"))
# require(methods)
#}
#.onLoad <- function(pkg, lib) {
#cat("spdep: a package for analysing spatial dependence\n")
#.onAttach <- function(lib, pkg) {
#packageStartupMessage("spdep: a package for analysing spatial dependence\nDEPRECATED: from 1.1-1, spatial regression functions moved to the spatialreg package\n", appendLF = FALSE)
#require(maptools)
#.First.lib <- function(lib, pkg) {
# library.dynam("spdep", pkg, lib)
......
......@@ -3,6 +3,14 @@
LR.sarlm <- function(x, y)
{
.Deprecated("spatialreg::LR.sarlm", msg="Method LR.sarlm moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::LR.sarlm(x=x, y=y))
}
warning("install the spatialreg package")
# if (FALSE) {
if (!inherits(x, "logLik")) LLx <- logLik(x)
else LLx <- x
if (!inherits(y, "logLik")) LLy <- logLik(y)
......@@ -24,8 +32,17 @@ LR.sarlm <- function(x, y)
class(res) <- "htest"
res
}
#}
logLik.sarlm <- function(object, ...) {
.Deprecated("spatialreg::logLik.sarlm", msg="Method logLik.sarlm moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::logLik.sarlm(object=object, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
LL <- c(object$LL)
class(LL) <- "logLik"
N <- length(residuals(object))
......@@ -34,6 +51,7 @@ logLik.sarlm <- function(object, ...) {
attr(LL, "df") <- object$parameters
LL
}
#}
#residuals.sarlm <- function(object, ...) return(object$residuals)
# Copyright 2005-2008 by Roger Bivand and Pedro Peres-Neto (from Matlab)
#
ME <- function(formula, data, family = gaussian, weights, offset, listw,
alpha=0.05, nsim=99, verbose=NULL, stdev=FALSE) {
ME <- function(formula, data=list(), family = gaussian, weights, offset,
na.action=na.fail,listw=NULL, alpha=0.05, nsim=99, verbose=NULL,
stdev=FALSE, zero.policy=NULL) {
.Deprecated("spatialreg::ME", msg="Function ME moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
if (!missing(weights) || !missing(offset)) stop("run spatialreg::ME directly")
return(spatialreg::ME(formula=formula, data=data, family = family,
na.action=na.action,listw=listw, alpha=alpha, nsim=nsim, verbose=verbose,
stdev=stdev, zero.policy=zero.policy))
}
warning("install the spatialreg package")
# if (FALSE) {
MoraneI.boot <- function(var, i, ...) {
var <- var[i]
I <- (n/S0)*(crossprod(sW %*% var, var))/cpvar
......@@ -26,16 +38,13 @@ ME <- function(formula, data, family = gaussian, weights, offset, listw,
res <- list(estimate=mi, statistic=zi, p.value=pri)
res
}
if (is.null(zero.policy))
zero.policy <- get("zeroPolicy", envir = .spdepOptions)
stopifnot(is.logical(zero.policy))
if (is.null(verbose)) verbose <- get("verbose", envir = .spdepOptions)
stopifnot(is.logical(verbose))
listw <- listw2U(listw) # make weights symmetric
sW <- as(listw, "CsparseMatrix")
Wmat <- listw2mat(listw) # convert to full matrix form
n <- ncol(Wmat)
S0 <- Szero(listw)
# argument handling copied from stats:::glm
# call <- match.call()
if (is.character(family))
......@@ -47,7 +56,8 @@ ME <- function(formula, data, family = gaussian, weights, offset, listw,
}
if (missing(data)) data <- environment(formula)
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "weights", "offset"), names(mf), 0)
m <- match(c("formula", "data", "weights", "offset", "na.action"),
names(mf), 0)
mf <- mf[c(1, m)]
mf$drop.unused.levels <- TRUE
mf[[1]] <- as.name("model.frame")
......@@ -65,6 +75,20 @@ ME <- function(formula, data, family = gaussian, weights, offset, listw,
if (!is.null(offset) && length(offset) != NROW(Y))
stop("number of offsets should equal number of observations")
na.act <- attr(mf, "na.action")
if (!is.null(na.act)) {
subset <- !(1:length(listw$neighbours) %in% na.act)
listw <- subset(listw, subset, zero.policy=zero.policy)
}
listw <- listw2U(listw) # make weights symmetric
sW <- as(listw, "CsparseMatrix")
Wmat <- listw2mat(listw) # convert to full matrix form
n <- ncol(Wmat)
S0 <- Szero(listw)
glm_fit <- glm.fit(x=X, y=Y, weights=weights, offset=offset,
family=family)
glm_res <- glm_fit$y - glm_fit$fitted.values
......@@ -160,16 +184,55 @@ ME <- function(formula, data, family = gaussian, weights, offset, listw,
colnames(tres) <- c("Eigenvector", "ZI", "pr(ZI)")
rownames(tres) <- 0:(nrow(tres)-1)
res <- list(selection=tres, vectors=sv)
if (!is.null(na.act))
res$na.action <- na.act
class(res) <- "ME_res"
res
}
#}
print.ME_res <- function(x, ...) {
.Deprecated("spatialreg::print.ME_res", msg="Method print.ME_res moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::print.ME_res(x=x, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
print(x$selection)
}
#}
fitted.ME_res <- function(object, ...) {
object$vectors
.Deprecated("spatialreg::fitted.ME_res", msg="Method fitted.ME_res moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::fitted.ME_res(object=object, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
if (is.null(object$na.action)) {
res <- object$vectors
} else {
omitted_rows <- unname(object$na.action)
res <- matrix(as.numeric(NA), ncol=ncol(object$vectors),
nrow=length(omitted_rows)+nrow(object$vectors))
i <- j <- k <- 1
while (i <= nrow(res)) {
if (j <= length(omitted_rows) && i == omitted_rows[j]) {
i <- i+1
j <- j+1
} else {
res[i,] <- object$vectors[k,]
i <- i+1
k <- k+1
}
}
}
res
}
#}
SpatialFiltering <- function (formula, lagformula, data=list(), nb,
SpatialFiltering <- function (formula, lagformula=NULL, data=list(), na.action=na.fail, nb=NULL,
glist=NULL, style="C", zero.policy=NULL, tol=0.1, zerovalue = 0.0001,
ExactEV=FALSE, symmetric=TRUE, alpha=NULL, alternative="two.sided",
verbose=NULL) {
......@@ -34,6 +34,17 @@ SpatialFiltering <- function (formula, lagformula, data=list(), nb,
#
# Version 0.9.1 - September 11, 2004
# Adaptation to formula format Roger Bivand December 2005
.Deprecated("spatialreg::SpatialFiltering", msg="Function SpatialFiltering moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::SpatialFiltering(formula=formula, lagformula=lagformula, data=data, na.action=na.action, nb=nb,
glist=glist, style=style, zero.policy=zero.policy, tol=tol, zerovalue = zerovalue,
ExactEV=ExactEV, symmetric=symmetric, alpha=alpha, alternative=alternative,
verbose=verbose))
}
warning("install the spatialreg package")
# if (FALSE) {
if (missing(nb)) stop("Neighbour list argument missing")
if (missing(formula)) stop("Formula argument missing")
......@@ -42,27 +53,42 @@ SpatialFiltering <- function (formula, lagformula, data=list(), nb,
if (is.null(zero.policy))
zero.policy <- get("zeroPolicy", envir = .spdepOptions)
stopifnot(is.logical(zero.policy))
lw <- nb2listw(nb, glist=glist, style=style, zero.policy=zero.policy)
if (symmetric) lw <- listw2U(lw)
S <- listw2mat(lw)
a <- sum(S)
S <- nrow(S)/a*S
nofreg <- nrow(S) # number of observations
# Generate Eigenvectors if eigen vectors are not given
# (M1 for no SAR, MX for SAR)
if (class(formula) != "formula") formula <- as.formula(formula)
mt <- terms(formula, data = data)
mf <- lm(formula, data, method="model.frame")
if (missing(data)) data <- environment(formula)
mf <- match.call(expand.dots = FALSE)
m <- match(c("formula", "data", "na.action"), names(mf), 0)
mf <- mf[c(1, m)]
mf$drop.unused.levels <- TRUE
mf[[1]] <- as.name("model.frame")
mf <- eval(mf, parent.frame())
mt <- attr(mf, "terms")
y <- model.extract(mf, "response")
if (any(is.na(y))) stop("NAs in dependent variable")
xsar <- model.matrix(mt, mf)
if (any(is.na(xsar))) stop("NAs in independent variable")
if (NROW(xsar) != length(nb))
lw <- nb2listw(nb, glist=glist, style=style, zero.policy=zero.policy)
na.act <- attr(mf, "na.action")
if (!is.null(na.act)) {
subset <- !(1:length(lw$neighbours) %in% na.act)
lw <- subset(lw, subset, zero.policy=zero.policy)
}
if (NROW(xsar) != length(lw$neighbours))
stop("Input data and neighbourhood list have different dimensions")
if (symmetric) lw <- listw2U(lw)
S <- listw2mat(lw)
a <- sum(S)
S <- nrow(S)/a*S
nofreg <- nrow(S) # number of observations
mx <- diag(1,nofreg) - xsar %*% qr.solve(crossprod(xsar), t(xsar))
S <- mx %*% S %*% mx
......@@ -277,18 +303,58 @@ SpatialFiltering <- function (formula, lagformula, data=list(), nb,
#Generating a result object
SFResult <- list(selection=out, dataset=selVec)
if (!is.null(na.act))
SFResult$na.action <- na.act
class(SFResult) <- "SFResult"
return(SFResult)
}
#}
print.SFResult <- function(x, ...) {
.Deprecated("spatialreg::print.SFResult", msg="Method print.SFResult moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::print.SFResult(x=x, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
print(x$selection, ...)
}
#}
fitted.SFResult <- function(object, ...) {
object$dataset
.Deprecated("spatialreg::fitted.SFResult", msg="Method fitted.SFResult moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::fitted.SFResult(object=object, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
if (is.null(object$na.action)) {
res <- object$dataset
} else {
omitted_rows <- unname(object$na.action)
res <- matrix(as.numeric(NA), ncol=ncol(object$dataset),
nrow=length(omitted_rows)+nrow(object$dataset))
i <- j <- k <- 1
while (i <= nrow(res)) {
if (j <= length(omitted_rows) && i == omitted_rows[j]) {
i <- i+1
j <- j+1
} else {
res[i,] <- object$dataset[k,]
i <- i+1
k <- k+1
}
}
}
res
}
#}
#if (FALSE) {
GetMoranStat <- function(MSM, degfree) {
#MSM : M %*% S %*% M matrix
# M : projection matrix
......@@ -303,6 +369,6 @@ GetMoranStat <- function(MSM, degfree) {
V <- 2 * (degfree * t2 - t1 * t1)/(degfree * degfree * (degfree + 2))
return(list(Mean=E,Var=V))
}
#}
......@@ -2,6 +2,14 @@
#
anova.sarlm <- function(object, ...) {
.Deprecated("spatialreg::anova.sarlm", msg="Method anova.sarlm moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::anova.sarlm(object=object, ...))
}
warning("install the spatialreg package")
# if (FALSE) {
if (length(list(object, ...)) > 1L) {
getResponseFormula <- function (object)
{
......@@ -72,5 +80,6 @@ anova.sarlm <- function(object, ...) {
return(res)
}
}
#}
preAple <- function(x, listw, override_similarity_check=FALSE, useTrace=TRUE) {
stopifnot(isTRUE(all.equal(mean(x), 0.0)))
stopifnot(is.vector(x))
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
W <- as(listw, "CsparseMatrix")
n <- dim(W)[1]
if (useTrace) {
......
......@@ -17,6 +17,6 @@ localAple <- function(x, listw, override_similarity_check=FALSE, useTrace=TRUE)
aplepl <- aple.plot(x, listw,
override_similarity_check=override_similarity_check,
useTrace=useTrace, do.plot=FALSE)
res <- (length(aplepl$X) * aplepl$Y * aplepl$X) / crossprod(aplepl$X)
res <- (length(aplepl$X) * aplepl$Y * aplepl$X) / c(crossprod(aplepl$X))
res
}
......@@ -30,7 +30,25 @@ autocov_dist <- function(z, xy, nbs=1, type="inverse", zero.policy=NULL,
longlat <- TRUE
} else longlat <- FALSE
xy <- coordinates(xy)
} else if (is.null(longlat) || !is.logical(longlat)) longlat <- FALSE
} else {
if (inherits(xy, "sf")) {
if (is.null(row.names)) row.names <- row.names(xy)
xy <- sf::st_geometry(xy)
}
if (inherits(xy, "sfc")) {
if (!is.null(longlat))
warning("dnearneigh: longlat argument overriden by object")
if (!inherits(xy, "sfc_POINT"))
stop("Point geometries required")
if (attr(xy, "n_empty") > 0L)
stop("Empty geometries found")
if (!is.na(sf::st_is_longlat(xy)) && sf::st_is_longlat(xy)) {
longlat <- TRUE
} else longlat <- FALSE
xy <- sf::st_coordinates(xy)
}
}
if (is.null(longlat) || !is.logical(longlat)) longlat <- FALSE
stopifnot(ncol(xy) == 2)
if (longlat) {
bb <- bbox(xy)
......
......@@ -5,6 +5,14 @@
bptest.sarlm <- function (object, varformula=NULL, studentize = TRUE, data=list())
{
.Deprecated("spatialreg::bptest.sarlm", msg="Method bptest.sarlm moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::bptest.sarlm(object=object, varformula=varformula, studentize = studentize, data=data))
}
warning("install the spatialreg package")
# if (FALSE) {
if(!inherits(object, "sarlm")) stop("not sarlm object")
Z <- object$tarX
if (!is.null(varformula)) Z <- model.matrix(varformula, data = data)
......@@ -34,4 +42,5 @@ bptest.sarlm <- function (object, varformula=NULL, studentize = TRUE, data=list(
class(RVAL) <- "htest"
return(RVAL)
}
#}
......@@ -57,7 +57,8 @@ queencell <- function(rowcol, nrow, ncol, torus=FALSE, rmin=1, cmin=1) {
mrc2vi <- function(rowcol, nrow, ncol) {
i <- ((rowcol[,2]-1) * nrow) + rowcol[,1]
if (i > nrow*ncol || i < 1) stop("row or column out of range")
if (any(i > (nrow*ncol)) || any(i < 1))
stop("row or column out of range")
as.integer(i)
}
......
# Copyright 2000-2014 by Roger S. Bivand.
# Copyright 2000-2019 by Roger S. Bivand.
# Upgrade to sp classes February 2007
#
dnearneigh <- function(x, d1, d2, row.names=NULL, longlat=NULL, bounds=c("GT", "LE")) {
if (inherits(x, "SpatialPoints")) {
if (inherits(x, "SpatialPoints")) {
# correct logic
if (!is.null(longlat))
warning("dnearneigh: longlat overriden for Spatial object")
if (!is.na(is.projected(x)) && !is.projected(x)) {
warning("dnearneigh: longlat argument overrides object")
if ((is.null(longlat) || !is.logical(longlat))
&& !is.na(is.projected(x)) && !is.projected(x)) {
longlat <- TRUE
} else longlat <- FALSE
x <- coordinates(x)[, 1:2]
} else if (is.null(longlat) || !is.logical(longlat)) longlat <- FALSE
} else {
if (inherits(x, "sf")) {
if (is.null(row.names)) row.names <- row.names(x)
x <- sf::st_geometry(x)
}
if (inherits(x, "sfc")) {
if (!is.null(longlat))
warning("dnearneigh: longlat argument overrides object")
if (!inherits(x, "sfc_POINT"))
stop("Point geometries required")
if (attr(x, "n_empty") > 0L)
stop("Empty geometries found")
if ((is.null(longlat) || !is.logical(longlat))
&& !is.na(sf::st_is_longlat(x)) && sf::st_is_longlat(x)) {
longlat <- TRUE
} else longlat <- FALSE
x <- sf::st_coordinates(x)
}
}
if (is.null(longlat) || !is.logical(longlat)) longlat <- FALSE
if (!is.numeric(x)) stop("Data non-numeric")
if (!is.matrix(x)) stop("Data not in matrix form")
stopifnot(ncol(x) == 2)
......
......@@ -3,6 +3,14 @@
eigenw <- function(listw, quiet=NULL)
{
.Deprecated("spatialreg::eigenw", msg="Function eigenw moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::eigenw(listw=listw, quiet=quiet))
}
warning("install the spatialreg package")
# if (FALSE) {
if(!inherits(listw, "listw")) stop("not a listw object")
if (is.null(quiet)) quiet <- !get("verbose", envir = .spdepOptions)
stopifnot(is.logical(quiet))
......@@ -18,8 +26,17 @@ eigenw <- function(listw, quiet=NULL)
}
e
}
#}
griffith_sone <- function(P, Q, type="rook") {
.Deprecated("spatialreg::griffith_sone", msg="Function griffith_sone moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::griffith_sone(P=P, Q=Q, type=type))
}
warning("install the spatialreg package")
# if (FALSE) {
stopifnot(P >= 1)
stopifnot(Q >= 1)
p <- seq(1:P)
......@@ -34,9 +51,19 @@ griffith_sone <- function(P, Q, type="rook") {
res <- sort(c(res0), decreasing=TRUE)
res
}
#}
subgraph_eigenw <- function(nb, glist=NULL, style="W", zero.policy=NULL,
quiet=NULL) {
.Deprecated("spatialreg::subgraph_eigenw", msg="Function subgraph_eigenw moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
return(spatialreg::subgraph_eigenw(nb=nb, glist=glist, style=style, zero.policy=zero.policy,
quiet=quiet))
}
warning("install the spatialreg package")
# if (FALSE) {
if(!inherits(nb, "nb")) stop("Not a neighbours list")
if (is.null(quiet)) quiet <- !get("verbose", envir = .spdepOptions)
stopifnot(is.logical(quiet))
......@@ -74,3 +101,5 @@ subgraph_eigenw <- function(nb, glist=NULL, style="W", zero.policy=NULL,
stop("length mismatch, eout:", length(eout))
eout
}
#}
# Copyright 2009-2013 by Roger Bivand
#if (FALSE) {
getVmate <- function(coefs, env, s2, trs, tol.solve=1.0e-10, optim=FALSE,
optimM="optimHess") {
if (optim) {
......@@ -80,4 +80,5 @@ insert_asye <- function(coefs, env, s2, mat, trs) {
# omat[1, 2] <- omat[2, 1] <- -trB(lambda, trs)
omat
}
#}
......@@ -4,6 +4,15 @@
errorsarlm <- function(formula, data = list(), listw, na.action, weights=NULL,
Durbin, etype, method="eigen", quiet=NULL, zero.policy=NULL,
interval=NULL, tol.solve=1.0e-10, trs=NULL, control=list()) {
.Deprecated("spatialreg::errorsarlm", msg="Function errorsarlm moved to the spatialreg package")
# if (!requireNamespace("spatialreg", quietly=TRUE))
# stop("install the spatialreg package")
if (requireNamespace("spatialreg", quietly=TRUE)) {
if (!missing(weights)) stop("run spatialreg::errorsarlm directly")
return(spatialreg::errorsarlm(formula=formula, data=data,listw=listw, na.action=na.action, Durbin=Durbin, etype=etype, method=method, quiet=quiet, zero.policy=zero.policy, interval=interval, tol.solve=tol.solve, trs=trs, control=control))
}
warning("install the spatialreg package")
# if (FALSE) {
timings <- list()