This function implements a spatial constrained clusterwise regression based on the Skater procedure by Assuncao et al. (2002).
SkaterF(edges,data,coly,colx,ncuts,crit,method=1,ind_col,lat,long,tau.ch)
A object of skaterF class with:
A vector with length equal the number of nodes. Each position identifies the group of node.
A list of length equal the number of groups with each element is a set of edges
A vector identifying the groups with are not candidates to partition.
A vector identifying the groups with are candidates to partition.
The total dissimilarity in each step of edge removal.
A matrix with 2 colums with each row is an edge.
A data.frame with the informations over nodes.
The dependent variable in the c("y_ols") form.
The covariates in the c("x1","x2") form.
The number of cuts.
A scalar or two dimensional vector with with criteria for groups. Examples: limits of group size or limits of population size. If scalar, is the minimum criteria for groups.
1 (default) for OLS, 2 for Quantile regression
Parameter still not used in this version.
Parameter still not used in this version.
Parameter still not used in this version.
Chosen quantile (for method = 2).
F. Vidoli
Author really thanks Renato M. Assuncao and Elias T. Krainski for their original code (skater, library spdep).
F. Vidoli, G. Pignataro and R. Benedetti "Identification of spatial regimes of the production function of Italian hospitals through spatially constrained cluster-wise regression", Socio-Economic Planning Sciences (in press) https://doi.org/10.1016/j.seps.2022.101223
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