Calculate a weighted mean, between-group standard deviation and standard error on the weighted mean using the Mandel-Paule algorithm.
mpaule(x, …, tol=.Machine$double.eps^0.25, maxiter=25) # S3 method for default
mpaule(x, u=NULL, n=NULL, groups=NULL,
tol=.Machine$double.eps^0.25, maxiter=25, …)
mandel.paule(x, …, tol=.Machine$double.eps^0.25, maxiter=25)
numeric vector of mean values for groups, or (if groups
is given) of individual observations
numeric vector of standard deviations or standard uncertainties
associated with the values x
integer vector of numbers in each group. If NULL
, u
are interpreted as
standard uncertainties or standard errors. n
is recycled to length(x)
.
factor, or vetor which can be coerced to factor, of groups. If present, x
is
interpreted as a vector of individual observations and u
and n
ignored.
Additional parameters passed to other functions.
numeric tolerance; iteration stops when the variance step size drops below tol*var(x)
numeric maximum number of iterations
A loc.est object; see loc.est for details. In the returned object, df
is
set to \(n-1\) where \(n\) is the number of non-NA
observations or
group means as appropriate, and method.details
is returned as :
the estimated between-group variance)
the number of iterations taken
converged
indicates the convergence status. 0L
indicates
failure to converge (maxiter
reached before step size drops below tolerance);
1L
indicates normal convergence; 2L
indicates that the final step size resulted
in a negative between-group variance, at which point the variance and step size are set to 0.0
The Mandel-Paule algorithm finds the between-method variance by iteratively solving the
equation relating the weighted mean to the weighting factor applied. The weighting factor is
the inverse of the sum of the standard error in x
and the between-group variance.
If the iterative procedure produces a negative estimate for the between-group variance, the between-group variance is set to zero.
For the default method, if u
is present and n=NULL
, u
is interpreted as
a vector of standard uncertainties or standard errors. If n
is not NULL
, u
is interpreted as a vector of standard deviations and standard errors are calculated as
u/sqrt(n)
.
If groups
is not NULL
, x
is interpreted as a vector of individual
observations grouped by groups
, and the algorithm is applied to the corresponding
group means and standard errors.
If maxiter
is set less than 1, no iterations are performed and the consensus mean
is returned as NA
.
mandel.paule
is an alias for mpaule
retained for backward compatibility.
Paule, R. C. and Mandel, J. (1982), J Res Nat Bur Stand, 87, (5) 377-385
# NOT RUN {
## the second example in the paper cited above
x <- c(201.533, 216.55)
s <- c(0.154, 0.25)
n <- c(6, 2)
mpaule(x, s/sqrt(n))
## Cd heat of vapourisation example from the paper cited above
x2<-c(27.044, 26.022, 26.340, 26.787, 26.796)
v<-c(3, 76, 464, 3, 14)*1e-3
mpaule(x2, sqrt(v))
# }
Run the code above in your browser using DataLab