API

SimpleANOVA.anovaMethod
anova(observations::Array{Union{Number, Vector{Number}}}, factortypes = FactorType[]; factornames = String[], hasreplicates = true)
anova(observations::Vector{Number}, factorassignments::Vector{Vector{Any}}, factortypes = FactorType[]; factornames = String[], hasreplicates = true)
anova(df::DataFrame, observationscolumn::Symbol, factorcolumns::Vector{Symbol}, factortypes = FactorType[]; factornames = String[])

Performs an Analysis of Variance (ANOVA) calculation.

Operates on fixed or random factors, subject/block factors, and nested factors, with or without replicates, on balanced data.

Limitations:

  • If any factors are random type, limited to 3-way
  • Repeated measures ANOVA (with subject/block factor) limited to 3 fixed factors which may be partitioned as within or among subjects

Operates on up to 3 crossed factors (fixed or random) and arbitrarily many random nested factors, with or without replicates, on balanced data.

Arguments

  • observations: Array containing the values to test. For the array, each dimension is a factor level, such that observations[2,5,3] indicates the 2nd level of the first factor, the 5th level of the second factor, and the 3rd level of the third factor. May contain values or vectors of values, where the vector contains replicates. Factors should be ordered with least significant first. For the vector, must provide factorassignments to specify factor levels.
  • factorassignments: Vector of vectors of integers specifying how each observation is assigned to a factor level. Provide this when observations is given as a vector. Factor levels do not have to be consecutive or ordered. Nested factors must reuse factor levels currently.
  • factortypes: Vector indicating the FactorType for each factor. Factors must be ordered with nested first, then random/measured or fixed/manipulated in any order. For repeated measures, subject or block must appear after within-subject fixed and before among-subject fixed. If too few values are provided, remaining are assumed to be fixed.
  • factornames: Vector of names for each factor, excluding the replicate factor. If empty, will be automatically populated alphabetically.
  • hasreplicates: Boolean to specify if the first level should be considered

Notes: The last index will be the top factor in the table.

Output: AnovaData structure containing the test results for each factor.

Examples

anova(observations)                           # N-way fixed-effects ANOVA with replicates (vectors or first dimension)
anova(observations, hasreplicates = false)    # N-way fixed-effects ANOVA without replicates (first dimension)
anova(observations, [random])                 # N-way ANOVA with lower random factor and 1 or 2 upper fixed factors
anova(observations, [random])                 # N-way ANOVA with lower random factor and 1 or 2 upper fixed factors
anova(observations, [fixed, random])          # N-way ANOVA with 1 lower fixed factor, 1 random factor, and 0 or 1 upper fixed factor
anova(observations, [nested, random])         # N-way fixed-effects ANOVA with 1 random nested factor, 1 random factor, and 1-2 fixed factors
anova(observations, [fixed, subject])         # N-way repeated measures ANOVA with 1 within-subjects fixed factor
anova(observations, [fixed, block])           # N-way repeated measures ANOVA with 1 within-block fixed factor
anova(observations, [nested, fixed, subject]) # N-way repeated measures ANOVA with 1 within-subjects fixed factor and 1 nested factor

Glossary

  • observation: The dependent variable.
  • factor: An independent variable.
  • factor level: A value of a factor.
  • balanced: All combinations of factor levels have the same number of observations.
  • crossed factor: A factor with levels that combine with the levels of all other crossed factors.
  • fixed/manipulated factor: A factor with fixed effects (e.g. treatment, concentration, exposure time).
  • random/measured factor: A factor with random effects (e.g. location, individual).
  • nested factor: A random factor where the levels are unique to a combination of crossed factor levels (e.g. replicate).
  • subject/block factor: A nested factor that is subjected to multiple levels of another factor.
  • sum of squares (SS): A measure of variance that is dependent on sample size. Also called "sum of squared deviations."
  • degrees of freedom (DF, ν): The number of bins in which the values could have been moved, if random.
  • mean square (MS): SS / DF. Corrects for the larger variance expected if random values can be assigned to more bins. Also called "mean squared error" or "mean squared deviation."
  • F-statistic: The division of MS values produce a result belonging to the "F distribution", the shape of which depends on the DF of the numerator and error. The location of this value on the distribution provides the p-value.
  • p-value: The probability that, if all measurements had been drawn from the same population, you would obtain data at least as extreme as contained in your observations.
  • effect size (ω²): The standardized difference in the measurement caused by the factor. This is the generalized version which is largely stable with respect to study design.
