#----------------------------------------------------------------------------
# Confidence Interval (CI) for the Variance
# Example 1a: Two-Sided 95% CI
ci.var(mtcars)
# Example 1b: One-Sided 99% CI based on the chi-square distributio
ci.var(mtcars, alternative = "less", method = "chisq")
#----------------------------------------------------------------------------
# Confidence Interval (CI) for the Standard Deviation
# Example 2a: Two-Sided 95% CI
ci.sd(mtcars)
# Example 2b: One-Sided 99% CI based on the chi-square distributio
ci.sd(mtcars, alternative = "less", method = "chisq")
if (FALSE) {
#----------------------------------------------------------------------------
# Bootstrap Confidence Interval (CI)
# Example 3a: Bias-corrected (BC) percentile bootstrap CI
ci.var(mtcars, boot = "bc")
# Example 3b: Bias-corrected and accelerated (BCa) bootstrap CI,
# 5000 bootstrap replications, set seed of the pseudo-random number generator
ci.var(mtcars, boot = "bca", R = 5000, seed = 123)
#----------------------------------------------------------------------------
# Grouping and Split Variable
# Example 4a: Grouping variable
ci.var(mtcars, mpg, cyl, disp, group = "vs")
# Alternative specification without using the '...' argument
ci.var(mtcars[, c("mpg", "cyl", "disp")], group = mtcars$vs)
# Example 4b: Split variable
ci.var(mtcars, mpg, cyl, disp, split = "am")
# Alternative specification without using the '...' argument
ci.var(mtcars[, c("mpg", "cyl", "disp")], split = mtcars$am)
# Example 4c: Grouping and split variable
ci.var(mtcars, mpg, cyl, disp, group = "vs", split = "am")
# Alternative specification without using the '...' argument
ci.var(mtcars[, c("mpg", "cyl", "disp")], group = mtcars$vs, split = mtcars$am)
#----------------------------------------------------------------------------
# Write Output
# Example 5a: Text file
ci.var(mtcars, write = "CI_Var_Text.txt")
# Example 5b: Excel file
ci.var(mtcars, write = "CI_Var_Excel.xlsx")
#----------------------------------------------------------------------------
# Plot Confidence Intervals
# Example 6a: Two-Sided 95
ci.var(mtcars, plot = "ci")
# Example 6b: Grouping variable
ci.var(mtcars, disp, hp, group = "vs", plot = "ci")
# Example 6c: Split variable
ci.var(mtcars, disp, hp, split = "am", plot = "ci")
# Example 6d: Save plot as PDF file
ci.var(mtcars, disp, hp, plot = "ci", saveplot = "CI_Var.pdf",
width = 9, height = 6)
# Example 6e: Save plot as PNG file
ci.var(mtcars, disp, hp, plot = "ci", saveplot = "CI_Var.png",
width = 9, height = 6)
#----------------------------------------------------------------------------
# Plot Bootstrap Samples
# Example 7a: Two-Sided 95
ci.var(mtcars, disp, hp, boot = "bc", plot = "boot")
# Example 7b: Grouping variable
ci.var(mtcars, disp, hp, group = "vs", boot = "bc", plot = "boot")
# Example 7c: Split variable
ci.var(mtcars, disp, hp, split = "am", boot = "bc", plot = "boot")
# Example 7d: Save plot as PDF file
ci.var(mtcars, disp, hp, boot = "bc", plot = "boot",
saveplot = "CI_Var_Boot.pdf", width = 12, height = 7)
# Example 7e: Save plot as PNG file
ci.var(mtcars, disp, hp, boot = "bc", plot = "boot",
saveplot = "CI_Var_Boot.png", width = 12, height = 7)
}
Run the code above in your browser using DataLab