Learn R Programming

SpatialRegimes (version 1.2)

SkaterF: Spatial constrained clusterwise regression by Spatial 'K'luster Analysis by Tree Edge Removal

Description

This function implements a spatial constrained clusterwise regression based on the Skater procedure by Assuncao et al. (2002).

Usage

SkaterF(edges,data,coly,colx,ncuts,crit,method=1,ind_col,lat,long,tau.ch)

Value

A object of skaterF class with:

groups

A vector with length equal the number of nodes. Each position identifies the group of node.

edges.groups

A list of length equal the number of groups with each element is a set of edges

not.prune

A vector identifying the groups with are not candidates to partition.

candidates

A vector identifying the groups with are candidates to partition.

ssto

The total dissimilarity in each step of edge removal.

Arguments

edges

A matrix with 2 colums with each row is an edge.

data

A data.frame with the informations over nodes.

coly

The dependent variable in the c("y_ols") form.

colx

The covariates in the c("x1","x2") form.

ncuts

The number of cuts.

crit

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.

method

1 (default) for OLS, 2 for Quantile regression, 3 for logit

ind_col

Parameter still not used in this version.

lat

Parameter still not used in this version.

long

Parameter still not used in this version.

tau.ch

Chosen quantile (for method = 2).

Author

F. Vidoli

Details

Author really thanks Renato M. Assuncao and Elias T. Krainski for their original code (skater, library spdep).

References

For method = 1: F. Vidoli, G. Pignataro, and R. Benedetti. (2022) "Identification of spatial regimes of the production function of italian hospitals through spatially constrained cluster-wise regression. In: Socio-Economic Planning Sciences, page 101223, doi: https://doi.org/10.1016/j.seps.2022.101223

For method = 2: Vidoli, F., Sacchi A. & Sanchez Carrera E. (2025) "Spatial regimes in heterogeneous territories: The efficiency of local public spending" In: Economic modelling https://doi.org/10.1016/j.econmod.2025.107139

Examples

Run this code

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