source
SimpleANOVA.contrastFunction
contrast(anovaresult::AnovaResult, groupassignment::Vector{Int})

Calculate a single-factor contrast against the groups specified in groupassignment. Valid groups are "0", "1", and "2", where "0" excludes the group from the comparison.

Note: If you do nonorthogonal contrasts, use the Bonferroni or Šidák correction to adjust the α level (the level at which you consider a result likely to be true): Bonferroni: α′ = α/c for c contrasts Šidák: α′ = 1 - (1 - α)^(1 / c) (slightly better) where c = number of contrasts

Note: Effect size is calcluated using the error term associated with the factor. Other choices are possible, including average of each group error; or the error associated with a control.

source
SimpleANOVA.differencecontrastsFunction
differencecontrast(anovaresult::AnovaData, factorindex = 1, reverseorder = false)

Compute orthogonal contrasts on the factor levels in the original order. Forward direction also known as a "Helmert" contrast; revere direction may also be called "Difference" (as in SPSS). See contrast function for more.

source
SimpleANOVA.leveneMethod
levene(observations::Array{Union{Number, Vector{Number}}})
levene(observations::Vector{Number}, factorassignments::Vector{Vector{Any}})
levene(df::DataFrame, observationscolumn::Symbol, factorcolumns::Vector{Symbol})

Performs Levene's homogeniety of variance test.

Operates on at least 3 crossed factors (fixed or random) and arbitrarily many random nested factors on balanced data. Levene's test is identical to performing an ANOVA on the absolute deviations of each cell.

If Levene's test is significant, the data is heteroscedastic (variances differ). If it is not, variances could differ or the sample size could be too small to tell.

Arguments

  • observations: Array containing the values to test. For the array, each dimension is a factor level, such that observations[2,5,3] indicates the 2nd level of the first factor, the 5th level of the second factor, and the 3rd level of the third factor. May contain values or vectors of values, where the vector contains replicates. Factors should be ordered with least significant first. For the vector, must provide factorassignments to specify factor levels.
  • factorassignments: Vector of vectors of integers specifying how each observation is assigned to a factor level. Provide this when observations is given as a vector. Factor levels do not have to be consecutive or ordered. Nested factors must reuse factor levels currently.

Notes: Throws an exception if it can tell there are no replicates. Do not use with on any data structure you would pass into anova() using hasrepliates=false.

Output: AnovaData structure containing the test results for each factor.

Examples

levene(observations)
source
SimpleANOVA.repeatedcontrastsFunction
repeatedcontrast(anovaresult::AnovaData, factorindex = 1)

Compute contrasts between neighboring levels. Non-orthogonal. See contrast function for more.

source
SimpleANOVA.simplecontrastsFunction
simplecontrast(anovaresult::AnovaData, controlindex = 1, factorindex = 1)

Compute contrasts of each level to a single level (control). Non-orthogonal. See contrast function for more.

source
SimpleANOVA.AnovaContrastResultType
AnovaValue <: AnovaEffect

A set of values for an Anova item for which a mean square is not required.

contrast - the contrast value

df - degrees of freedom

f - the F statistic

p - the probability of a Type I error (incorrect rejection of null hypothesis)

r - the effect size

source
SimpleANOVA.AnovaFactorType
AnovaFactor <: AnovaEffect

A set of values for an Anova effect which has a mean square.

name - the name of this factor

ss - sum of squares

df - degrees of freedom

ms - mean square

source
SimpleANOVA.AnovaResultType
AnovaResult <: AnovaEffect

A set of values for an Anova factor which has been tested

name - the name of this factor

ss - sum of squares

df - degrees of freedom

ms - mean square

f - the F statistic

p - the probability of a Type I error (incorrect rejection of null hypothesis)

ω² - the effect size

source
SimpleANOVA.AnovaValueType
AnovaValue <: AnovaEffect

A set of values for an Anova item for which a mean square is not required.

name - the name of this value

ss - sum of squares

df - degrees of freedom

source
SimpleANOVA.FactorTypeType
FactorType

fixed manipulated - A crossed fixed-effects factor

random measured - A crossed random-effects factor

nested - A random factor fully nested within another factor

subject block - A random factor subjected to multiple levels of another factor

source