ci.mean | R Documentation |
This function computes a confidence interval for the arithmetic mean 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(x, 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, check = TRUE, output = TRUE)
x |
a numeric vector, matrix or data frame with numeric variables, i.e.,
factors and character variables are excluded from |
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 |
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 |
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 |
output |
logical: if |
A difference-adjusted confidence interval (Baguley, 2012) can be computed by
specifying adjust = TRUE
.
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 takuya.yanagida@univie.ac.at
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.
test.z
, test.t
, ci.mean.diff
,
ci.median
, ci.prop
, ci.var
,
ci.sd
, descript
dat <- data.frame(group1 = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2),
group2 = c(1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2),
x1 = c(3, 1, 4, 2, 5, 3, 2, 4, NA, 4, 5, 3),
x2 = c(4, NA, 3, 6, 3, 7, 2, 7, 5, 1, 3, 6),
x3 = c(7, 8, 5, 6, 4, NA, 8, NA, 6, 5, 8, 6))
# Two-Sided 95% Confidence Interval for x1
ci.mean(dat$x1)
# Two-Sided 95% Difference-Adjusted Confidence Interval for x1
ci.mean(dat$x1, adjust = TRUE)
# Two-Sided 95% Confidence Interval with known standard deviation for x1
ci.mean(dat$x1, sigma = 1.2)
# Two-Sided 95% Confidence Interval with known variance for x1
ci.mean(dat$x1, sigma2 = 2.5)
# One-Sided 95% Confidence Interval for x1
ci.mean(dat$x1, alternative = "less")
# Two-Sided 99% Confidence Interval
ci.mean(dat$x1, conf.level = 0.99)
# Two-Sided 95% Confidence Interval, print results with 3 digits
ci.mean(dat$x1, digits = 3)
# Two-Sided 95% Confidence Interval for x1, convert value 4 to NA
ci.mean(dat$x1, as.na = 4)
# Two-Sided 95% Confidence Interval for x1, x2, and x3,
# listwise deletion for missing data
ci.mean(dat[, c("x1", "x2", "x3")], na.omit = TRUE)
# Two-Sided 95% Confidence Interval for x1, x2, and x3,
# analysis by group1 separately
ci.mean(dat[, c("x1", "x2", "x3")], group = dat$group1)
# Two-Sided 95% Confidence Interval for x1, x2, and x3,
# analysis by group1 separately, sort by variables
ci.mean(dat[, c("x1", "x2", "x3")], group = dat$group1, sort.var = TRUE)
# Two-Sided 95% Confidence Interval for x1, x2, and x3,
# split analysis by group1
ci.mean(dat[, c("x1", "x2", "x3")], split = dat$group1)
# Two-Sided 95% Confidence Interval for x1, x2, and x3,
# analysis by group1 separately, split analysis by group2
ci.mean(dat[, c("x1", "x2", "x3")], group = dat$group1, split = dat$group2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.