Table Of Contents

ANOVA (Three-Way ANOVA) (G Dataflow)

Last Modified: March 15, 2017

Performs a three-way analysis of variance (ANOVA) and returns the effect of the levels of three factors and the interactions among the factors on the experimental outcome.

connector_pane_image
datatype_icon

level c

Number of levels in factor c. You must specify at least two levels. Otherwise, this node returns an error.

The sign of level c is set to positive if c is a fixed effect and negative if c is a random effect.

Default: 2

datatype_icon

level b

Number of levels in factor b. You must specify at least two levels. Otherwise, this node returns an error.

The sign of level b is set to positive if b is a fixed effect and negative if b is a random effect.

Default: 2

datatype_icon

level a

Number of levels in factor a. You must specify at least two levels. Otherwise, this node returns an error.

The sign of level a is set to positive if a is a fixed effect and negative if a is a random effect.

Default: 2

datatype_icon

x

All the observational data. You must specify an equal number of observations in each cell.

The total number of data points in x must equal the result of multiplying the number of levels in each factor and the number of observations per cell. Otherwise, this node returns an error. For example, if level a is 2, level b is 3, level c is 2, and observations per cell is 2, x must contain 24 data points.

datatype_icon

index a

The level of factor a to which the corresponding observation belongs.

This input converts input levels that do not begin with zero or input levels that have nonconsecutive values. For example, if you enter an index that contains the levels 3, 5, and 7, this input converts the levels to an index array with level values of 0, 1, and 2.

datatype_icon

index b

The level of factor b to which the corresponding observation belongs.

This input converts input levels that do not begin with zero or input levels that have nonconsecutive values. For example, if you enter an index that contains the levels 3, 5, and 7, this input converts the levels to an index array with level values of 0, 1, and 2.

datatype_icon

index c

The level of factor c to which the corresponding observation belongs.

This input converts input levels that do not begin with zero or input levels that have nonconsecutive values. For example, if you enter an index that contains the levels 3, 5, and 7, this input converts the levels to an index array with level values of 0, 1, and 2.

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

observations per cell

Number of observations in each cell. Each cell must contain at least two observations. Otherwise, this node returns an error.

Default: 2

datatype_icon

significance

Values corresponding to the significance levels.

Analyzing significance for Your Experiment

Compare the corresponding significance output with the chosen level of significance to determine whether the level of the factor or the interaction among the factors has an effect on the experimental outcome. A common choice of the chosen level of significance is 0.05. If the corresponding significance output is less than the chosen level of significance, at least one level of the factor or the interaction among the factors has some effect on the experimental outcome.

For example, if factor a is a random effect, your chosen level of significance is 0.05, and significance a is 0.03, then you can conclude that factor a has an effect on the experimental outcome.

Algorithm for Calculating significance

Depending on whether a, b, and c are fixed or random, this node calculates significance using the following equations:

