[R-sig-Geo] Help: plot part of the correlogram
Roger Bivand
Roger.Bivand at nhh.no
Tue Apr 3 17:34:07 CEST 2012
On Tue, 3 Apr 2012, 李小马 wrote:
> Hi eveybody, I want to test the local sptial autocorrelation of my data
> (present and absence). My study area is about 16410 km square. I used
> correlog {ncf} to plot a correlogram. I want t set a lower increment.
> for example 200 meters. And I got a correlogram with many bins, which is
> not readable. So i hope i can just plot part of them, for example the
> first 50 points. From the achieve, i found that it can be conducted by
> "plot(XXX$correlation[1:50])". but it does not show the significance
> test. Can anybody help me plot such a map? or can we receive the P value
> of the first 50 points as we received the moran's I value? Thank you
> very much! Sincerely Xiaoma Li
Please learn about str() to see the internal structure of objects:
library(ncf)
x <- expand.grid(1:20, 1:5)[,1]
y <- expand.grid(1:20, 1:5)[,2]
z <- rmvn.spa(x=x, y=y, p=2, method="exp"),
fit1 <- correlog(x=x, y=y, z=z[,1], increment=0.1, resamp=1000)
plot(fit1)
str(fit1)
# fit1 is a list of class "correlog", with vector components of equal
# length. One is p, so:
fit1$p
# are the apparent p-values (uncorrected for multiple comparisons I think,
# computed by permutation) IMO not to be trusted especially for narrow
# increments
class(fit1) <- NULL
df1 <- as.data.frame(fit1)
fit2 <- as.list(df1[1:50,])
str(fit2)
class(fit2) <- "correlog"
# reconstruct object as class "correlog" after selecting rows from
# data.frame
plot(fit2)
Hope this helps,
Roger
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list