data(SimData)
coords = cbind(SimData$long, SimData$lat)
#######################
neighbours = tri2nb(coords, row.names = NULL)
bh.nb <- neighbours
lcosts <- nbcosts(bh.nb, SimData)
nb <- nb2listw(bh.nb, lcosts, style="B")
mst.bh <- mstree(nb,5)
edges1 = mst.bh[,1:2]
#######################
ncuts1 = 4
crit1 = 10
coly1 = c("y_ols")
colx1 = c("A","L","K")
# OLS
sk = SkaterF(edges = edges1,
data= SimData,
coly = coly1,
colx= colx1,
ncuts=ncuts1,
crit=crit1,
method=1)
SimData$regimes = sk$groups
# plot(lat~long,SimData,col=regimes,pch=16)
## quantile 0.8
# sk2 = SkaterF(edges = edges1,
# data= SimData,
# coly = coly1,
# colx= colx1,
# ncuts=ncuts1,
# crit=crit1,
# method=2,tau.ch=0.8)
#
# SimData$regimes_q = sk2$groups
# plot(lat~long,SimData,col=regimes_q,pch=16)
Run the code above in your browser using DataLab