Skip to content

Correlation

Maarten Hilferink edited this page Sep 27, 2026 · 14 revisions

Aggregation functions correlation

syntax

  • corr(a, b)
  • corr(a, b, relation)

definition

  • corr(a, b) results in the correlation coefficient of attributes a and b.
  • corr(a, b, relation) results in the correlation coefficient of attributes a and b, grouped by relation. The domain unit of the resulting attribute is the values unit of the relation.

The value type of the resulting data item is float32 or float64.

A row in which a or b is null is left out. Since GeoDMS 20.22.0 it is left out of every sum the coefficient is computed from. Before, it was left out of the count, the sums of a and b and the sum of their products, but not out of the sums of squares: a null in a float argument then made the result null, and a null in an int32 argument pulled the result close to 0 without a warning. Results of such data calculated with an older version have to be recalculated.

applies to

  • attribute a and b with Numeric value type
  • relation with value type of the group CanBeDomainUnit

conditions

  1. The value type of the arguments a and b must match.
  2. The domain of arguments a, b and relation must match.

Since GeoDMS 20.22.0 condition 2 is also checked for corr(a, b) without relation, as it already was with one: a configuration that pairs attributes of two different domain units now stops with an error. Before, b was read element by element along a, beyond its end when its domain was smaller, and the result was meaningless. See also covariance and modus_weighted.

example

1. parameter<float32> corrNrInhabitantsTemp                := 
    corr(float32(City/NrInhabitants), City/avgDailyTemperature); result = -0.89948
2. attribute<float32> corrNrInhabitantsTempRegion (Region) :=
    corr(
       float32(City/NrInhabitants)
      ,City/avgDailyTemperature
      ,City/RegionNr
   );
City/NrInhabitants City/avgDailyTemperature City/Region_rel
550 12 0
525 11 1
300 null 2
500 11 1
200 14 3
175 null null
null 14 3

domain City, nr of rows = 7

corrNrInhabitantsTempRegion
null
null
null
null
null

domain Region, nr of rows = 5

Clone this wiki locally