TEST.prop {UBStats} | R Documentation |
Test on the proportion
Description
TEST.prop()
tests hypotheses on the proportion of successes in a
population.
Usage
TEST.prop(
x,
success = NULL,
p0 = 0.5,
alternative = "two.sided",
digits = 2,
force.digits = FALSE,
use.scientific = FALSE,
data,
...
)
Arguments
x |
An unquoted string identifying the variable of interest.
|
success |
If |
p0 |
Numeric value that specifies the null hypothesis to test for (default is 0). |
alternative |
A length-one character vector specifying the direction
of the alternative hypothesis. Allowed values are |
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. |
Value
A table reporting the results of the test on the population proportion of successes.
Author(s)
Raffaella Piccarreta raffaella.piccarreta@unibocconi.it
See Also
CI.prop()
to build confidence intervals for the
population proportion of successes.
Examples
data(MktDATA, package = "UBStats")
# Success = one value of a character vector or factor
# - Bilateral test
TEST.prop(WouldSuggest, success = "Yes", p0 = 0.7,
data = MktDATA)
# - Unilateral test, change digits
TEST.prop(Education, success = "Post-Grad", p0 = 0.3,
alternative = "less", digits = 4,data = MktDATA)
# Success = numeric value; bilateral test
TEST.prop(Children, success = 2, p0 = 0.3, data = MktDATA)
# Binary variable (success = 1 by default); unilateral
TEST.prop(LastCampaign, p0 = 0.1, alternative = "greater",
digits = 3, data = MktDATA)
# Logical variable (success = TRUE by default); unilateral test
TEST.prop(Deals.ge50, p0 = 0.13, alternative = "greater",
digits = 3, data = MktDATA)
# Success based on combined conditions
# - Build a (logical) vector
IsTop <- MktDATA$CustClass == "Gold" |
MktDATA$CustClass == "Platinum"
TEST.prop(IsTop, p0 = 0.2, data = MktDATA)
HighAOV <- MktDATA$AOV>150
TEST.prop(HighAOV, p0 = 0.1)
TEST.prop(HighAOV, p0 = 0.1, force.digits = TRUE)
TEST.prop(HighAOV, p0 = 0.1, use.scientific = TRUE)
# Output results
out_test_prop<-TEST.prop(IsTop, p0 = 0.2, data = MktDATA)