ci.mean {misty} | R Documentation |
Confidence Interval for the Arithmetic Mean and Median
Description
The function ci.mean
computes a confidence interval for the arithmetic
mean with known or unknown population standard deviation or population variance
and the function ci.median
computes the confidence interval for the
median for one or more variables, optionally by a grouping and/or split variable.
Usage
ci.mean(..., data = NULL, sigma = NULL, sigma2 = NULL, adjust = 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)
ci.median(..., data = NULL, 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)
Arguments
... |
a numeric vector, matrix or data frame with numeric variables,
i.e., factors and character variables are excluded from |
data |
a data frame when specifying one or more variables in the
argument |
sigma |
a numeric vector indicating the population standard deviation when computing confidence
intervals for the arithmetic mean with known standard deviation Note that either argument
|
sigma2 |
a numeric vector indicating the population variance when computing confidence intervals
for the arithmetic mean with known variance. Note that either argument |
adjust |
logical: if |
alternative |
a character string specifying the alternative hypothesis, must be one of
|
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
group |
either a character string indicating the variable name of
the grouping variable in |
split |
either a character string indicating the variable name of
the split variable in |
sort.var |
logical: if |
na.omit |
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 |
check |
logical: if |
write |
a character string naming a text file with file extension
|
append |
logical: if |
output |
logical: if |
Details
A difference-adjusted confidence interval (Baguley, 2012) for the arithmetic
mean can be computed by specifying adjust = TRUE
.
Value
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 |
Author(s)
Takuya Yanagida takuya.yanagida@univie.ac.at
References
Baguley, T. S. (2012). Serious stats: A guide to advanced statistics for the behavioral sciences. Palgrave Macmillan.
Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.
See Also
test.z
, test.t
, ci.mean.diff
,
ci.prop
, ci.var
, ci.sd
,
descript
Examples
# Example 1a: Two-Sided 95% Confidence Interval for the Arithmetic Mean for 'mpg'
ci.mean(mtcars$mpg)
# Example 1b: Alternative specification using the 'data' argument
ci.mean(mpg, data = mtcars)
# Example 2: Two-Sided 95% Confidence Interval for the Median
ci.median(mtcars$mpg)
# Example 3: Two-Sided 95% Difference-Adjusted Confidence Interval
ci.mean(mtcars$mpg, adjust = TRUE)
# Example 4: Two-Sided 95% Confidence Interval with known standard deviation
ci.mean(mtcars$mpg, sigma = 1.2)
# Example 5: Two-Sided 95% Confidence Interval with known variance
ci.mean(mtcars$mpg, sigma2 = 2.5)
# Example 6: One-Sided 95% Confidence Interval
ci.mean(mtcars$mpg, alternative = "less")
# Example 7: Two-Sided 99% Confidence Interval
ci.mean(mtcars$mpg, conf.level = 0.99)
# Example 8: Two-Sided 95% Confidence Interval, print results with 3 digits
ci.mean(mtcars$mpg, digits = 3)
# Example 9a: Two-Sided 95% Confidence Interval for 'mpg', 'cyl', and 'disp',
# listwise deletion for missing data
ci.mean(mtcars[, c("mpg", "cyl", "disp")], na.omit = TRUE)
#
# Example 9b: Alternative specification using the 'data' argument
ci.mean(mpg:disp, data = mtcars, na.omit = TRUE)
# Example 10a: Two-Sided 95% Confidence Interval, analysis by 'vs' separately
ci.mean(mtcars[, c("mpg", "cyl", "disp")], group = mtcars$vs)
# Example 10b: Alternative specification using the 'data' argument
ci.mean(mpg:disp, data = mtcars, group = "vs")
# Example 11: Two-Sided 95% Confidence Interval, analysis by 'vs' separately,
# sort by variables
ci.mean(mtcars[, c("mpg", "cyl", "disp")], group = mtcars$vs, sort.var = TRUE)
# Example 12: Two-Sided 95% Confidence Interval, split analysis by 'am'
ci.mean(mtcars[, c("mpg", "cyl", "disp")], split = mtcars$am)
# Example 13a: Two-Sided 95% Confidence Interval for 'mpg', 'cyl', and 'disp'
# analysis by 'vs' separately, split analysis by 'am'
ci.mean(mtcars[, c("mpg", "cyl", "disp")], group = mtcars$vs, split = mtcars$am)
# Example 13b: Alternative specification using the 'data' argument
ci.mean(mpg:disp, data = mtcars, group = "vs", split = "am")
## Not run:
# Example 14: Write results into a text file
ci.mean(mpg:disp, data = mtcars, group = "vs", split = "am", write = "Means.txt")
## End(Not run)