Package {coupling}


Title: Analysis of Coupling Coordination Degree
Version: 0.1
Description: Implements coupling coordination degree (CCD) models and supports metacoupling analysis following Tang et al. (2021) <doi:10.1016/j.scs.2021.103405>.
License: GPL-3
Encoding: UTF-8
URL: https://stscl.github.io/coupling/, https://github.com/stscl/coupling
BugReports: https://github.com/stscl/coupling/issues
Depends: R (≥ 4.1.0)
LinkingTo: Rcpp, RcppThread
Suggests: gdverse, infoxtr, knitr, pc, Rcpp, RcppThread, rmarkdown, sdsfun, spEDM
VignetteBuilder: knitr
Config/roxygen2/markdown: TRUE
Config/roxygen2/version: 8.0.0
NeedsCompilation: yes
Packaged: 2026-05-11 12:15:48 UTC; dell
Author: Wenbo Lyu ORCID iD [aut, cre, cph]
Maintainer: Wenbo Lyu <lyu.geosocial@gmail.com>
Repository: CRAN
Date/Publication: 2026-05-15 20:00:07 UTC

Coupling Coordination Degree (CCD)

Description

Coupling Coordination Degree (CCD)

Usage

ccd(data, weight = NULL, method = c("standard", "wang", "fan"), threads = 1)

Arguments

data

A numeric matrix or data.frame. Rows are observations, columns are indicators.

weight

Numeric vector of indicator weights. Must have length equal to ncol(data). If NULL, equal weights are used.

method

Coupling model. One of "standard", "wang", or "fan".

threads

Number of threads used in computation.

Details

Full model definitions and formulas are available at: https://github.com/stscl/coupling/discussions/3

Value

A data.frame with:

Note

Input values should be normalized to ⁠[0, 1]⁠.

Examples

set.seed(42)
mat = matrix(runif(20), nrow = 5)
coupling::ccd(mat)


Metacoupling Analysis

Description

Metacoupling Analysis

Usage

metacoupling(
  data,
  swm_peri = NULL,
  swm_tele = NULL,
  weight = NULL,
  method = c("standard", "wang", "fan"),
  threads = 1
)

Arguments

data

A numeric matrix or data.frame. Rows are observations, columns are indicators.

swm_peri

A numeric matrix representing the peri (local) spatial weight matrix. Must be square with dimension equal to nrow(data). If NULL, a zero matrix is used.

swm_tele

A numeric matrix representing the tele (long-distance) spatial weight matrix. Must be square with dimension equal to nrow(data). If NULL, a zero matrix is used.

weight

Numeric vector of indicator weights. Must have length equal to ncol(data). If NULL, equal weights are used.

method

Coupling model. One of "standard", "wang", or "fan".

threads

Number of threads used in computation.

Details

Full model definitions and formulas are available at: https://github.com/stscl/coupling/discussions/8

Value

A data.frame with:

Note

Input values should be normalized to ⁠[0, 1]⁠. Spatial weight matrices are typically symmetric.

Examples

set.seed(42)
mat = matrix(runif(20), nrow = 5)
swm1 = apply(matrix(runif(25), 5, 5), 1, \(.x) .x / sum(.x))
swm2 = apply(matrix(runif(25), 5, 5), 1, \(.x) .x / sum(.x))
coupling::metacoupling(mat, swm1, swm2)