Module: SpatialStats::Utils::Lag

Defined in:
lib/spatial_stats/utils/lag.rb

Overview

Lag includes methdos for computing spatially lagged variables under different contexts.

Class Method Summary collapse

Class Method Details

.neighbor_average(matrix, variables) ⇒ Array

Dot product of the row_standardized input matrix by the input vector, variables.

Parameters:

  • matrix (WeightsMatrix)

    holding target weights.

  • variables (Array)

    vector multiplying the matrix

Returns:

  • (Array)

    resultant vector



18
19
20
21
# File 'lib/spatial_stats/utils/lag.rb', line 18

def self.neighbor_average(matrix, variables)
  matrix = matrix.standardize
  neighbor_sum(matrix, variables)
end

.neighbor_sum(matrix, variables) ⇒ Array

Dot product of the input matrix by the input vector, variables.

Parameters:

  • matrix (WeightsMatrix)

    holding target weights.

  • variables (Array)

    vector multiplying the matrix

Returns:

  • (Array)

    resultant vector



30
31
32
# File 'lib/spatial_stats/utils/lag.rb', line 30

def self.neighbor_sum(matrix, variables)
  matrix.sparse.mulvec(variables)
end

.window_average(matrix, variables) ⇒ Array

Dot product of the input windowed, row standardized matrix by the input vector, variables.

Parameters:

  • matrix (WeightsMatrix)

    holding target weights.

  • variables (Array)

    vector multiplying the matrix

Returns:

  • (Array)

    resultant vector



42
43
44
45
# File 'lib/spatial_stats/utils/lag.rb', line 42

def self.window_average(matrix, variables)
  matrix = matrix.window.standardize
  window_sum(matrix, variables)
end

.window_sum(matrix, variables) ⇒ Array

Dot product of the input windowed matrix by the input vector, variables.

Parameters:

  • matrix (WeightsMatrix)

    holding target weights.

  • variables (Array)

    vector multiplying the matrix

Returns:

  • (Array)

    resultant vector



55
56
57
58
# File 'lib/spatial_stats/utils/lag.rb', line 55

def self.window_sum(matrix, variables)
  matrix = matrix.window
  matrix.sparse.mulvec(variables)
end