significance a = { { Prob { F dofa , dofe > fa } ( if c is fixed ) Prob { F dofa , dofac > fa } ( if c is random ) ( if b is fixed ) { Prob { F dofa , dofab > fa } ( if c is fixed ) 1 ( if c is random ) ( if b is random )
significance b = { { Prob { F dofb , dofe > fb } ( if a is fixed ) Prob { F dofb , dofab > fb } ( if a is random ) ( if c is fixed ) { Prob { F dofb , dofbc > fb } ( if a is fixed ) 1 ( if a is random ) ( if c is random )
significance c = { { Prob { F dofc , dofe > fc } ( if b is fixed ) Prob { F dofc , dofbc > fc } ( if b is random ) ( if a is fixed ) { Prob { F dofc , dofac > fc } ( if b is fixed ) 1 ( if b is random ) ( if a is random )
significance a b = { Prob { F dofab , dofe > fab } ( if c is fixed ) Prob { F dofab , dofabc > fab } ( if c is random )
significance a c = { Prob { F dofac , dofe > fac } ( if b is fixed ) Prob { F dofac , dofabc > fac } ( if b is random )
significance b c = { Prob { F dofbc , dofe > fbc } ( if a is fixed ) Prob { F dofbc , dofabc > fbc } ( if a is random )
s i g n i f i c a n c e a b c = Prob { F dofabc , dofe > fabc }

where

  • F dofa , dofe is the F distribution with dofa and dofe degrees of freedom
  • F dofa , dofac is the F distribution with dofa and dofac degrees of freedom
  • F dofa , dofab is the F distribution with dofa and dofab degrees of freedom
  • F dofb , dofe is the F distribution with dofb and dofe degrees of freedom
  • F dofb , dofab is the F distribution with dofb and dofab degrees of freedom
  • F dofb , dofbc is the F distribution with dofb and dofbc degrees of freedom
  • F dofc , dofe is the F distribution with dofc and dofe degrees of freedom
  • F dofc , dofbc is the F distribution with dofc and dofbc degrees of freedom
  • F dofc , dofac is the F distribution with dofc and dofac degrees of freedom
  • F dofab , dofe is the F distribution with dofab and dofe degrees of freedom
  • F dofab , dofabc is the F distribution with dofab and dofabc degrees of freedom
  • F dofac , dofe is the F distribution with dofac and dofe degrees of freedom
  • F dofac , dofabc is the F distribution with dofac and dofabc degrees of freedom
  • F dofbc , dofe is the F distribution with dofbc and dofe degrees of freedom
  • F dofbc , dofabc is the F distribution with dofc and dofbc degrees of freedom
  • F dofabc , dofe is the F distribution with dofabc and dofe degrees of freedom
datatype_icon

significance a

Level of significance associated with factor a.

datatype_icon

significance b

Level of significance associated with factor b.

datatype_icon

significance c

Level of significance associated with factor c.

datatype_icon

significance ab

Level of significance associated with the interaction of factors a and b.

datatype_icon

significance ac

Level of significance associated with the interaction of factors a and c.

datatype_icon

significance bc

Level of significance associated with the interaction of factors b and c.

datatype_icon

significance abc

Level of significance associated with the interaction of factors a, b, and c.

datatype_icon

summary

An 8-by-4 matrix that displays the obtained values for analysis.

summary = [ ssa dofa ssb dofb ssc dofc ssab dofab ssac dofac ssbc dofbc ssabc dofabc sse dofe msa fa msb fb msc fc msab fab msac fac msbc fbc msabc fabc mse 0.0 ]

where

  • The first column corresponds to the sums of squares associated with the respective factors (a, b, and c), the respective interactions (ab, ac, bc, and abc), and residual error
  • The second column corresponds to the respective degrees of freedom
  • The third column corresponds to the respective mean squares
  • The fourth column corresponds to the respective F values

Algorithm for Calculating Sums of Squares

This node calculates the sums of squares using the following equations:

ssa = b c L p = 0 a 1 ( x p ¯ x ¯ ) 2
ssb = a c L q = 0 b 1 ( x q ¯ x ¯ ) 2
ssc = a b L r = 0 c 1 ( x r ¯ x ¯ ) 2
ssab = c L p = 0 a 1 q = 0 b 1 ( x p q ¯ x p ¯ x q ¯ + x ¯ ) 2
ssac = b L p = 0 a 1 r = 0 c 1 ( x p r ¯ x p ¯ x r ¯ + x ¯ ) 2
ssbc = a L q = 0 b 1 r = 0 c 1 ( x q r ¯ x q ¯ x r ¯ + x ¯ ) 2
ssabc = L p = 0 a 1 q = 0 b 1 r = 0 c 1 ( x p q r ¯ x p q ¯ x p r ¯ x q r ¯ + x p ¯ + x q ¯ + x r ¯ x ¯ ) 2
sse = p = 0 a 1 q = 0 b 1 r = 0 c 1 s = 0 L 1 ( x p q r s x p q r ¯ ) 2

where

  • b is the number of levels in factor b
  • c is the number of levels in factor c
  • L is the number of observational data per cell
  • a is the number of levels in factor a
  • p is the index of each level in factor a, starting from 0
  • x p ¯ is the mean of all the observational data at the pth level of factor a
  • x ¯ is the mean of all the observational data
  • q is the index of each level in factor b, starting from 0
  • x q ¯ is the mean of all the observational data at the qth level of factor b
  • r is the index of each level in factor c, starting from 0
  • x r ¯ is the mean of all the observational data at the rth level of factor c
  • x p q ¯ is the mean of all the observational data at the pth and qth levels of factor a and b respectively
  • x p r ¯ is the mean of all the observational data at the pth and rth levels of factor a and c respectively
  • x q r ¯ is the mean of all the observational data at the qth and rth levels of factor b and c respectively
  • x p q r ¯ is the mean of all the observational data at the pth, qth, and rth levels of factor a, b, and c respectively
  • s is the index of each observational data in a cell defined by the pth, qth, and rth levels of factor a, b, and c respectively
  • xpqrs is the sth observational data at the pth, qth, and rth levels of factor a, b, and c respectively

Algorithm for Calculating Degrees of Freedom

This node calculates the degrees of freedom using the following equations:

dofa = a 1
dofb = b 1
dofc = c 1
dofab = ( a 1 ) ( b 1 )
dofac = ( a 1 ) ( c 1 )
dofbc = ( b 1 ) ( c 1 )
dofabc = ( a 1 ) ( b 1 ) ( c 1 )
dofe = a b c ( L 1 )

where

  • a is the number of levels in factor a
  • b is the number of levels in factor b
  • c is the number of levels in factor c
  • L is the number of observational data per cell

Algorithm for Calculating Mean Squares

This node calculates the mean squares using the following equations:

msa = ssa dofa
msb = ssb dofb
msc = ssc dofc
msab = ssab dofab
msac = ssac dofac
msbc = ssbc dofbc
msabc = ssabc dofabc
mse = sse dofe

where

  • ssa is a measure of variation attributed to factor a
  • dofa is the degree of freedom of ssa
  • ssb is a measure of variation attributed to factor b
  • dofb is the degree of freedom of ssb
  • ssc is a measure of variation attributed to factor c
  • dofc is the degree of freedom of ssc
  • ssab is a measure of variation attributed to the interaction of factor a and b
  • dofab is the degree of freedom of ssab
  • ssac is a measure of variation attributed to the interaction of factor a and c
  • dofac is the degree of freedom of ssac
  • ssbc is a measure of variation attributed to the interaction of factor b and c
  • dofbc is the degree of freedom of ssbc
  • ssabc is a measure of variation attributed to the interaction of factor a, b, and c
  • dofabc is the degree of freedom of ssabc
  • sse is a measure of variation attributed to random fluctuation
  • dofe is the degree of freedom of sse

Algorithm for Calculating F Values

This node calculates the F values using the following equations:

fa = { { msa mse ( if c is fixed ) msa msac ( if c is random ) ( if b is fixed ) { msa msab ( if c is fixed ) 1 ( if c is random ) ( if b is random )
fb = { { msb mse ( if a is fixed ) msb msab ( if a is random ) ( if c is fixed ) { msb msbc ( if a is fixed ) 1 ( if a is random ) ( if c is random )
fc = { { msc mse ( if b is fixed ) msc msbc ( if b is random ) ( if a is fixed ) { msc msac ( if b is fixed ) 1 ( if b is random ) ( if a is random )
fab = { msab mse ( if c is fixed ) msab msabc ( if c is random )
fac = { msac mse ( if b is fixed ) msac msabc ( if b is random )
fbc = { msbc mse ( if a is fixed ) msbc msabc ( if a is random )
fabc = msabc mse

where

  • msa is the mean square quantity of ssa
  • mse is the mean square quantity of sse
  • msac is the mean square quantity of ssac
  • msab is the mean square quantity of ssab
  • msb is the mean square quantity of ssb
  • msbc is the mean square quantity of ssbc
  • msc is the mean square quantity of ssc
  • msabc is the mean square quantity of ssabc

The greater the F value is, the more significant effect the corresponding factor or the interaction of the factors has on the experimental outcome.

datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Random and Fixed Effects

A factor is a basis for categorizing data. A factor is a random effect if it has a large population of levels about which you want to draw conclusions but such that you cannot sample from all levels. You thus pick levels at random and generalize about all levels.

A factor is a fixed effect if you can sample from all levels about which you want to draw conclusions.

ANOVA Cells

In ANOVA, cells mean level combinations of multiple factors. For example, if you specify the inputs for this node as shown in the following table, the second table below illustrates the cell distributions.

level a 2
level b 2
level c 2
x [10, 25, 16, 18, 13, 19, 15, 12, 30, 27, 16, 12, 30, 17, 15, 12]
index a [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1]
index b [0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1]
index c [1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1]
observations per cell 2
factor b (Level 0) factor b (Level 1)
factor c (Level 0) factor c (Level 1) factor c (Level 0) factor c (Level 1)
factor a (Level 0) 25, 13 10, 12 30, 15 16, 12
factor a (Level 1) 19, 15 16, 17 30, 27 18, 12

Using age, weight, or gender as a factor, this example demonstrates how to test whether age, weight, or gender has an effect on the number of sit-ups a person can do.

The following table defines the levels of age, weight, and gender.

factor a (age) Level 0 10 years old to 20 years old
Level 1 21 years old to 30 years old
factor b (weight) Level 0 less than 50 kg
Level 1 between 50 and 75 kg
factor c (gender) Level 0 male
Level 1 female

The following table lists the results of a random sampling of 16 people. The results are based on a series of observations of how many sit-ups people from different age, weight, and gender groups can do.

spd-note-note
Note  

To perform a three-way analysis of variance, you must make at least two observations per level, and make the same number of observations per cell.

Person 1 12 years old (Level 0) 40 kg (Level 0) female (Level 1) 10 sit-ups
Person 2 16 years old (Level 0) 46 kg (Level 0) male (Level 0) 25 sit-ups
Person 3 22 years old (Level 1) 47 kg (Level 0) female (Level 1) 16 sit-ups
Person 4 25 years old (Level 1) 51 kg (Level 1) female (Level 1) 18 sit-ups
Person 5 14 years old (Level 0) 49 kg (Level 0) male (Level 0) 13 sit-ups
Person 6 28 years old (Level 1) 45 kg (Level 0) male (Level 0) 19 sit-ups
Person 7 24 years old (Level 1) 48 kg (Level 0) male (Level 0) 15 sit-ups
Person 8 15 years old (Level 0) 46 kg (Level 0) female (Level 1) 12 sit-ups
Person 9 29 years old (Level 1) 65 kg (Level 1) male (Level 0) 30 sit-ups
Person 10 27 years old (Level 1) 62 kg (Level 1) male (Level 0) 27 sit-ups
Person 11 19 years old (Level 0) 58 kg (Level 1) female (Level 1) 16 sit-ups
Person 12 18 years old (Level 0) 68 kg (Level 1) female (Level 1) 12 sit-ups
Person 13 17 years old (Level 0) 59 kg (Level 1) male (Level 0) 30 sit-ups
Person 14 26 years old (Level 1) 45 kg (Level 0) female (Level 1) 17 sit-ups
Person 15 11 years old (Level 0) 50 kg (Level 1) male (Level 0) 15 sit-ups
Person 16 21 years old (Level 1) 54 kg (Level 1) female (Level 1) 12 sit-ups

The following table lists the inputs and outputs of this node.

level a 2
level b 2
level c 2
x [10, 25, 16, 18, 13, 19, 15, 12, 30, 27, 16, 12, 30, 17, 15, 12]
index a [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1]
index b [0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1]
index c [1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1]
observations per cell 2
summary ssa 27.5625
ssb 68.0625
ssc 232.563
ssab 3.0625
ssac 1.5625
ssbc 45.5625
ssabc 39.0625
sse 225.5
dofa 1
dofb 1
dofc 1
dofab 1
dofac 1
dofbc 1
dofabc 1
dofe 8
msa 27.5625
msb 68.0625
msc 232.563
msab 3.0625
msac 1.5625
msbc 45.5625
msabc 39.0625
mse 28.1875
fa 0.977827
fb 2.41463
fc 8.25055
fab 0.108647
fac 0.0554324
fbc 1.61641
fabc 1.38581
0.0 0
significance significance a 0.351697
significance b 0.158812
significance c 0.020753
significance ab 0.750154
significance ac 0.819782
significance bc 0.23931
significance abc 0.272948

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices


Recently Viewed Topics