two_way_anova {kim} | R Documentation |
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 = TRUE,
error_bar = "ci",
error_bar_range = 0.95,
error_bar_tip_width = 0.13,
error_bar_thickness = 1,
error_bar_caption = TRUE,
line_colors = NULL,
line_types = NULL,
line_thickness = 1,
dot_size = 3,
position_dodge = 0.13,
x_axis_title = NULL,
y_axis_title = NULL,
y_axis_title_vjust = 0.85,
legend_title = NULL,
legend_position = "right",
output = "anova_table",
png_name = NULL,
width = 7000,
height = 4000,
units = "px",
res = 300,
layout_matrix = NULL
)
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 |
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 |
error_bar |
if |
error_bar_range |
width of the confidence interval
(default = 0.95 for 95 percent confidence interval).
This argument will not apply when |
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_types |
types of the lines connecting means (default = NULL)
If the second IV has two levels, then by default,
|
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
|
y_axis_title |
a character string for the y-axis title. If no
input is entered, then, by default, |
y_axis_title_vjust |
position of the y axis title (default = 0.85).
By default, |
legend_title |
a character for the legend title. If no input
is entered, then, by default, the second value of |
legend_position |
position of the legend:
|
output |
output type can be one of the following: |
png_name |
name of the PNG file to be saved.
If |
width |
width of the PNG file (default = 7000) |
height |
height of the PNG file (default = 4000) |
units |
the units for the |
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 |
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
Value
by default, the output will be "anova_table"
Examples
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