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 (default = TRUE)
error_bar: if error_bar = "se"; error bars will be +/-1 standard error; if error_bar = "ci" error bars will be a confidence interval
error_bar_range: width of the confidence interval (default = 0.95 for 95 percent confidence interval). This argument will not apply when error_bar = "se"
error_bar_tip_width: graphically, width of the segments at the end of error bars (default = 0.13)
error_bar_thickness: thickness of the error bars (default = 1)
error_bar_caption: should a caption be included to indicate the width of the error bars? (default = TRUE).
line_colors: colors of the lines connecting means (default = NULL) If the second IV has two levels, then by default, line_colors = c("red", "blue")
line_types: types of the lines connecting means (default = NULL) If the second IV has two levels, then by default, line_types = c("solid", "dashed")
line_thickness: thickness of the lines connecting group means, (default = 1)
dot_size: size of the dots indicating group means (default = 3)
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)
x_axis_title: a character string for the x-axis title. If no input is entered, then, by default, the first value of iv_name will be used as the x-axis title.
y_axis_title: a character string for the y-axis title. If no input is entered, then, by default, dv_name will be used as the y-axis title.
y_axis_title_vjust: position of the y axis title (default = 0.85). By default, y_axis_title_vjust = 0.85, which means that the y axis title will be positioned at 85% of the way up from the bottom of the plot.
legend_title: a character for the legend title. If no input is entered, then, by default, the second value of iv_name
will be used as the legend title. If legend_title = FALSE, then the legend title will be removed.
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", "robust_anova_results", "robust_anova_post_hoc_results", "robust_anova_post_hoc_contrast", "all"
png_name: name of the PNG file to be saved. If png_name = TRUE, the name will be "two_way_anova_" followed by a timestamp of the current time. The timestamp will be in the format, jan_01_2021_1300_10_000001, where "jan_01_2021" would indicate January 01, 2021; 1300 would indicate 13:00 (i.e., 1 PM); and 10_000001 would indicate 10.000001 seconds after the hour.
width: width of the PNG file (default = 7000)
height: height of the PNG file (default = 4000)
units: the units for the width and height arguments. Can be "px" (pixels), "in" (inches), "cm", or "mm". By default, units = "px".
res: The nominal resolution in ppi which will be recorded in the png file, if a positive integer. Used for units other than the default. If not specified, taken as 300 ppi to set the size of text and line widths.
layout_matrix: The layout argument for arranging plots and tables using the grid.arrange function.
Returns
by default, the output will be "anova_table"
Details
Conduct a two-way factorial analysis of variance (ANOVA).
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
## Not run: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
## End(Not run)