Hello,
Your code has basically 2 problems one minor and another that is more
important.
The minor one is when you use
COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, ozone.dists.inv)
since ozone.dists.inv is a matrix and the function lagsarlm reads listw you
have to convert it. so use mat2listw.
The more important problem is in dimensions
Ozone.dists.inv is a matrix of 32 x 32 inv distances and the data from
crime in columbus has 49 observations. so you have missing information.
please check that before running your models cause it will save you
headaches.
Juan


On Wed, Mar 13, 2013 at 11:28 PM, hnstedu <hnstedu@163.com> wrote:

> Hi, all
> I want to implement spatial model with spdep packages.Let me see the
> example,
>
>
> data(oldcol)
> COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
> nb2listw(COL.nb))
> summary(COL.lag.eig, correlation=TRUE)
>
>
> In the above, the neighbours spatial weight matrix created by nb2listw is
> used. Now I
> want to employ the inv distance weight matrix directly.
>
>
> For example, I creat the inv distance using the following codes (source:
> http://statistics.ats.ucla.edu/stat/r/faq/morans_i.htm)
> ozone<-read.table("http://www.ats.ucla.edu/stat/r/faq/ozone.csv",
> sep=",", header=T)
> ozone.dists <- as.matrix(dist(cbind(ozone$Lon, ozone$Lat)))
> ozone.dists.inv <- 1/ozone.dists
> diag(ozone.dists.inv) <- 0
>
>
> I want to employ the "ozone.dists.inv" matrix with my empirical analysis.
> That is to say
> COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data=COL.OLD, ozone.dists.inv)
>
>
> I can implement it with Matlab quickly.However,I cannot implement it with R
>
>
> Could anyone help me? Or give me some suggestions?
>
>
> Best,
> wanhai
>
>
>
>
>
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Juan Tomás Sayago Gómez
Graduate Research Assistant
West Virginia University - RRI
886 Chestnut Ridge Road, Room 520
P.O. Box 6825
Morgantown, WV 26506-6825

	[[alternative HTML version deleted]]

