# tolIntNormN: Sample Size for a Specified Half-Width of a Tolerance...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

### Description

Compute the sample size necessary to achieve a specified half-width of a tolerance interval for a normal distribution, given the estimated standard deviation, coverage, and confidence level.

### Usage

 1 2 3  tolIntNormN(half.width, sigma.hat = 1, coverage = 0.95, cov.type = "content", conf.level = 0.95, method = "wald.wolfowitz", round.up = TRUE, n.max = 5000, tol = 1e-07, maxiter = 1000) 

### Arguments

 half.width numeric vector of (positive) half-widths. Missing (NA), undefined (NaN), and infinite (Inf, -Inf) values are not allowed. sigma.hat numeric vector specifying the value(s) of the estimated standard deviation(s). The default value is sigma.hat=1. coverage numeric vector of values between 0 and 1 indicating the desired coverage of the tolerance interval. The default value is coverage=0.95. cov.type character string specifying the coverage type for the tolerance interval. The possible values are "content" (β-content; the default), and "expectation" (β-expectation). conf.level numeric vector of values between 0 and 1 indicating the confidence level of the prediction interval. The default value is conf.level=0.95. method character string specifying the method for constructing the tolerance interval. The possible values are "exact" (the default) and "wald.wolfowitz" (the Wald-Wolfowitz approximation). round.up logical scalar indicating whether to round up the values of the computed sample size(s) to the next smallest integer. The default value is round.up=TRUE. n.max positive integer greater than 1 specifying the maximum possible sample size. The default value is n.max=5000. tol numeric scalar indicating the tolerance to use in the uniroot search algorithm. The default value is tol=1e-7. maxiter positive integer indicating the maximum number of iterations to use in the uniroot search algorithm. The default value is maxiter=1000.

### Details

If the arguments half.width, sigma.hat, coverage, and conf.level are not all the same length, they are replicated to be the same length as the length of the longest argument.

The help files for tolIntNorm and tolIntNormK give formulas for a two-sided tolerance interval based on the sample size, the observed sample mean and sample standard deviation, and specified confidence level and coverage. Specifically, the two-sided tolerance interval is given by:

[\bar{x} - Ks, \bar{x} + Ks] \;\;\;\;\;\; (1)

where \bar{x} denotes the sample mean:

\bar{x} = \frac{1}{n} ∑_{i=1}^n x_i \;\;\;\;\;\; (2)

s denotes the sample standard deviation:

s^2 = \frac{1}{n-1} ∑_{i=1}^n (x_i - \bar{x})^2 \;\;\;\;\;\; (3)

and K denotes a constant that depends on the sample size n, the confidence level, and the coverage (see the help file for tolIntNormK). Thus, the half-width of the tolerance interval is given by:

HW = Ks \;\;\;\;\;\; (4)

The function tolIntNormN uses the uniroot search algorithm to determine the sample size for specified values of the half-width, sample standard deviation, coverage, and confidence level. Note that unlike a confidence interval, the half-width of a tolerance interval does not approach 0 as the sample size increases.

### Value

numeric vector of sample sizes.

### Note

See the help file for tolIntNorm.

In the course of designing a sampling program, an environmental scientist may wish to determine the relationship between sample size, confidence level, and half-width if one of the objectives of the sampling program is to produce tolerance intervals. The functions tolIntNormHalfWidth, tolIntNormN, and plotTolIntNormDesign can be used to investigate these relationships for the case of normally-distributed observations.

### Author(s)

Steven P. Millard (EnvStats@ProbStatInfo.com)

### References

See the help file for tolIntNorm.

### See Also

tolIntNorm, tolIntNormK, tolIntNormHalfWidth, plotTolIntNormDesign, Normal.

### Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109  # Look at how the required sample size for a tolerance interval increases # with increasing coverage: seq(0.5, 0.9, by = 0.1) #[1] 0.5 0.6 0.7 0.8 0.9 tolIntNormN(half.width = 3, coverage = seq(0.5, 0.9, by = 0.1)) #[1] 4 4 5 6 9 #---------- # Look at how the required sample size for a tolerance interval decreases # with increasing half-width: 3:6 #[1] 3 4 5 6 tolIntNormN(half.width = 3:6) #[1] 15 8 6 5 tolIntNormN(3:6, round = FALSE) #[1] 14.199735 7.022572 5.092374 4.214371 #---------- # Look at how the required sample size for a tolerance interval increases # with increasing estimated standard deviation for a fixed half-width: seq(0.5, 2, by = 0.5) #[1] 0.5 1.0 1.5 2.0 tolIntNormN(half.width = 4, sigma.hat = seq(0.5, 2, by = 0.5)) #[1] 4 8 24 3437 #---------- # Look at how the required sample size for a tolerance interval increases # with increasing confidence level for a fixed half-width: seq(0.5, 0.9, by = 0.1) #[1] 0.5 0.6 0.7 0.8 0.9 tolIntNormN(half.width = 3, conf.level = seq(0.5, 0.9, by = 0.1)) #[1] 3 4 5 7 11 #========== # Example 17-3 of USEPA (2009, p. 17-17) shows how to construct a # beta-content upper tolerance limit with 95% coverage and 95% # confidence using chrysene data and assuming a lognormal distribution. # The data for this example are stored in EPA.09.Ex.17.3.chrysene.df, # which contains chrysene concentration data (ppb) found in water # samples obtained from two background wells (Wells 1 and 2) and # three compliance wells (Wells 3, 4, and 5). The tolerance limit # is based on the data from the background wells. # Here we will first take the log of the data and then estimate the # standard deviation based on the two background wells. We will use this # estimate of standard deviation to compute required sample sizes for # various half-widths on the log-scale. head(EPA.09.Ex.17.3.chrysene.df) # Month Well Well.type Chrysene.ppb #1 1 Well.1 Background 19.7 #2 2 Well.1 Background 39.2 #3 3 Well.1 Background 7.8 #4 4 Well.1 Background 12.8 #5 1 Well.2 Background 10.2 #6 2 Well.2 Background 7.2 longToWide(EPA.09.Ex.17.3.chrysene.df, "Chrysene.ppb", "Month", "Well") # Well.1 Well.2 Well.3 Well.4 Well.5 #1 19.7 10.2 68.0 26.8 47.0 #2 39.2 7.2 48.9 17.7 30.5 #3 7.8 16.1 30.1 31.9 15.0 #4 12.8 5.7 38.1 22.2 23.4 summary.stats <- summaryStats(log(Chrysene.ppb) ~ Well.type, data = EPA.09.Ex.17.3.chrysene.df) summary.stats # N Mean SD Median Min Max #Background 8 2.5086 0.6279 2.4359 1.7405 3.6687 #Compliance 12 3.4173 0.4361 3.4111 2.7081 4.2195 sigma.hat <- summary.stats["Background", "SD"] sigma.hat #[1] 0.6279 tolIntNormN(half.width = c(4, 2, 1), sigma.hat = sigma.hat) #[1] 4 12 NA #Warning message: #In tolIntNormN(half.width = c(4, 2, 1), sigma.hat = sigma.hat) : # Value of 'half.width' is too smallfor element3. # Try increasing the value of 'n.max'. # NOTE: We cannot achieve a half-width of 1 for the given value of # sigma.hat for a tolerance interval with 95% coverage and # 95% confidence. The default value of n.max is 5000, but in fact, # even with a million observations the half width is greater than 1. tolIntNormHalfWidth(n = 1e6, sigma.hat = sigma.hat) #[1] 1.232095 #========== # Clean up #--------- rm(summary.stats, sigma.hat) 

Search within the EnvStats package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.