| ci.mean.diff | R Documentation |
This function computes confidence intervals for the difference in arithmetic means in a one-sample, two-sample and paired-sample design with known or unknown population standard deviation or population variance for one or more variables, optionally by a grouping and/or split variable.
ci.mean.diff(...)
## Default S3 method:
ci.mean.diff(data = NULL, ..., x = NULL, y, mu = 0,
sigma = NULL, sigma2 = NULL, var.equal = FALSE, 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.mean.diff(formula, data, sigma = NULL, sigma2 = NULL,
var.equal = FALSE, 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 |
mu |
a numeric value indicating the population mean under the
null hypothesis. Note that the argument |
sigma |
a numeric vector indicating the population standard deviation(s)
when computing confidence intervals for the difference in
arithmetic means with known standard deviation(s). In case
of independent samples, equal standard deviations are assumed
when specifying one value for the argument |
sigma2 |
a numeric vector indicating the population variance(s) when
computing confidence intervals for the difference in arithmetic
means with known variance(s). In case of independent samples,
equal variances are assumed when specifying one value for the
argument |
var.equal |
logical: if |
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 |
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 |
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
Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.
test.z, test.t, ci.mean, ci.median,
ci.prop, ci.var, ci.sd, descript
#————————————————————————————————————————————————————————————————————————————
# One-Sample Design
# Example 1a: Two-Sided 95% CI for 'mpg', population mean = 20
ci.mean.diff(mtcars, mpg, mu = 20)
# Example 1b: Alternative specification without using the '...' argument
ci.mean.diff(mtcars$mpg, mu = 20)
#————————————————————————————————————————————————————————————————————————————
# Two-Sample Design
# Example 2a: Two-Sided 95% CI for 'mpg' by 'vs'
ci.mean.diff(mpg ~ vs, data = mtcars)
# Example 2b: Alternative specification without using the '...' argument
ci.mean.diff(x = df.subset(mtcars, mpg, subset = vs == 0),
y = df.subset(mtcars, mpg, subset = vs == 1))
# Example 2c: Equal variance assumption
ci.mean.diff(mpg ~ vs, data = mtcars, var.equal = TRUE)
# Example 2d: Known equal population standard deviations
ci.mean.diff(mpg ~ vs, data = mtcars, sigma = 4)
# Example 2e: Known unequal population standard deviations
ci.mean.diff(mpg ~ vs, data = mtcars, sigma = c(4, 5))
# Example 2f: Two-Sided 95% CI for 'mpg', 'cyl', and 'disp' by 'vs'
ci.mean.diff(cbind(mpg, cyl, disp) ~ vs, data = mtcars)
# Example 2g: Analysis by group separately
ci.mean.diff(cbind(mpg, cyl, disp) ~ vs, data = mtcars, group = "am")
# Example 2h: Analysis split by group
ci.mean.diff(cbind(mpg, cyl, disp) ~ vs, data = mtcars, split = "am")
#————————————————————————————————————————————————————————————————————————————
# Paired-Sample Design
# Example 3a: Two-Sided 95% CI for the mean difference in 'pre' and 'post'
ci.mean.diff(mtcars, drat, wt, paired = TRUE)
# Example 3a: Alternative specification without using the '...' argument
ci.mean.diff(x = mtcars$drat, y = mtcars$wt, paired = TRUE)
# Example 3b: Analysis by group separately
ci.mean.diff(mtcars, drat, wt, paired = TRUE, group = "vs")
# Example 3c: Analysis split by group
ci.mean.diff(mtcars, drat, wt, paired = TRUE, split = "vs")
# Example 3e: Known population standard deviation of difference scores
ci.mean.diff(mtcars, drat, wt, sigma = 1, paired = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.