GRPES
Computes basic statistics from grouped data.
Required Arguments
TABLE — Vector of length NGROUP containing the frequencies within the groups. (Input)
The entries in TABLE are interpreted as counts. They must be nonnegative.
CLOW — The center (class mark) of the lowest class interval. (Input)
CWIDTH — The class width. (Input)
CWIDTH must be positive.
STAT — Vector of length 13 containing the statistics. (Output)
I
STAT(I)
1
The sum of the frequencies in TABLE.
2
Mean (arithmetic mean, first moment).
3
Sample standard deviation. (Uses STAT(1)  1 as divisor).
4
Second moment about the mean, uncorrected for grouping. (Uses STAT(1) as divisor.)
5
Second moment about the mean, adjusted using Sheppard’s correction.
6
Third moment about the mean, uncorrected for grouping.
7
Third moment about the mean, adjusted using Sheppard’s correction.
8
Fourth moment about the mean, uncorrected for grouping.
9
Fourth moment about the mean, adjusted using Sheppard’s correction.
10
Median.
11
Geometric mean; defined only if CLOW  CWIDTH/2 is nonnegative.
12
Harmonic mean; defined only if CLOW   CWIDTH/2 is nonnegative.
13
Mode; defined only if one element of TABLE is strictly greater than all other elements of TABLE.
Optional Arguments
NGROUP — Number of groups. (Input)
Default: NGROUP = size (TABLE,1).
IPRINT — Printing option. (Input)
If IPRINT = 0, no printing is performed; and if IPRINT = 1, the statistics in STAT are printed.
Default: IPRINT = 0.
FORTRAN 90 Interface
Generic: CALL GRPES (TABLE, CLOW, CWIDTH, STAT [])
Specific: The specific interface names are S_GRPES and D_GRPES.
FORTRAN 77 Interface
Single: CALL GRPES (NGROUP, TABLE, CLOW, CWIDTH, IPRINT, STAT)
Double: The double precision name is DGRPES.
Description
The routine GRPES computes various statistics using data from equally spaced groups. The second, third, and fourth moments are computed both with and without Sheppard’s corrections. These corrections for grouped data are most useful for distributions whose densities tail off smoothly (such as the normal distribution). Kendall, Stuart, and Ord (1987, Chapters 2 and 3) discuss these corrections.
The moments are computed using the sum of the frequencies as the divisor. The standard deviation (STAT(3)), on the other hand, is computed using as the divisor the sum of the frequencies minus one.
If any of the class marks are negative, the geometric and harmonic means are not computed, and NaN (not a number) is stored as the value of STAT(11). Likewise, if the mode does not exist (no group has a frequency greater than that of all other groups), NaN is stored as the value of STAT(13).
Examples
Example 1
This example is taken from Conover and Iman (1983, page 119). The objective is to compute some basic statistics relating to test scores, using the following data:
Score
Frequency
91  100
7
81  90
13
71  80
11
61  70
5
60
4
 
USE GRPES_INT
 
IMPLICIT NONE
INTEGER IPRINT, NGROUP
REAL CLOW, CWIDTH, STAT(13), TABLE(5)
!
NGROUP = 5
CLOW = 55.5
CWIDTH = 10.0
TABLE(1) = 4.0
TABLE(2) = 5.0
TABLE(3) = 11.0
TABLE(4) = 13.0
TABLE(5) = 7.0
IPRINT = 1
CALL GRPES (TABLE, CLOW, CWIDTH, STAT, IPRINT=IPRINT)
END
Output
 
Statistics from GRPES
Sum freqs. 40.0
Mean 79.0
Std. dev. 12.1
2nd moment 142.8
2nd, adj. 134.4
3rd moment -741.8
3rd, adj. -2716.8
4th moment 48242.3
4th, adj. 47929.0
Median 80.5
Geometric 78.0
Harmonic 77.0
Mode 85.5
Example 2
In this example, there are negative values of some class marks, and there is no modal class.
Class Marks
Frequency
 2.0
2
 1.0
5
0.0
7
1.0
7
2.0
2
 
USE GRPES_INT
 
IMPLICIT NONE
INTEGER NGROUP, IPRINT
REAL TABLE(5), CLOW, CWIDTH, STAT(13)
!
NGROUP = 5
CLOW = -2.0
CWIDTH = 1.0
TABLE(1) = 2.0
TABLE(2) = 5.0
TABLE(3) = 7.0
TABLE(4) = 7.0
TABLE(5) = 2.0
IPRINT = 1
CALL GRPES (TABLE, CLOW, CWIDTH, STAT, IPRINT=IPRINT)
END
Output
 
Statistics from GRPES
Sum freqs. 23.0000
Mean 0.0870
Std. dev. 1.1246
2nd moment 1.2098
2nd, adj. 1.1265
3rd moment -0.2293
3rd, adj. -0.2510
4th moment 3.3292
4th, adj. 2.7960
Median 0.1429
 
The mode is not defined, since no class has higher
frequency than all others.
The geometric and harmonic means are not defined, since
the lower bound is negative.
Published date: 03/19/2020
Last modified date: 03/19/2020