| ci.prop.diff | R Documentation |
This function computes confidence intervals for the difference in proportions in a two-sample and paired-sample design for one or more variables, optionally by a grouping and/or split variable.
ci.prop.diff(...)
## Default S3 method:
ci.prop.diff(data = NULL, ..., x = NULL, y = NULL,
method = c("wald", "newcombe"), paired = FALSE,
alternative = c("two.sided", "less", "greater"), conf.level = 0.95,
group = NULL, split = NULL, sort.var = FALSE, digits = 2, as.na = NULL,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
## S3 method for class 'formula'
ci.prop.diff(formula, data, method = c("wald", "newcombe"),
alternative = c("two.sided", "less", "greater"), conf.level = 0.95,
group = NULL, split = NULL, sort.var = FALSE, na.omit = FALSE,
digits = 2, as.na = NULL, write = NULL, append = TRUE,
check = TRUE, output = TRUE, ...)
data |
a data frame. Note that data are specified either by using
the argument |
... |
an expression indicating the variable names in |
x |
a numeric vector of data values. |
y |
a numeric vector of data values. |
formula |
a formula of the form |
method |
a character string specifying the method for computing the confidence interval,
must be one of |
paired |
logical: if |
alternative |
a character string specifying the alternative hypothesis, must be one of
|
na.omit |
logical: if |
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
group |
a numeric vector, character vector or factor as grouping variable. Note that a grouping variable can only be used when computing confidence intervals with unknown population standard deviation and population variance. |
split |
a numeric vector, character vector or factor as split variable. Note that a split variable can only be used when computing confidence intervals with unknown population standard deviation and population variance. |
sort.var |
logical: if |
digits |
an integer value indicating the number of decimal places to be used. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string naming a text file with file extension
|
append |
logical: if |
check |
logical: if |
output |
logical: if |
The Wald confidence interval which is based on the normal approximation to the binomial distribution are
computed by specifying method = "wald", while the Newcombe Hybrid Score interval (Newcombe, 1998a;
Newcombe, 1998b) is requested by specifying method = "newcombe". By default, Newcombe Hybrid Score
interval is computed which have been shown to be reliable in small samples (less than n = 30 in each sample)
as well as moderate to larger samples(n > 30 in each sample) and with proportions close to 0 or 1, while the
Wald confidence intervals does not perform well unless the sample size is large (Fagerland, Lydersen & Laake, 2011).
Returns an object of class misty.object, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
list with the input specified in |
args |
specification of function arguments |
result |
result table |
Takuya Yanagida
Fagerland, M. W., Lydersen S., & Laake, P. (2011) Recommended confidence intervals for two independent binomial proportions. Statistical Methods in Medical Research, 24, 224-254.
Newcombe, R. G. (1998a). Interval estimation for the difference between independent proportions: Comparison of eleven methods. Statistics in Medicine, 17, 873-890.
Newcombe, R. G. (1998b). Improved confidence intervals for the difference between binomial proportions based on paired data. Statistics in Medicine, 17, 2635-2650.
Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.
ci.prop, ci.mean, ci.mean.diff,
ci.median, ci.var, ci.sd,
descript
#————————————————————————————————————————————————————————————————————————————
# Two-Sample Design
# Example 1a: Two-Sided 95% CI for 'vs' by 'am', Newcombes Hybrid Score interval
ci.prop.diff(vs ~ am, data = mtcars)
# Example 2b: Alternative specification without using the '...' argument
ci.mean.diff(x = df.subset(mtcars, vs, subset = am == 0),
y = df.subset(mtcars, vs, subset = am == 1))
# Example 1c: Wald CI
ci.prop.diff(vs ~ am, data = mtcars, method = "wald")
#————————————————————————————————————————————————————————————————————————————
# Paired-Sample Design
# Example 2a: Two-Sided 95% CI for the difference in proportions 'pre' and 'post'
# Newcombes Hybrid Score interval
ci.prop.diff(mtcars, vs, am, paired = TRUE)
# Example 2b: Alternative specification without using the '...' argument
ci.prop.diff(x = mtcars$vs, y = mtcars$am, paired = TRUE)
# Example 2b: Wald CI
ci.prop.diff(mtcars, vs, am, method = "wald", paired = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.