Calculates a confidence interval and test the null hypothesis for the median absolute deviation (MAD) for a single sample.
madci(
x,
constant = 1.4826,
alternative = c("two.sided", "less", "greater"),
conf.level = 0.95,
true.mad = 1,
use.gld = FALSE,
gld.est = "TM",
...
)Hypothesis test results comparing two mads from independent samples and associated confidence interval for the ratio of mads (a list with class "htest"). This list includes values
statisticthe value of the Z-statistic.
p.valuethe p-value for the test.
conf.inta confidence interval for the MAD that is appropriate for the alternative hypothesis.
estimatethe estimated MAD.
null.valuethe specified hypothesized value of the MAD under the null hypothesis.
alternativea character string describing the alternative hypothesis.
data.namea character string giving the names of the data.
a numeric vector of data values.
a scale factor. Default choice ensures population mad is equal to sd for normal distributions.
a character string specifying the alternative hypothesis to be used. Needs to be one of "two.sided" (default), "greater" or "less".
confidence level for the confidence interval. The default is 0.95 (for a 95% confidence interval).
a number which is the nominated value for the population mad under the null hypothesis. Default is 1.
a logical indicating whether the Generalised Lambda Distribution (GLD) should be used to estimate the density of the data. Default is FALSE in which case the function density is used.
a character string indicating which gld estimator to use if use.gld = TRUE. See details below.
additional arguments, if desired, to be passed to function density for density estimation (see help file for density() for more details).
This function calculates an approximate confidence interval and conducts a hypothesis test for a single mad. The approximate variance used in the construction of the confidence interval and the test statistic is calculated using the varmad() function (see Arachchige and Prendergast (2024) and the help file for varmad() for further details).
Note that the interval and test statistic are approximate and may be unreliable for small sample sizes. Arachchige and Prendergast (2024) showed that reliable results
can be achieved for sample sizes of 50 or more when simulating data from various distributions. Additionally, the confidence interval is a Wald-type interval (estimate +/- crit*SE)
and so it may be possible that the domain of the interval contains negative values. Since negative values are not possible for the mad, thought could be given to truncation (setting the lower bound to zero), although
this may undermine interval coverage.
Arachchige, C.N.P.G., & Prendergast, L.A. (2026) Confidence intervals for median absolute deviations. Communications in Statistics-Simulation and Computation, 55(1), 13-22.
# Create some data
set.seed(1234)
x <- rlnorm(100)
# Calculate the mad, 95% confidence interval and test the hypothesis
mad.est <- madci(x)
mad.est
Run the code above in your browser using DataLab