Skip to content
Prev 22654 / 29559 Next

A simple correlogram using sp.correlogram with data(meuse)

On Tue, 28 Apr 2015, Michael Treglia wrote:

            
The problem is that the ... is passed to try(), not moran.test() or 
geary.test() in:

xt <- switch(pmatch(method, c("Moran", "Geary"), nomatch = 3),
     try(moran.test(lst.z1[[i]], nb2listw(lst.nb1[[i]],
         style = "W")), silent = TRUE, ...), try(geary.test(lst.z1[[i]],
         nb2listw(lst.nb1[[i]], style = "W")), silent = TRUE,
         ...), stop("Method must be 'Moran' or 'Geary'"))

With:

xt <- switch(pmatch(method, c("Moran", "Geary"), nomatch = 3),
     try(moran.test(lst.z1[[i]], nb2listw(lst.nb1[[i]],
         style = "W"), ...), silent = TRUE), try(geary.test(lst.z1[[i]],
         nb2listw(lst.nb1[[i]], style = "W"), ...), silent = TRUE),
         stop("Method must be 'Moran' or 'Geary'"))

via for example correlog1 <- edit(correlog), it works. You can save the 
function for later use too.

Hope this helps,

Roger