OWFRQ
Tallies observations into a one-way frequency table.
Required Arguments
X — Vector of length NOBS containing the data. (Input)
K — Number of intervals. (Input)
TABLE — Vector of length K containing the counts. (Output)
Optional Arguments
NOBS Number of observations. (Input)
Default: NOBS = size (X,1).
IOPT — Tallying option. (Input)
Default: IOPT = 0.
IOPT
Action
0
Intervals of equal length, determined from the data, are used. Let XMIN and XMAX be the minimum and maximum values in X, respectively. Then, TABLE(1) is the tally of observations less than or equal to XMIN + (XMAX  XMIN)/K, TABLE(2) is the tally of observations greater than XMIN + (XMAX  XMIN)/K and less than or equal to XMIN + 2 * (XMAX  XMIN)/K, and so on. TABLE(K) is the tally of observations greater than XMAX  (XMAX  XMIN)/K.
1
Intervals of equal length are used just as in the case of IOPT = 0, except the upper and lower bounds are taken as the user supplied variables XLO and XHI, instead of the actual minimum and maximum in the data. Therefore, the first and the last intervals are semi-infinite in length. K must be greater than 2.
2
K‑1 cutpoints are input in DIV. The tally in TABLE(1) is the number of observations less than or equal to DIV(1). For I greater than 1 and less than K, the tally in TABLE(I) is the number of observations greater than DIV(I  1) and less than or equal to DIV(I). The tally in TABLE(K) is the number of observations greater than DIV(K  1). K must be greater than 1.
3
Class marks are input in DIV and a constant class half-width is input in CLHW. The total of the elements in TABLE may be less than NOBS. The tally in TABLE(I) is the number of observations between DIV(I CLHW and DIV(I) + CLHW.
XLO — If IOPT = 1, XLO is the lower bound at which to begin forming the class intervals. (Input)
XLO is used only if IOPT = 1.
XHI — If IOPT = 1, XHI is the upper bound to use in forming the class intervals. (Input)
XHI is used only if IOPT = 1.
CLHW — If IOPT = 3, CLHW is the half-width of the class intervals. (Input)
CLHW is not used if IOPT is not equal to 3.
DIV — Vector of varying length and contents depending on IOPT. (Input if IOPT= 2 or 3; output if IOPT = 0 or 1.)
The contents of DIV are in ascending order.
IOPT
Contents
0
DIV is of length K containing interval midpoints. (DIV is output.)
1
DIV is of length K containing interval midpoints. Since the first and last intervals are semi-infinite in length, DIV(1) contains XLO minus half the interval length, and DIV(K) contains XHI plus half the interval length. (DIV is output.)
2
DIV is a vector of length K  1 containing cutpoints. (DIV is input.)
3
DIV is of length K containing classmarks. (DIV is input.)
FORTRAN 90 Interface
Generic: CALL OWFRQ (X, K, TABLE [])
Specific: The specific interface names are S_OWFRQ and D_OWFRQ.
FORTRAN 77 Interface
Single: CALL OWFRQ (NOBS, X, K, IOPT, XLO, XHI, CLHW, DIV, TABLE)
Double: The double precision name is DOWFRQ.
Description
The routine OWFRQ groups numerical data into categories, which can be defined in any of four different ways as chosen by IOPT. If IOPT = 0, K intervals of equal length are formed between the minimum and maximum values in the data, and then the data are tallied in these intervals. The midpoints of the intervals are output in DIV.
If IOPT = 1, K  2 intervals of equal length are formed between XLO and XHI, and then the data are tallied in these intervals. In this option, there is one group that consists of data less than XLO and one group of data greater than XHI. This option is similar to IOPT = 0, except with this option, the midpoints of the classes are under control of the user. The midpoints of the intervals are output in DIV. The first and last values of DIV, respectively, contain XLO minus half the class width and XHI plus half the class width.
For IOPT = 2 or 3, the intervals need not be equally spaced. If IOPT = 2, the intervals need not be equal in length. In this case, the intervals are defined by their boundaries, the “cutpoints”, which are input in DIV. The number of cutpoints is one less than the number of intervals. The first cutpoint defines the upper bound of the first interval, and the last cutpoint defines the lower bound of the last interval.
If IOPT= 3, the intervals are all of length twice CLHW, and they are centered on the class marks input in DIV. This option can be used to exclude portions of the data.
The examples use all of these options with the same data set.
Examples
Example 1
The data for these examples are from Hinkley (1977) and Velleman and Hoaglin (1981). They are the measurements (in inches) of precipitation in Minneapolis/St. Paul during the month of March for 30 consecutive years. In the first example, we set IOPT = 0. This option may be appropriate if we do not know the range of the data. Notice that the midpoints of the class intervals, output in DIV, are not “pretty” numbers.
 
USE OWFRQ_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER K, NOBS
PARAMETER (K=10, NOBS=30)
!
INTEGER NOUT
REAL DIV(K), TABLE(K), X(NOBS)
!
DATA X/0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, &
2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, &
0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.90, &
2.05/
!
CALL UMACH (2, NOUT)
!
CALL OWFRQ (X, K, TABLE, DIV=DIV)
WRITE (NOUT,99999) DIV, TABLE
99999 FORMAT (' Midpoints: ', 10F5.2, /, ' Counts: ', 10F5.0)
END
Output
 
Midpoints: 0.54 0.98 1.43 1.87 2.31 2.76 3.20 3.64 4.09 4.53
Counts: 4. 8. 5. 5. 3. 1. 3. 0. 0. 1.
Example 2
In this example, we set IOPT = 1 and choose XLO and XHI so that the intervals will be 0.0 to 0.5, 0.5 to 1.0, and so on. This means that the midpoints of the class intervals, output in DIV, will be 0.25, 0.75, and so on.
 
USE OWFRQ_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER K, NOBS
PARAMETER (K=10, NOBS=30)
!
INTEGER IOPT, NOUT
REAL DIV(K), TABLE(K), X(NOBS), XHI, XLO
!
DATA X/0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, &
2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, &
0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.90, &
2.05/
!
CALL UMACH (2, NOUT)
IOPT = 1
XLO = 0.5
XHI = 4.5
!
CALL OWFRQ (X, K, TABLE, iopt=iopt, xlo=xlo, xhi=xhi, div=div)
WRITE (NOUT,99999) DIV, TABLE
99999 FORMAT (' Midpoints: ', 10F5.2, /, ' Counts: ', 10F5.0)
END
Output
 
Midpoints: 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75
Counts: 2. 7. 6. 6. 4. 2. 2. 0. 0. 1.
Example 3
In this example, we input class boundaries in DIV. We choose the same intervals as in the example above: 0.0 to 0.5, 0.5 to 1.0, and so on. DIV begins with the first cutpoint between classes.
 
USE OWFRQ_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER K, NOBS
PARAMETER (K=10, NOBS=30)
!
INTEGER IOPT, NOUT
REAL DIV(K-1), TABLE(K), X(NOBS)
!
DATA X/0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, &
2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, &
0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.90, &
2.05/
DATA DIV/0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5/
!
CALL UMACH (2, NOUT)
IOPT = 2
!
CALL OWFRQ (X, K, TABLE, IOPT=IOPT, DIV=DIV)
WRITE (NOUT,99999) DIV, TABLE
99999 FORMAT (' Cutpoints: ', 9F5.1, /, ' Counts: ', 10F5.0)
END
Output
 
Cutpoints: 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5
Counts: 2. 7. 6. 6. 4. 2. 2. 0. 0. 1.
Example 4
In this example, we set IOPT = 3, and set the values in DIV and CLHW so that the intervals will be the same as in the previous two examples.
 
USE OWFRQ_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER K, NOBS
PARAMETER (K=10, NOBS=30)
!
INTEGER IOPT, NOUT
REAL CLHW, DIV(K), TABLE(K), X(NOBS)
!
DATA X/0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, &
2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, &
0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.90,&
2.05/
DATA DIV/0.25, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25,&
4.75/
!
CALL UMACH (2, NOUT)
IOPT = 3
CLHW = 0.25
!
CALL OWFRQ (X, K, TABLE, IOPT=IOPT, CLHW=CLHW, DIV=DIV)
WRITE (NOUT,99999) DIV, TABLE
99999 FORMAT (' Class marks: ', 10F5.2, /, ' Counts: ', 10F5.0)
END
Output
 
Class marks: 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75
Counts: 2. 7. 6. 6. 4. 2. 2. 0. 0. 1.
Published date: 03/19/2020
Last modified date: 03/19/2020