SMPSS
Computes statistics for inferences regarding the population mean and total, given data from a stratified random sample.
Required Arguments
NROWS — Vector of length NSTRAT in which ∣NROWS(I)∣ is the number of items from the I‑th stratum currently input in Y. (Input)
Each element of NROWS may be positive, zero, or negative. A negative value for NROWS(I) means delete the ‑NROWS(I) elements of the I‑th stratum in Y from the analysis.
Y — Vector containing the stratified random sample. (Input)
The observations within any one stratum must appear contiguously in Y. The first ∣NROWS(1)∣ elements of Y are from the first stratum, and so on.
NPOPS — Vector of length NSTRAT containing the sizes of the population in the strata. (Input)
The entries must be ordered in correspondence with the ordering of strata in the other vectors. If the population strata sizes are not known, estimates must be entered in their place.
YBARS — Vector of length NSTRAT containing the strata means. (Output, if IDO = 0 or 1; Input/Output, if IDO = 2 or 3.)
YVARS — Vector of length NSTRAT containing the within‑strata variances. (Output, if IDO = 0 or 1; Input/Output, if IDO = 2 or 3.)
NSAMPS — Vector of length NSTRAT containing the number of nonmissing observations from each stratum. (Output, if IDO = 0 or 1; Input/Output, if IDO = 2 or 3.)
STAT — Vector of length 13 containing the resulting statistics. (Output, if IDO = 0 or 1; input/output, if IDO = 2 or 3.)
These are:
I | STAT(I) |
1 | Estimate of the mean. |
2 | Estimate of the total. |
3 | Variance estimate of the mean estimate. |
4 | Variance estimate of the total estimate. |
5 | Lower confidence limit for the mean. |
6 | Upper confidence limit for the mean. |
7 | Lower confidence limit for the total. |
8 | Upper confidence limit for the total. |
9 | Estimate of the coefficient of variation of the mean and total estimates. |
10 | Number of degrees of freedom associated with the variance estimates of the mean and total estimates. When IVOPT = 1, STAT(10) contains an effective number of degrees of freedom determined according to the Satterthwaite approximation. |
11 | Variance estimate of the mean estimate assuming that sampling was simple random instead of stratified random. |
12 | Pooled estimate of the common variance, when IVOPT = 0. If IVOPT = 1, STAT(12) is not defined. |
13 | The number of missing values. |
Optional Arguments
IDO — Processing option. (Input)
Default: IDO = 0.
IDO | Action |
---|
0 | This is the only invocation of SMPSS for this data set, and all the data are input at once. |
1 | This is the first invocation, and additional calls to SMPSS will be made. Initialization and updating for the data in Y are performed. |
2 | This is an intermediate invocation of SMPSS, and updating for the data in Y is performed. |
3 | This is the final invocation of this routine. Updating for the data in Y and wrap‑up computations are performed. |
NSTRAT — Number of strata into which the population is divided. (Input)
In the vectors of length NSTRAT, the elements are all ordered in the same way. That is, the first stratum is always the first, the second always the second, and so on.
Default: NSTRAT = size (NROWS,1).
IVOPT — Within‑stratum variance assumption indicator. (Input)
If IVOPT = 0, the true within‑stratum variance is assumed constant, and a pooled estimate of that variance is returned in STAT(12). If IVOPT = 1, separate within‑strata variance estimates are assumed.
Default: IVOPT = 0.
CONPER — Confidence level for two‑sided interval estimate, in percent. (Input)
A CONPER percent confidence interval is computed; hence, CONPER must be greater than or equal to 0.0 and less than 100.0. CONPER is often 90.0, 95.0, or 99.0. For a one‑sided confidence interval with confidence level ONECL, set CONPER = 100.0 ‑ 2.0 * (100.0 ‑ ONECL).
Default: CONPER = 95.0.
FORTRAN 90 Interface
Generic: CALL SMPSS (NROWS, Y, NPOPS, YBARS, YVARS, NSAMPS, STAT[, …])
Specific: The specific interface names are S_SMPSS and D_SMPSS.
FORTRAN 77 Interface
Single: CALL SMPSS (IDO, NSTRAT, NROWS, Y, NPOPS, IVOPT, CONPER, YBARS, YVARS, NSAMPS, STAT)
Double: The double precision name is DSMPSS.
Description
Routine SMPSS computes point and interval estimates for the population mean and total from a stratified random sample of one variable. The routine uses the standard methods discussed in Chapters 5 and 5A of Cochran (1977). The sample means for the individual strata are accumulated in YBARS, and the corrected sums of squares are accumulated in YVARS. In the postprocessing phase, the quantities in STAT are computed using the strata statistics in YBARS, YVARS, and NSAMPS. The parameters IDO and NROWS allow either all or part of the data to be brought in at one time.
Comments
Information Error
Type | Code | Description |
---|
4 | 1 | The population size for each stratum is equal to one. |
Example
In this example, we use a stratified sample from the data in Table 5.1 of Cochran (1977): the 1930 population (in 1000’s) of 64 cities in the United States. The 64 cities are the “population”, and our objective is to estimate the mean and total number of inhabitants in these 64 cities. There are two strata: the largest 16 cities and the remaining cities. We use stratified sampling with equal sample sizes. To choose the random sample, we use routine
RNSRI (see
Chapter 18, “Random Number Generation”), as follows:
USE RNSET_INT
USE RNSRI_INT
IMPLICIT NONE
INTEGER ISEED, NSAMP, NPOP, INDEX(12)
NSAMP = 12
NPOP = 16
ISEED = 123457
CALL RNSET(ISEED)
CALL RNSRI(NPOP, INDEX)
WRITE(*, *) INDEX
NPOP = 48
CALL RNSRI(NPOP, INDEX)
WRITE(*, *) INDEX
END
This yields the population indices {2, 3, 4, 6, 8, 10, 11, 12, 13, 14, 15, 16} for the first stratum and {4, 8, 10, 11, 13, 16, 29, 30, 36, 37, 45, 46} for the second stratum. The corresponding values from Table 5.1 are encoded in the program below.
USE SMPSS_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER NSTRAT
PARAMETER (NSTRAT=2)
!
INTEGER I, IVOPT, NOUT, NPOPS(NSTRAT), NROWS(NSTRAT), &
NSAMPS(NSTRAT)
REAL STAT(13), Y(24), YBARS(NSTRAT), YVARS(NSTRAT)
!
DATA Y/822., 781., 805., 1238., 634., 487., 442., 451., 459., &
464., 400., 366., 302., 291., 272., 284., 270., 260., 139., &
170., 154., 140., 163., 116./
!
NPOPS(1) = 16
NPOPS(2) = 48
IVOPT = 1
! All data are input at once.
NROWS(1) = 12
NROWS(2) = 12
CALL SMPSS (NROWS, Y, NPOPS, YBARS, YVARS, NSAMPS, STAT, IVOPT=IVOPT)
! Print results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) (STAT(I),I=1,11), STAT(13)
99999 FORMAT (' Mean estimate = ', F8.3, ' Total estimate = ', &
F9.1, /, ' Vhat of mean = ', F8.3, ' Vhat of total ' &
, ' = ', F9.1, /, ' Confidence limits for mean ', F8.3, &
',', F8.3, /, ' Confidence limits for total ', F8.1, &
',', F8.1, /, ' C. V. = ', F8.1, ' Degrees ' &
, 'of freedom = ', F8.1, /, ' SRS var. estimate = ', &
F8.3, ' Number missing = ', F8.0)
END
Output
Mean estimate = 313.167 Total estimate = 20042.7
Vhat of mean = 264.703 Vhat of total = 1084224.6
Confidence limits for mean 279.180, 347.153
Confidence limits for total 17867.5, 22217.8
C. V. = 5.2 Degrees of freedom = 19.6
SRS var. estimate = 1288.075 Number missing = 0.