| confint | R Documentation |
Defines a method to compute confidence intervals for interest measures for association rules.
## S3 method for class 'rules'
confint(
object,
parm = "oddsRatio",
level = 0.95,
measure = NULL,
side = c("two.sided", "lower", "upper"),
method = NULL,
replications = 1000,
smoothCounts = 0,
transactions = NULL,
...
)
object |
an object of class rules. |
parm, measure |
name of the interest measures (see |
level |
the confidence level required. |
side |
Should a two-sided confidence interval or a one-sided limit be returned? Lower returns an interval with only a lower limit and upper returns an interval with only an upper limit. |
method |
method to construct the confidence interval. The available methods depends on the measure and the most common method is used by default. |
replications |
number of replications for method |
smoothCounts |
pseudo count for addaptive smoothing (Laplace smoothing). Often a pseudo counts of .5 is used for smoothing (see Detail Section). |
transactions |
transactions used to calculate the contingency-table counts. If supplied, stored rule-quality values are not reused. An independent validation dataset can be supplied to obtain confidence intervals that are not affected by mining and selecting the rules on the same observations. |
... |
Additional parameters are ignored with a warning. |
This method creates a contingency table for each rule and then constructs a
confidence interval for the specified measures. Confidence intervals for
all interest measures can be assessed using the "bootstrap" method.
However, since bootstrapping has to be applied to each rule
separately, this can be slow. For some popular measures, faster estimates
are available.
Returns a matrix with with one row for each rule and the two columns
named "LL" and "UL" with the interval boundaries.
The matrix has the following additional attributes:
measure |
the interest measure. |
level |
the confidence level |
side |
the confidence level |
smoothCounts |
used count smoothing. |
method |
name of the method to create the interval |
desc |
description of the used method to calculate the confidence interval. The mentioned references can be found below. |
Fast confidence interval approximations are currently available and used for the
measures "support", "count", "confidence", "lift", "oddsRatio", and "phi".
Methods:
"exact": Exact binomial proportion confidence interval (Clopper & Pearson, 1934).
"normal": Normal approximation population proportion confidence interval (Wilson, 1927).
"wilson": Wilson score interval (Wilson, 1927).
"woolf": Woolf method confidence interval for log of the odds ratio (Woolf, 1955).
"delta", "log_delta": Delta and Log delta method (Doob, 1935).
"gart": Haldane-Anscombe-Gart interval. Delta method with count smoothing of .5 (Haldane, 1956).
Available methods by interest measure:
| Interest measure | Default fast method | Other available fast methods |
"count" | "wilson" | "normal", "exact" |
"support" | "wilson" | "normal", "exact" |
"confidence" | "delta" | "log_delta", "wilson", "normal", "exact" |
"lift" | "delta" | "log_delta" |
"oddsRatio" | "woolf" | "gart", "exact" |
"phi" | "delta" | None |
The "bootstrap" method is also available.
All intervals are calculated using count data. Haldan-Anscombe correction
(Haldan, 1940; Anscombe, 1956) avoids issues
with zero counts by count smoothing (adding .5 to each count).
Haldan-Anscombe correction of smoothCounts = 0.5 can be used with any
interval method.
The Haldane-Anscombe-Gart interval above (method "gart") applies
the delta method with Haldan-Anscombe correction to the odds ratio
measure (Haldane, 1956).
Confidence intervals calculated from the same transactions used to mine and select rules do not account for the rule-selection process. Their nominal coverage may therefore be too optimistic, especially when many candidate rules are examined.
For confirmatory analysis, rules can be mined using training data and an
independent validation transaction set can be supplied using transactions.
The contingency-table counts and confidence intervals are then recalculated
from the validation data instead of using the quality measures stored with
the rules. When many rules are evaluated on the validation data,
multiple-comparison adjustments or a further independent test set may still
be appropriate.
Michael Hahsler
Wilson, E. B. (1927). "Probable inference, the law of succession, and statistical inference". Journal of the American Statistical Association, 22 (158): 209-212. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1927.10502953")}
Clopper, C.; Pearson, E. S. (1934). "The use of confidence or fiducial limits illustrated in the case of the binomial". Biometrika, 26 (4): 404-413. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/biomet/26.4.404")}
Doob, J. L. (1935). "The Limiting Distributions of Certain Statistics". Annals of Mathematical Statistics, 6: 160-169. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/aoms/1177732594")}
Fisher, R.A. (1962). "Confidence limits for a cross-product ratio". Australian Journal of Statistics, 4, 41.
Wilson, E.B. (1927, 6). "Probable inference, the law of succession, and statistical inference". Journal of the American Statistical Association, 22.
Woolf, B. (1955). "On estimating the relation between blood group and diseases". Annals of Human Genetics, 19, 251-253.
Haldane, J.B.S. (1940). "The mean and variance of the moments of chi-squared when used as a test of homogeneity, when expectations are small". Biometrika, 29, 133-134.
Haldane, J.B.S. (1956, 5). "The estimation and significance of the logarithm of a ratio of frequencies". Annals of Human Genetics, 20.
Anscombe, F.J. (1956). "On estimating binomial response relations". Biometrika, 43, 461-464.
Other interest measures:
coverage(),
interestMeasure(),
is.redundant(),
is.significant(),
support()
data("Income")
# mine some rules with the consequent "language in home=english"
rules <- apriori(Income,
parameter = list(support = 0.5),
appearance = list(rhs = "language in home=english")
)
# calculate the confidence interval for the rules' odds ratios.
# note that we use Haldane-Anscombe correction (with smoothCounts = .5)
# to avoid issues with 0 counts in the contingency table.
ci <- confint(rules, "oddsRatio", smoothCounts = .5)
ci
# We add the odds ratio (with Haldane-Anscombe correction)
# and the confidence intervals to the quality slot of the rules.
quality(rules) <- cbind(
quality(rules),
oddsRatio = interestMeasure(rules, "oddsRatio", smoothCounts = .5),
oddsRatio = ci
)
rules <- sort(rules, by = "oddsRatio")
inspect(rules)
# use confidence intervals for lift to find rules with a lift significantly larger then 1.
# We set the confidence level to 95%, create a one-sided interval and check
# if the interval does not cover 1 (i.e., the lower limit is larger than 1).
ci <- confint(rules, "lift", level = 0.95, side = "lower")
ci
inspect(rules[ci[, "LL"] > 1])
# For confirmatory analysis, mine rules on training data and calculate
# confidence intervals using independent validation data.
set.seed(1234)
training_ids <- sample(seq_along(Income), floor(.7 * length(Income)))
training <- Income[training_ids]
validation <- Income[-training_ids]
validation_rules <- apriori(training,
parameter = list(support = .5),
appearance = list(rhs = "language in home=english")
)
validation_ci <- confint(validation_rules,
"lift",
transactions = validation,
side = "lower"
)
inspect(validation_rules[validation_ci[, "LL"] > 1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.