SMPSR

Computes statistics for inferences regarding the population mean and total, given data from a simple random sample.

Required Arguments

NROW — The absolute value of NROW is the number of rows of data currently input in Y. (Input)
NROW may be positive, zero, or negative. Negative ‑NROW means delete the NROW rows of data from the analysis.

Y — Vector of length NROW containing the sample data. (Input)

NPOP — Size of the (full) population. (Input)

STAT — Vector of length 11 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

Within‑sample variance estimate.

4

Variance estimate of the mean estimate.

5

Variance estimate of the total estimate.

6

Lower confidence limit for the mean.

7

Upper confidence limit for the mean.

8

Lower confidence limit for the total.

9

Upper confidence limit for the total.

10

The sample size.

11

The number of missing values.

Optional Arguments

IDO — Processing option. (Input)
Default: IDO = 0.

 

IDO

Action

0

This is the only invocation of SMPSR for this data set, and all the data are input at once.

1

This is the first invocation, and additional calls to SMPSR will be made. Initialization and updating for the data in Y are performed.

2

This is an intermediate invocation of SMPSR, 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.

IOPT — Subpopulation option. (Input)
If IOPT = 0, no subpopulation is assumed. If IOPT = 1, the input data come from a subpopulation (“domain of study”) of unknown size.
Default: IOPT = 0.

NSAMPO — Size of the sample from the full population, if a subpopulation is sampled (that is, if IOPT = 1). (Input)
Default: NSAMPO = ABS (NROW).

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 SMPSR (NROW, Y, NPOP, STAT [])

Specific: The specific interface names are S_SMPSR and D_SMPSR.

FORTRAN 77 Interface

Single: CALL SMPSR (IDO, NROW, Y, NPOP, IOPT, NSAMPO, CONPER, STAT)

Double: The double precision name is DSMPSR.

Description

Routine SMPSR computes point and interval estimates for the population mean and total from a simple random sample of one variable. The routine uses the standard methods discussed in Chapter 2 of Cochran (1977). The sample mean is accumulated in STAT(1) and the corrected sum of squares is accumulated in STAT(3). In the postprocessing phase, STAT(3) is divided by the sample size minus one, and then the other quantities in STAT are computed. The parameters IDO and NROW allow either all or part of the data to be brought in at one time.

By use of IOPT and NSAMPO, SMPSR can also be used to analyze data from a subpopulation or “domain of study”. (See Cochran 1977, pages 3438.) In the case of a subpopulation, only the estimates relating to the subpopulation total differ from the corresponding estimates when no subpopulation is assumed. Of course, if a subpopulation is of known size, it should be considered the full population.

Examples

Example 1

This example uses artificial data to illustrate a simple use of SMPSR to compute point and interval estimates of the population mean and total. The sample size is 15, from a population of size 150.

 

USE SMPSR_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER NROW

PARAMETER (NROW=15)

!

INTEGER NOUT, NPOP, NSAMPO

REAL STAT(11), Y(NROW)

!

DATA Y/21., 14., 17., 22., 19., 21., 20., 15., 24., 28., 20., &

17., 16., 22., 19./

!

NPOP = 150

! All data are input at once.

! No subpopulation is assumed.

CALL SMPSR (NROW, Y, NPOP, STAT)

! Print results

CALL UMACH (2, NOUT)

WRITE (NOUT,99999) STAT

99999 FORMAT (' Mean estimate = ', F8.3, ' Total estimate = ', &

F8.1, /, ' Within-sample variance estimate = ', F8.3, /, &

' VHAT of mean = ', F8.5, ' VHAT of total = ', &

F8.1, /, ' Confidence limits for mean ', F8.3, &

',', F8.3, /, ' Confidence limits for total ', F8.1, &

',', F8.1, /, ' Sample size = ', F8.1, ' Number ', &

'missing = ', F8.0)

END

Output

 

Mean estimate = 19.667 Total estimate = 2950.0

Within-sample variance estimate = 13.238

VHAT of mean = 0.79429 VHAT of total = 17871.4

Confidence limits for mean 17.755, 21.578

Confidence limits for total 2663.3, 3236.7

Sample size = 15.0 Number missing = 0.

Example 2

This example is a problem of estimation in a subpopulation described on page 37 of Cochran (1977). The example illustrates how the IDO and NROW parameters can be used to allow input other than the actual data. Cochran gives only the sample total and uncorrected sum of squares, so these values are transformed to the mean and corrected sum of squares prior to input as STAT(1) and STAT(3).

 

USE SMPSR_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER IDO, IOPT, NOUT, NPOP, NROW, NSAMPO

REAL SQRT, STAT(11), Y(1)

INTRINSIC SQRT

!

NPOP = 2422

! There are 180 items in the complete

! sample, but only a subpopulation is

! of interest.

IOPT = 1

NSAMPO = 180

! For this example, STAT is

! initialized as if the data

! have been already processed and only

! the postprocessing computations are

! to be done. There are 152 items of

! interest in the sample. The sample

! total is 343.5 and the uncorrected

! sum of squares is 1491.38.

! STAT(1) is initialized to the sample

! mean by dividing the total by the

! sample size, and STAT(3) is

! initialized to the corrected sum of

! squares.

STAT(1) = 343.5/152.0

STAT(3) = 1491.38 - 152.0*STAT(1)**2

STAT(10) = 152.0

STAT(11) = 0.0

IDO = 3

NROW = 0

CALL SMPSR (NROW, Y, NPOP, STAT, IDO=IDO, IOPT=IOPT, NSAMPO=NSAMPO)

! Print results

CALL UMACH (2, NOUT)

WRITE (NOUT,99999) STAT(2), SQRT(STAT(5))

99999 FORMAT (' Total estimate = ', F8.1, /, ' Standard ', &

'deviation of the estimate = ', F8.1)

END

Output

 

Total estimate = 4622.0

Standard deviation of the estimate = 375.3