View source: R/UBStats_Main_Visible_ALL_202406.R
CI.prop | R Documentation |
CI.prop()
builds confidence intervals for the proportion of
successes in a population.
CI.prop(
x,
success = NULL,
conf.level = 0.95,
digits = 2,
force.digits = FALSE,
use.scientific = FALSE,
data,
...
)
x |
An unquoted string identifying the variable of interest.
|
success |
If |
conf.level |
Numeric value specifying the required confidence level; default to 0.95. |
digits |
Integer value specifying the number of
decimals used to round statistics; default to 2. If the chosen rounding formats some
non-zero values as zero, the number of decimals is increased
so that all values have at least one significant digit, unless the argument
|
force.digits |
Logical value indicating whether reported values
should be forcedly rounded to the number of decimals specified in
|
use.scientific |
Logical value indicating whether numbers
in tables should be displayed using
scientific notation ( |
data |
An optional data frame containing |
... |
Additional arguments to be passed to low level functions. |
A table reporting the confidence intervals for the population proportion of successes.
Raffaella Piccarreta raffaella.piccarreta@unibocconi.it
TEST.prop()
to test hypotheses on the
proportion of successes in a population.
data(MktDATA, package = "UBStats")
# Success = one value of a character vector or factor
CI.prop(WouldSuggest, success = "Yes", data = MktDATA)
# - change confidence level and rounding
CI.prop(Education, success = "Post-Grad",
conf.level = 0.9, digits = 4,
data = MktDATA)
# Success = numeric value
CI.prop(Children, success = 2, data = MktDATA)
# Binary variable ('success' is 1 by default)
CI.prop(LastCampaign, digits = 3, data = MktDATA)
# Logical variable ('success' is TRUE by default)
CI.prop(RespCampaign, conf.level = 0.9, digits = 3, data = MktDATA)
# Success based on combined conditions
# - Build a (logical) vector indicating whether a condition is satisfied
IsTop <- MktDATA$CustClass == "Gold" | MktDATA$CustClass == "Platinum"
CI.prop(IsTop, conf.level = 0.9)
# - A very rare event
HighAOV <- MktDATA$AOV>150
CI.prop(HighAOV, conf.level = 0.9)
# Arguments force.digits, use.scientific
# - Default: manages possible excess of rounding
CI.prop(HighAOV)
# - Forcing digits to the default values (2)
CI.prop(HighAOV, force.digits = TRUE)
# - Allow scientific notation
CI.prop(HighAOV, use.scientific = TRUE)
# Output results
out_ci_prop<-CI.prop(HighAOV)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.