ci.var | R Documentation |
The function ci.var
computes the confidence interval for the variance,
and the function ci.sd
computes the confidence interval for the standard
deviation for one or more variables, optionally by a grouping and/or split variable.
ci.var(..., data = NULL, method = c("chisq", "bonett"),
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.sd(..., data = NULL, method = c("chisq", "bonett"),
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)
... |
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 |
method |
a character string specifying the method for computing the confidence interval,
must be one of |
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 |
write |
a character string naming a text file with file extension
|
append |
logical: if |
check |
logical: if |
output |
logical: if |
The confidence interval based on the chi-square distribution is computed by specifying method = "chisq"
,
while the Bonett (2006) confidence interval is requested by specifying method = "bonett"
. By default,
the Bonett confidence interval interval is computed which performs well under moderate departure from
normality, while the confidence interval based on the chi-square distribution is highly sensitive to minor
violations of the normality assumption and its performance does not improve with increasing sample size.
Note that at least four valid observations are needed to compute the Bonett confidence interval.
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
Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.
Bonett, D. G. (2006). Approximate confidence interval for standard deviation of nonnormal distributions. Computational Statistics and Data Analysis, 50, 775-782. https://doi.org/10.1016/j.csda.2004.10.003
ci.mean
, ci.mean.diff
, ci.median
,
ci.prop
, ci.prop.diff
, descript
# Example 1a: Two-Sided 95% CI for the variance for 'mpg'
ci.var(mtcars$mpg)
# Example 1b: Alternative specification using the 'data' argument
ci.var(mpg, data = mtcars)
# Example 2a: Two-Sided 95% CI for the standard deviation for 'mpg'
ci.sd(mtcars$mpg)
# Example 2b: Alternative specification using the 'data' argument
ci.sd(mpg, data = mtcars)
# Example 3: Two-Sided 95% CI using chi square distribution
ci.var(mtcars$mpg, method = "chisq")
# Example 4: One-Sided 95% CI
ci.var(mtcars$mpg, alternative = "less")
# Example 5: Two-Sided 99% CI
ci.var(mtcars$mpg, conf.level = 0.99)
# Example 6: Two-Sided 95% CI, print results with 3 digits
ci.var(mtcars$mpg, digits = 3)
# Example 7a: Two-Sided 95% CI for 'mpg', 'disp', and 'hp',
# listwise deletion for missing data
ci.var(mtcars[, c("mpg", "disp", "hp")])
# Example 7b: Alternative specification using the 'data' argument
ci.var(mpg:hp, data = mtcars)
# Example 8a: Two-Sided 95% CI, analysis by 'vs' separately
ci.var(mtcars[, c("mpg", "disp", "hp")], group = mtcars$vs)
# Example 8b: Alternative specification using the 'data' argument
ci.var(mpg:hp, data = mtcars, group = "vs")
# Example 9: Two-Sided 95% CI for, analysis by 'vs' separately, sort by variables
ci.var(mtcars[, c("mpg", "disp", "hp")], group = mtcars$vs, sort.var = TRUE)
# Example 10: Two-Sided 95% CI, split analysis by 'vs'
ci.var(mtcars[, c("mpg", "disp", "hp")], split = mtcars$vs)
# Example 11a: Two-Sided 95% CI, analysis by 'vs' separately, split analysis by 'am'
ci.var(mtcars[, c("mpg", "disp", "hp")], group = mtcars$vs, split = mtcars$am)
# Example 11b: Alternative specification using the 'data' argument
ci.var(mpg:hp, data = mtcars, group = "vs", split = "am")
## Not run:
# Example 12: Write results into a text file
ci.var(mpg:hp, data = mtcars, group = "vs", split = "am", write = "Variance.txt")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.