beales: Beale's Estimator and Sample Size

View source: R/beales.R

bealesR Documentation

Beale's Estimator and Sample Size

Description

Beale's ratio estimator \insertCiteBeale_1962funtimes for estimating population total and confidence intervals, with an option of calculating sample size for a required relative error (p) or margin of error (d).

Usage

beales(x, y, level = 0.95, N = NULL, p = NULL, d = NULL, verbose = TRUE)

Arguments

x

a numeric vector with quantities of interest, such as river discharge per month. Missing values (NA) are allowed.

y

a numeric vector with quantities of interest for which the total shall be estimated, such as total nutrient loads per month. Missing values (NA) are allowed. Lengths of x and y mush be the same.

level

confidence level, from 0 to 1. Default is 0.95, that is, 95% confidence.

N

population size for which the estimate of the total y is required. By default, length(x) is used.

p

optional argument specifying the required relative error, from 0 to 1, for computing the corresponding sample size. For example, p = 0.15 defines a 15% relative error.

d

optional argument specifying the required margin of error for computing the corresponding sample size. If both p and d are specified, only p is used.

verbose

logical value defining whether the output should be printed out in words. Default is set to TRUE to give such output.

Value

A list with the following components:

estimate

Beale's estimate of the population total for the variable y.

se

standard error of the estimate.

CI

a vector of length 2 with a confidence interval (lower and upper value) for the estimate.

level

confidence level for the interval.

N

population size.

n

the actual sample size.

p

the relative error used for sample size calculations. Reported only if p was specified in the input.

d

the margin of error used for sample size calculations. Reported only if d was specified and p was not specified in the input.

nhat

estimated sample size for the given level and error (p or d).

Author(s)

Vyacheslav Lyubchich, thanks to Dave Lorenz for pointing out an error in version 7 and below of the package

References

\insertAllCited

See Also

vignette("beales", package = "funtimes")

Examples

#Some hypothetical data for monthly river discharge 
#and corresponding nutrient loads:
discharge <- c(NA, 50, 90, 100, 80, 90, 100, 90, 80, 70, NA, NA)
loads <- c(33, 22, 44, 48, NA, 44, 49, NA, NA, 36, NA, NA)

#Example 1:
#Estimate total annual load (12 months), 
#with 90% confidence intervals
beales(discharge, loads, level = 0.9)

#Example 2:
#Calculate sample size required for 90% confidence intervals 
#with a margin of error 30 units
beales(discharge, loads, level = 0.9, d = 30)


funtimes documentation built on March 31, 2023, 7:35 p.m.