hw3<-read.table("http://www.public.iastate.edu/~pcaragea/S40608/HW/hw3.txt",header=TRUE) attach(hw3)# library(spdep) nb.pl=dnearneigh(x=cbind(u,v),d1=0,d2=250) col.W <- nb2listw(nb.pl, style="W")#constructs necessary summaries for calling moran and other functions Observed=elev MI.PL=moran(Observed, col.W, length(nb.pl), Szero(col.W)) moran.plot(Observed,col.W,xlab="Obs",ylab="Neighb")# title(main=paste("Moran's I for year for original elevation data",round(MI.PL$I,3))) moran.test(Observed,col.W,rank=TRUE) moran.mc(Observed,col.W,nsim=999) moist.lm=lm(moist~elev) ress=moist.lm$resid Observed=ress MI.PL=moran(Observed, col.W, length(nb.pl), Szero(col.W)) moran.plot(Observed,col.W,xlab="Obs",ylab="Neighb")# title(main=paste("Moran's I for year for original elevation data",round(MI.PL$I,3))) library(geoR) moist.g<-as.geodata(hw3,coords.col=1:2,data.col=3,covar.col=4) elev.all<-read.table("http://www.public.iastate.edu/~pcaragea/S40608/HW/hw3_all_elev.txt",header=TRUE) elev.all.geo<-as.geodata(elev.all,coords.col=1:2,covar.col=3) plot(elev.all.geo)