Skip to contents

Computes the local regression coefficient of z on y using all edges in each vertex's neighborhood. This is the asymmetric analog of local correlation, satisfying beta_loc(z; y) = lcor(y, z) * sd_loc(z) / sd_loc(y).

Usage

lslope.neighborhood(
  adj.list,
  weight.list,
  y,
  z,
  weight.type = c("derivative", "unit"),
  y.diff.type = c("difference", "logratio"),
  z.diff.type = c("difference", "logratio"),
  epsilon = 0
)

Arguments

adj.list

List of integer vectors containing 1-based vertex indices.

weight.list

List of numeric vectors containing edge weights.

y

Numeric vector of directing function values.

z

Numeric vector of response function values.

weight.type

Character scalar specifying weighting scheme:

"derivative"

Geometric weights (w_e = 1/length^2). Default.

"unit"

Equal weights (w_e = 1).

y.diff.type

Character scalar specifying edge difference type for y.

z.diff.type

Character scalar specifying edge difference type for z.

epsilon

Numeric scalar for pseudocount in log-ratios.

Value

A list with class "lslope_neighborhood_result" containing:

vertex.coefficients

Numeric vector of local regression coefficients.

sd.y

Numeric vector of local standard deviation of y.

sd.z

Numeric vector of local standard deviation of z.

lcor

Numeric vector of local correlation (for reference).

mean.coefficient

Mean coefficient across all vertices.

median.coefficient

Median coefficient across all vertices.

Details

The neighborhood local regression coefficient at vertex v is: $$\beta_{loc}(z; y, w)(v) = \frac{\sum w_e \Delta_e y \cdot \Delta_e z}{\sum w_e (\Delta_e y)^2}$$

Unlike the gradient-restricted slope which uses only the single gradient edge, this measure uses all edges in the neighborhood, providing a more robust but less direction-specific measure of local association.

The relationship beta = rho * sigma_z / sigma_y holds locally: the regression coefficient equals the correlation times the ratio of local standard deviations.

See also

lslope for gradient-restricted slope, lcor for symmetric local correlation

Examples

if (FALSE) { # \dontrun{
result <- lslope.neighborhood(adj.list, weight.list, y, z,
                              weight.type = "derivative",
                              y.diff.type = "difference",
                              z.diff.type = "logratio")

## Verify relationship with local correlation
beta.from.lcor <- result$lcor * result$sd.z / result$sd.y
all.equal(result$vertex.coefficients, beta.from.lcor)
} # }