Learn R Programming

kim (version 0.5.3)

two_way_anova: Two-way ANOVA

Description

Conduct a two-way analysis of variance (ANOVA).

Usage

two_way_anova(
  data = NULL,
  dv_name = NULL,
  iv_1_name = NULL,
  iv_2_name = NULL,
  iv_1_values = NULL,
  iv_2_values = NULL,
  sigfigs = 3,
  robust = FALSE,
  iterations = 2000,
  plot = FALSE,
  error_bar = "ci",
  error_bar_range = 0.95,
  line_size = 1,
  dot_size = 3,
  error_bar_tip_width = 0.13,
  position_dodge = 0.13,
  legend_position = "right",
  output = "anova_table"
)

Value

by default, the output will be "anova_table"

Arguments

data

a data object (a data frame or a data.table)

dv_name

name of the dependent variable

iv_1_name

name of the first independent variable

iv_2_name

name of the second independent variable

iv_1_values

restrict all analyses to observations having these values for the first independent variable

iv_2_values

restrict all analyses to observations having these values for the second independent variable

sigfigs

number of significant digits to which to round values in anova table (default = 3)

robust

if TRUE, conduct a robust ANOVA in addition.

iterations

number of bootstrap samples for robust ANOVA. The default is set at 2000, but consider increasing the number of samples to 5000, 10000, or an even larger number, if slower handling time is not an issue.

plot

if TRUE, print a plot and enable returning an output.

error_bar

if error_bar = "se"; error bars will be +/-1 standard error, if error_bar = "ci" error bars will be a confidence interval; if error_bar = "pi", error bars will be a prediction interval

error_bar_range

width of the confidence or prediction interval (default = 0.95 for 95 percent confidence or prediction interval). This argument will not apply when error_bar = "se"

line_size

thickness of the lines connecting group means, (default = 1)

dot_size

size of the dots indicating group means (default = 3)

error_bar_tip_width

graphically, width of the segments at the end of error bars (default = 0.13)

position_dodge

by how much should the group means and error bars be horizontally offset from each other so as not to overlap? (default = 0.13)

legend_position

position of the legend: "none", "top", "right", "bottom", "left", "none" (default = "right")

output

output type can be one of the following: "anova_table", "group_stats", "plot", "levene_test_result", "robust_anova_results", "robust_anova_post_hoc_results", "robust_anova_post_hoc_contrast", "all"

Details

The following package(s) must be installed prior to running this function: Package 'car' v3.0.9 (or possibly a higher version) by Fox et al. (2020), https://cran.r-project.org/package=car

If robust ANOVA is to be conducted, the following package(s) must be installed prior to running the function: Package 'WRS2' v1.1-1 (or possibly a higher version) by Mair & Wilcox (2021), https://cran.r-project.org/package=WRS2

Examples

Run this code
# \donttest{
two_way_anova(
  data = mtcars, dv_name = "mpg", iv_1_name = "vs",
  iv_2_name = "am", iterations = 100)
anova_results <- two_way_anova(
  data = mtcars, dv_name = "mpg", iv_1_name = "vs",
  iv_2_name = "am", output = "all")
anova_results
# }

Run the code above in your browser using DataLab