Class: SpatialStats::Local::Geary
- Defined in:
- lib/spatial_stats/local/geary.rb
Overview
Geary's C statistic computes the spatial lag of the difference between variable zi and it's neighbors squared, in the set z. The local version returns a value for each entry.
Instance Attribute Summary
Attributes inherited from Stat
Instance Method Summary collapse
-
#groups ⇒ Array
Computes the groups each observation belongs to.
-
#initialize(scope, field, weights) ⇒ Geary
constructor
A new instance of Geary.
-
#stat ⇒ Array
(also: #c)
Computes Geary's C for every observation in the
scoe
. -
#x ⇒ Array
(also: #z)
Values of the
field
queried from thescope
.
Methods inherited from Stat
#crand, #expectation, #mc, #mc_bv, #quads, #summary, #variance, #x=, #y=, #z_score
Constructor Details
#initialize(scope, field, weights) ⇒ Geary
A new instance of Geary
18 19 20 |
# File 'lib/spatial_stats/local/geary.rb', line 18 def initialize(scope, field, weights) super(scope, field, weights) end |
Instance Method Details
#groups ⇒ Array
Computes the groups each observation belongs to. Potential groups for Geary's C are:
- HH
-
High-High
- LL
-
Low-Low
- N
-
Negative - Group traditionally for HL and LH, but since the difference is squared they are in the same group.
44 45 46 47 48 49 50 51 52 |
# File 'lib/spatial_stats/local/geary.rb', line 44 def groups quads.map do |quad| if %w[HL LH].include?(quad) 'N' else quad end end end |
#stat ⇒ Array Also known as: c
Computes Geary's C for every observation in the scoe
. Geary's C is defined as the square distance between an observation and it's neighbors, factored to their weights.
28 29 30 31 32 |
# File 'lib/spatial_stats/local/geary.rb', line 28 def stat z.each_with_index.map do |_zi, idx| stat_i(idx) end end |
#x ⇒ Array Also known as: z
Values of the field
queried from the scope
58 59 60 61 |
# File 'lib/spatial_stats/local/geary.rb', line 58 def x @x ||= SpatialStats::Queries::Variables.query_field(@scope, @field) .standardize end |