Calculates REML estimate of location, with standard error, assuming a random-effects model
reml.loc(x, ..., na.rm = FALSE) # S3 method for default
reml.loc(x, s, n = NULL, groups = NULL, na.rm = FALSE,
tol=.Machine$double.eps^0.5, REML=TRUE, ...)
A loc.est object; see loc.est for details. In the returned object, individual
values xi
are always input means (calculated from groups and n
as
necessary); method.details
is returned as a list containing:
The estimated location.
The standard error in the location.
The excess variance (as a standard deviation).
Logical, giving the value of REML used.
numeric vector of mean values for groups, or (if groups
is given) of individual observations
numeric vector of length length(x)
of standard deviations or
standard uncertainties associated with the values x
.
integer giving the number of observations in each group. May be a vector
of length length(x)
. If n
is NULL
, s
is interpreted as
a vector of 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 s
and n
ignored, if present, with a warning.
logical: if TRUE
, NA
values are removed
before processing.
numeric tolerance for convergence, used by optimize()
.
logical: if TRUE
(the default), the function optimises the REML
criterion (see Details). If FALSE, the maximum likelihood criterion is used.
Further parameters passed to optimize()
.
S L R Ellison s.ellison@lgcgroup.com
reml.loc
finds an excess variance \(\tau^2\) and location \(\mu\) that maximise the
restricted maximum likelihood criterion.
The estimator assumes a model of the form $$x_i=\mu+b_i+e_i$$ in which \(b_i\) is drawn from \(N(0, \tau^2)\) and \(e_i\) is drawn from \(N(0, \sigma_i^2)\).
By default the function maximises the data-dependent part of the negative log restricted likelihood:
$$\frac{1}{2} \left( \sum_{i=1}^{k}\frac{(x_i-mu)^2}{u_i^2} + \sum_{i=1}^{k}log(u_i^2) + log\left(\sum_{i=1}^{k}(1/u_i^2)\right) \right)$$
where \(u_i=s_i^2 + \tau^2\) and \(k\) is the number of mean values.
If REML=FALSE
, the final term is omitted to give the maximum likelihood criterion.
This implementation permits input in the form of:
means x
and standard errors s
, in which case neither n
nor
groups
are supplied;
means x
, standard deviations s
and group size(s) n
,
standard errors then being calculated as s/sqrt(n)
individual observations x
with a groupinf factor groups
, in
which case standard errors are calculated from the groups using tapply
.
None, but see documentation for the metafor package for a more general implementation of REML.
loc.est-class
#PCB measurements in a sediment from Key Comparison CCQM-K25
#s are reported standard uncertainties
pcb105 <- data.frame(x=c(10.21, 10.9, 10.94, 10.58, 10.81, 9.62, 10.8),
s=c(0.381, 0.250, 0.130, 0.410, 0.445, 0.196, 0.093))
with( pcb105, reml.loc(x, s) )
Run the code above in your browser using DataLab