Skip to content

Commit

Permalink
Remove multispati.rtest and multispati.randtest
Browse files Browse the repository at this point in the history
  • Loading branch information
aursiber committed Jan 12, 2024
1 parent 414e5f6 commit b0dd93b
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 174 deletions.
4 changes: 3 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export("originality")
export("haar2level", "mld", "orthobasis.circ", "orthobasis.haar", "orthobasis.line", "orthobasis.mat", "orthobasis.neig", "is.orthobasis")

## ******* spatial *******
export("area2link", "area2poly", "area.plot", "dist.neig", "gridrowcol", "multispati.randtest", "mstree", "multispati.rtest", "nb2neig", "neig", "neig2mat", "neig2nb", "poly2area", "scores.neig")
export("area2link", "area2poly", "area.plot", "dist.neig", "gridrowcol", "mstree", "nb2neig", "neig", "neig2mat", "neig2nb", "poly2area", "scores.neig")

## ******* misc *********
export("bwca.dpcoa")
Expand Down Expand Up @@ -276,6 +276,8 @@ export("testertracenubisCpp")
## "plot.multispati"
## "print.multispati"
## "plot.multispati"
## "multispati.randtest"
## "multispati.rtest"

## ******* internal utilities *******

Expand Down
78 changes: 78 additions & 0 deletions R/ade4-deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -1199,3 +1199,81 @@
s.match(x$li, x$ls, xax = xax, yax = yax, sub = "Scores and lag scores", csub = 2, clabel = 0.75)

}

"multispati.randtest" <- function (dudi, listw, nrepet = 999, ...) {

.Deprecated(new="multispati.randtest", package="ade4",
msg="The 'multispati.randtest' function is now deprecated in 'ade4' and will soon be available in the 'adespatial' package.")

if(!inherits(dudi,"dudi")) stop ("object of class 'dudi' expected")
if(!inherits(listw,"listw")) stop ("object of class 'listw' expected")
if(listw$style!="W") stop ("object of class 'listw' with style 'W' expected")

"testmultispati"<- function(nrepet, nr, nc, tab, mat, lw, cw) {
.C("testmultispati",
as.integer(nrepet),
as.integer(nr),
as.integer(nc),
as.double(as.matrix(tab)),
as.double(mat),
as.double(lw),
as.double(cw),
inersim=double(nrepet+1),
PACKAGE="ade4")$inersim
}

tab<- dudi$tab
nr<-nrow(tab)
nc<-ncol(tab)
mat<-spdep::listw2mat(listw)
lw<- dudi$lw
cw<- dudi$cw
if (!(identical(all.equal(lw,rep(1/nrow(tab), nrow(tab))),TRUE))) {
stop ("Not implemented for non-uniform weights")
}
inersim<- testmultispati(nrepet, nr, nc, tab, mat, lw, cw)
inertot<- sum(dudi$eig)
inersim<- inersim/inertot
obs <- inersim[1]
w <- as.randtest(sim = inersim[-1], obs = obs, call = match.call(), ...)
return(w)
}

"multispati.rtest" <- function (dudi, listw, nrepet = 99, ...) {

.Deprecated(new="multispati.rtest", package="ade4",
msg="The 'multispati.rtest' function is now deprecated in 'ade4' and will soon be available in the 'adespatial' package.")

if(!inherits(listw,"listw")) stop ("object of class 'listw' expected")
if(listw$style!="W") stop ("object of class 'listw' with style 'W' expected")
if (!(identical(all.equal(dudi$lw,rep(1/nrow(dudi$tab), nrow(dudi$tab))),TRUE))) {
stop ("Not implemented for non-uniform weights")
}

n <- length(listw$weights)
fun.lag <- function (x) spdep::lag.listw(listw,x,TRUE)
fun <- function (permuter = TRUE) {
if (permuter) {
permutation <- sample(n)
y <- dudi$tab[permutation,]
yw <- dudi$lw[permutation]
} else {
y <-dudi$tab
yw <- dudi$lw
}
y <- as.matrix(y)
ymoy <- apply(y, 2, fun.lag)
ymoy <- ymoy*yw
y <- y*ymoy
indexmoran <- sum(apply(y,2,sum)*dudi$cw)
return(indexmoran)
}
inertot <- sum(dudi$eig)
obs <- fun (permuter = FALSE)/inertot
if (nrepet == 0) return(obs)
perm <- unlist(lapply(1:nrepet, fun))/inertot
w <- as.randtest(obs = obs, sim = perm, call = match.call(), ...)
return(w)
}


39 changes: 0 additions & 39 deletions R/multispati.randtest.R

This file was deleted.

38 changes: 0 additions & 38 deletions R/multispati.rtest.R

This file was deleted.

2 changes: 0 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ reference:
- orthobasis.line
- orthobasis.mat
- orthobasis.neig
- multispati.randtest
- multispati.rtest
- nb2neig
- neig
- neig2mat
Expand Down
2 changes: 2 additions & 0 deletions man/ade4-deprecated.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- \code{freq2genet}: replaced by \code{df2genind} and \code{genind2genpop} in the \code{adegenet} package \cr
- \code{fuzzygenet}: replaced by \code{df2genind} in the \code{adegenet} package \cr
- \code{multispati}: replaced by \code{multispati} in the \code{adespatial} package \cr
- \code{multispati.rtest} \cr
- \code{multispati.randtest} \cr
- \code{optimEH}: replaced by \code{optimEH} in the \code{adiv} package \cr
- \code{orisaved}: replaced by \code{orisaved} in the \code{adiv} package \cr
- \code{orthogram}: replaced by \code{orthogram} in the \code{adephylo} package \cr
Expand Down
47 changes: 0 additions & 47 deletions man/multispati.randtest.Rd

This file was deleted.

47 changes: 0 additions & 47 deletions man/multispati.rtest.Rd

This file was deleted.

0 comments on commit b0dd93b

Please sign in to comment.