ANOVA: One-way and Two-way ANOVA

Description Usage Arguments Value Author(s) Examples

View source: R/ANOVA.R

Description

Perform one-way or two-way ANOVA on variables of a data set. The output is printed as a LaTeX table that mimics the look of SPSS output (version <24), and a plot of the results mimics the look of SPSS graphs.

Usage

1
2
3
4
5
6
7
ANOVA(data, variable, group, conf.level = 0.95)

## S3 method for class 'ANOVASPSS'
print(x, digits = 3, statistics = c("descriptives", "variance", "test"), ...)

## S3 method for class 'ANOVASPSS'
plot(x, y, which = 1, type = "o", main = NULL, xlab = NULL, ylab = NULL, ...)

Arguments

data

a data frame containing the variables.

variable

a character string specifying the numeric variable of interest.

group

a character vector specifying one or two grouping variables.

conf.level

a number between 0 and 1 giving the confidence level of the confidence interval.

x

an object of class "ANOVASPSS" as returned by function ANOVA.

digits

an integer giving the number of digits after the comma to be printed in the LaTeX tables.

statistics

a character vector specifying which LaTeX tables should be printed. Available options are "descriptives" for descriptive statistics, "variance" for Levene's test on homogeneity of the variances, and "test" for ANOVA results. The default is to print all tables.

...

For the plot method, additional arguments to be passed down, in particular graphical parameters (see also linesSPSS). For the print method, additional arguments are currently ignored.

y

ignored (only included because it is defined for the generic function plot).

which

for two-way ANOVA, an integer with possible values 1 or 2 indicating whether the first or the second factor should be used on the x-axis. The other factor will then be used for drawing separate lines. For one-way ANOVA, this is not meaningful and ignored.

type

a character string specifying the type of lines. Possible values are "o" (the default) for overplotted points and lines, and "l" for lines only.

main, xlab, ylab

the plot title and axis labels.

Value

An object of class "ANOVASPSS" with the following components:

descriptives

a data frame containing per-group descriptive statistics.

levene

an object as returned by leveneTest.

test

a data frame containing the ANOVA table.

variable

a character string containing the name of the numeric variable of interest.

group

a character vector containing the name(s) of the grouping variable(s).

i

an integer giving the number of groups in the (first) grouping variable.

j

an integer giving the number of groups in the second grouping variable (only two-way ANOVA).

conf.level

numeric; the confidence level used.

type

a character string giving the type of ANOVA performed ("one-way" or "two-way").

The print method produces a LaTeX table that mimics the look of SPSS output (version <24).

The plot method does not return anything, but produces a profile plot of the ANOVA results.

Author(s)

Andreas Alfons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)

# one-way ANOVA
oneway <- ANOVA(Eredivisie, "logMarketValue",
                group = "Position")
oneway        # print LaTeX table
plot(oneway)  # create profile plot

# two-way ANOVA
twoway <- ANOVA(Eredivisie, "logMarketValue",
                group = c("Position", "Foreign"))
twoway        # print LaTeX table
plot(twoway)  # create profile plot

r2spss documentation built on Nov. 25, 2021, 1:06 a.m.