Dataplot Vol 2 Vol 1

# GROUPED CORRELATION

Name:
GROUPED CORRELATION (LET)
Type:
Let Subcommand
Purpose:
Compute the grouped correlation coefficient between two variables.
Description:
At times, you may data in the form of a bivariate frequency table. For example, something like

X/Y 10-20 20-30 30-40 40-50 50-60
15-25 6 3 0 0 0
25-35 3 16 10 0 0
35-45 0 10 15 7 0
45-55 0 0 7 10 4
55-65 0 0 0 4 5

In Dataplot, you would create the data as

X Y FREQ
20 15 6
20 25 3
20 35 0
20 45 0
20 55 0
30 15 3
30 25 16
30 35 10
30 45 0
30 55 0
40 15 0
40 25 10
40 35 15
40 45 7
40 55 0
50 15 0
50 25 0
50 35 7
50 45 10
50 55 4
60 15 0
60 25 0
60 35 0
60 45 4
60 55 5

The computational formula for the grouped correlation is

$$r = \frac {n \sum_{i=1}^{k}{f_{i} x_{i} y_{i}} - (\sum_{i=1}^{k}{f_{i}x_{i}}) (\sum_{i=1}^{k}{f_{i}y_{i}})} {\sqrt{ (n \sum_{i=1}^{k}{f_{i}x_{i}^2} - (\sum_{i=1}^{k}{f_{i}x_{i}})^2) (n \sum_{i=1}^{k}{f_{i}y_{i}^2} - (\sum_{i=1}^{k}{f_{i}y_{i}})^2) }}$$

where

 k = the number of groups $$f_{i}$$ = the frequency of the i-th group n = the sum of the $$f_{i}$$ (i.e., the total frequency) $$x_{i}$$ = the mid-point of the i-th group for the x variable $$y_{i}$$ = the mid-point of the i-th group for the y variable

If the groups are equally spaced (the distances between x(i) and x(i+1) are equal for all i and the distances between y(i) and y(i+1) are equal for all i), then computational convenience Dataplot will use coded values for the x(i) and the y(i).

If you have groups with zero frequency, you may either omit or include these groups in your data. Dataplot strips out the zero frequency groups automatically before computing the grouped correlation.

Syntax:
LET <par> = GROUPED CORRELATION <y1> <y2> <freq>
<SUBSET/EXCEPT/FOR qualification>
where <y1> is the first response variable;
<y2> is the second response variable;
<freq> is the variable containing the frequencies;
<par> is a parameter where the computed grouped correlation is stored;
and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
LET A = GROUPED CORRELATION Y1 Y2 FREQ
Note:
Dataplot statistics can be used in a number of commands. For details, enter

Default:
None
Synonyms:
None
Related Commands:
 WEIGHTED CORRELATION = Compute a weighted correlation coefficient. CORRELATION = Compute the correlation of two variables. CORRELATION MATRIX = Generate a correlation matrix. RANK CORRELATION = Compute the rank correlation of two variables. KENDALLS TAU = Compute the Kendall tau correlation of two variables.
Reference:
Selby (1974), "CRC Standard Mathematical Tables", 22nd Edition, CRC Press, p. 577.
Applications:
Frequency Data
Implementation Date:
2018/11
Program:

set write decimals 4
.
20    15  6
20    25  3
20    35  0
20    45  0
20    55  0
30    15  3
30    25 16
30    35 10
30    45  0
30    55  0
40    15  0
40    25 10
40    35 15
40    45  7
40    55  0
50    15  0
50    25  0
50    35  7
50    45 10
50    55  4
60    15  0
60    25  0
60    35  0
60    45  4
60    55  5
end of data
.
let cor = grouped correlation x y freq
set parameter expand digits 2
print "Group Correlation: ^cor"

The following output is returned

Group Correlation: 0.80


NIST is an agency of the U.S. Commerce Department.

Date created: 11/08/2018
Last updated: 11/08/2018