Table Of Contents

ANOVA (Three-Way ANOVA) (G Dataflow)

Version:
    Last Modified: January 12, 2018

    Performs a three-way analysis of variance (ANOVA) and determines whether the three factors and their interactions have a significant effect on the experimental outcome.

    connector_pane_image
    datatype_icon

    levels c

    Number of levels in factor c. levels c must be equal to or greater than 2. Otherwise, this node returns an error.

    Specify a positive value if c is a fixed effect. Specify a negative value if c is a random effect.

    Default: 2

    datatype_icon

    levels b

    Number of levels in factor b. levels b must be equal to or greater than 2. Otherwise, this node returns an error.

    Specify a positive value if b is a fixed effect. Specify a negative value if b is a random effect.

    Default: 2

    datatype_icon

    levels a

    Number of levels in factor a. levels a must be equal to or greater than 2. Otherwise, this node returns an error.

    Specify a positive value if a is a fixed effect. Specify a negative value 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 node converts arrays that do not begin with 0 or have nonconsecutive values into arrays of consecutive values that begin with 0. For example, if you enter [3, 5, 7], this node converts the array into [0, 1, 2].

    datatype_icon

    index b

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

    This node converts arrays that do not begin with 0 or have nonconsecutive values into arrays of consecutive values that begin with 0. For example, if you enter [3, 5, 7], this node converts the array into [0, 1, 2].

    datatype_icon

    index c

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

    This node converts arrays that do not begin with 0 or have nonconsecutive values into arrays of consecutive values that begin with 0. For example, if you enter [3, 5, 7], this node converts the array into [0, 1, 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. observations per cell must be equal to or greater than 2. Otherwise, this node returns an error.

    Default: 2

    datatype_icon

    significance level

    Acceptable probability that this node incorrectly rejects a true null hypothesis.

    significance level is a threshold value used to judge whether a factor has a significant effect on the experimental outcome.

    Default: 0.05

    datatype_icon

    significance

    Significance values of the factors and their interactions.

    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 Fn1, n2 is the F distribution with n1 and n2 degrees of freedom.

    datatype_icon

    significance a

    Significance value associated with factor a.

    datatype_icon

    significance b

    Significance value associated with factor b.

    datatype_icon

    significance c

    Significance value associated with factor c.

    datatype_icon

    significance ab

    Significance value associated with the interaction of factors a and b.

    datatype_icon

    significance ac

    Significance value associated with the interaction of factors a and c.

    datatype_icon

    significance bc

    Significance value associated with the interaction of factors b and c.

    datatype_icon

    significance abc

    Significance value associated with the interaction of factors a, b, and c.

    datatype_icon

    summary

    An 8-by-5 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 F critical a F critical b F critical c F critical ab F critical ac F critical bc F critical abc 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
    • The fifth column corresponds to the respective F critical 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 factors a and b respectively
    • x p r ¯ is the mean of all the observational data at the pth and rth levels of factors a and c respectively
    • x q r ¯ is the mean of all the observational data at the qth and rth levels of factors b and c respectively
    • x p q r ¯ is the mean of all the observational data at the pth, qth, and rth levels of factors 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 factors a, b, and c respectively
    • xpqrs is the sth observational data at the pth, qth, and rth levels of factors 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 factors a and b
    • dofab is the degree of freedom of ssab
    • ssac is a measure of variation attributed to the interaction of factors a and c
    • dofac is the degree of freedom of ssac
    • ssbc is a measure of variation attributed to the interaction of factors b and c
    • dofbc is the degree of freedom of ssbc
    • ssabc is a measure of variation attributed to the interaction of factors 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

    Algorithm for Calculating F Critical Values

    F critical a is the value satisfying the following equation:

    Prob { F dofa , dofe F critical a } ( if c is fixed ) Prob { F dofa , dofac F critical a } ( if c is random ) } ( if b is fixed ) Prob { F dofa , dofab F critical a } ( if c is fixed ) 1 ( if c is random ) } ( if b is random ) } = significance level

    F critical b is the value satisfying the following equation:

    Prob { F dofb , dofe F critical b } ( if a is fixed ) Prob { F dofb , dofab F critical b } ( if a is random ) } ( if c is fixed ) Prob { F dofb , dofbc F critical b } ( if a is fixed ) 1 ( if a is random ) } ( if c is random ) } = significance level

    F critical c is the value satisfying the following equation:

    Prob { F dofc , dofe F critical c } ( if b is fixed ) Prob { F dofc , dofbc F critical c } ( if b is random ) } ( if a is fixed ) Prob { F dofc , dofac F critical c } ( if b is fixed ) 1 ( if b is random ) } ( if a is random ) } = significance level

    F critical ab is the value satisfying the following equation:

    Prob { F dofa b , dofe F critical ab } ( if c is fixed ) Prob { F dofa b , dofabc F critical ab } ( if c is random ) } = significance level

    F critical ac is the value satisfying the following equation:

    Prob { F dofac , dofe F critical ac } ( if b is fixed ) Prob { F dofac , dofabc F critical ac } ( if b is random ) } = significance level

    F critical bc is the value satisfying the following equation:

    Prob { F dofbc , dofe F critical bc } ( if a is fixed ) Prob { F dofbc , dofabc F critical bc } ( if a is random ) } = significance level

    F critical abc is the value satisfying the following equation:

    Prob { F dofabc , dofe F critical abc } = significance level

    where Fn1, n2 is the F distribution with n1 and n2 degrees of freedom.

    datatype_icon

    conclusion

    Result of the analysis. Each Boolean value in this output indicates whether the corresponding factor or interaction of the factors has a significant effect on the experimental outcome.

    True The corresponding element in significance is equal to or less than significance level, which means the corresponding factor or interaction of the factors has a significant effect on the experimental outcome.
    False The corresponding element in significance is -1 or is greater than significance level, which means the corresponding factor or interaction of the factors does not have a significant effect on the experimental outcome.
    datatype_icon

    a significant?

    Boolean value that indicates whether factor a has a significant effect on the experimental outcome.

    datatype_icon

    b significant?

    Boolean value that indicates whether factor b has a significant effect on the experimental outcome.

    datatype_icon

    c significant?

    Boolean value that indicates whether factor c has a significant effect on the experimental outcome.

    datatype_icon

    ab significant?

    Boolean value that indicates whether the interaction of factors a and b has a significant effect on the experimental outcome.

    datatype_icon

    ac significant?

    Boolean value that indicates whether the interaction of factors a and c has a significant effect on the experimental outcome.

    datatype_icon

    bc significant?

    Boolean value that indicates whether the interaction of factors b and c has a significant effect on the experimental outcome.

    datatype_icon

    abc significant?

    Boolean value that indicates whether the interaction of factors a, b and c has a significant effect 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.

    levels c 2
    levels b 2
    levels a 2
    x [10, 18, 16, 18, 13, 22, 17, 12, 22, 24, 16, 12, 23, 17, 15, 14]
    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) 18, 13 10, 12 23, 15 16, 12
    factor a (Level 1) 22, 17 16, 17 22, 24 18, 14

    Using age, weight, and gender as factors, this example demonstrates how to test whether age, weight, or gender has a significant 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 kg and 70 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) 18 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) 22 sit-ups
    Person 7 24 years old (Level 1) 48 kg (Level 0) male (Level 0) 17 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) 22 sit-ups
    Person 10 27 years old (Level 1) 62 kg (Level 1) male (Level 0) 24 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) 23 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) 14 sit-ups

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

    levels c 2
    levels b 2
    levels a 2
    x [10, 18, 16, 18, 13, 22, 17, 12, 22, 24, 16, 12, 23, 17, 15, 14]
    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
    significance level 0.05
    significance significance a 0.0375234
    significance b 0.165495
    significance c 0.0139613
    significance ab 0.589346
    significance ac 0.937954
    significance bc 0.490334
    significance abc 0.589346
    summary ssa 60.0625
    ssb 22.5625
    ssc 95.0625
    ssab 3.0625
    ssac 0.0625
    ssbc 5.0625
    ssabc 3.0625
    sse 77.5
    dofa 1
    dofb 1
    dofc 1
    dofab 1
    dofac 1
    dofbc 1
    dofabc 1
    dofe 8
    msa 60.0625
    msb 22.5625
    msc 95.0625
    msab 3.0625
    msac 0.0625
    msbc 5.0625
    msabc 3.0625
    mse 9.6875
    fa 6.2
    fb 2.32903
    fc 9.8129
    fab 0.316129
    fac 0.00645161
    fbc 0.522581
    fabc 0.316129
    0.0 0
    F critical a 5.31763
    F critical b 5.31763
    F critical c 5.31763
    F critical ab 5.31763
    F critical ac 5.31763
    F critical bc 5.31763
    F critical abc 5.31763
    0.0 0
    conclusion a significant? True
    b significant? False
    c significant? True
    ab significant? False
    ac significant? False
    bc significant? False
    abc significant? False

    Because only a significant? and c significant? are True in conclusion, you can conclude that based on the sampling data, only age and gender have a significant effect on the number of sit-ups a person can do.

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported

    Web Server: Not supported in VIs that run in a web application


    Recently Viewed Topics