data(nc.sids)
stem(floor(sort(1000*(nc.sids$SID74 + 1)/nc.sids$BIR74)*10)/10, scale=2)
pm <- probmap(nc.sids$SID74, nc.sids$BIR74)$pmap
pm.f <- as.ordered(cut(pm, breaks=c(0.0, 0.01, 0.05, 0.1, 0.9, 0.95, 0.99, 1),
include.lowest=TRUE))
cols <- cm.colors(7)
plotpolys(nc.utm.polys, nc.utmbbs, col=cols[codes(pm.f)])
legend(c(-280, -70), c(3700, 3900), legend=paste("prob.", levels(pm.f)),
fill=cols, bty="n")
ft.SID74 <- sqrt(1000)*(sqrt(nc.sids$SID74/nc.sids$BIR74) +
sqrt((nc.sids$SID74+1)/nc.sids$BIR74))
names(ft.SID74) <- rownames(nc.sids)
stem(ft.SID74, scale=2)
plotpolys(nc.utm.polys, nc.utmbbs, border="grey")
plot(sidsorig.nb, utm18.countyseats, add=TRUE, col="blue")
text(utm18.countyseats[card(sidsorig.nb) == 0,],
rownames(nc.sids)[card(sidsorig.nb) == 0], pos=3)
moran.plot(ft.SID74, nb2listw(sidsorig.nb, zero.policy=TRUE),
zero.policy=TRUE)
drop.no.neighs <- !(1:length(sidsorig.nb) %in% which(card(sidsorig.nb) == 0))
sub.sidsorig.nb <- subset(sidsorig.nb, drop.no.neighs)
sub.ft.SID74 <- subset(ft.SID74, drop.no.neighs)
moran.plot(sub.ft.SID74, nb2listw(sub.sidsorig.nb),
labels=attr(sub.sidsorig.nb, "region.id"))
tr.SID74 <- ft.SID74*sqrt(nc.sids$BIR74)
names(tr.SID74) <- names(ft.SID74)
moran.test(tr.SID74, nb2listw(sidsorig.nb, zero.policy=TRUE),
zero.policy=TRUE, alternative="two.sided")
geary.test(tr.SID74, nb2listw(sidsorig.nb, zero.policy=TRUE),
zero.policy=TRUE, alternative="two.sided")
Run the code above in your browser using DataLab