On Tue, 29 Mar 2005, Chloe ARCHINARD wrote:

> Hello all, I'm a new user of R and I have used the spdep package to

> calculate Moran's I estimates. I used the dnearneigh() function and

> moran.test() function and obtained what I wanted, but now I want to plot

> my results with the p-values. I regrouped my results for the Moran's I

> like

> >m=c(m1$e,m2$e...) #m1 contain the results of the moran.test for lag1

> >p=c(m1$p.v,m2$p.v...)

> The problem is that in mx$e there are three values (moran'I statistic,

> expectation and variance) and when I plot my results I plot all the

> three values for each lag. What should I do to choose only the statistic

> for plotting and maybe the variance for each I statistic? (For the

> p-value it's ok I have found how to differentiate the significant and

> non significant values.) I hope someone understand my question and could

> help me! Thanks a lot.

If you have the output object from moran.test()

data(oldcol)

res <- moran.test(COL.OLD$CRIME, nb2listw(COL.nb))

str(res) # shows the structure of the object

est <- res$estimate[1]

pv <- res$p.value

I suggest you make a list of test result objects for your distance lags,

and then use sapply(mylist, function(x) c(x$estimate[1], x$p.value)) to

extract the values (you may need t() around the result to transpose the

output). I'll try to add an example like this to moran.test() - any

suggestions of a well-known suitable data set with known Moran's I values

and distance bands?

Roger

>

> Chlo? ARCHINARD

> Centre d'Ecologie Fonctionnelle et Evolutive

> (C.N.R.S.-U.M.R. 5175)

> 1919, Route de Mende

> 34293 Montpellier Cedex 5 France

> chloe.archinard at cefe.cnrs.fr

>

>

>

--

Roger Bivand

Economic Geography Section, Department of Economics, Norwegian School of

Economics and Business Administration, 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

Roger Bivand

Department of Economics

Norwegian School of Economics

Helleveien 30

N-5045 Bergen, Norway