Table Of Contents

ANOVA (Two-Way ANOVA) (G Dataflow)

Version:
    Last Modified: March 15, 2017

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

    connector_pane_image
    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, and observations per cell is 2, x must contain 12 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

    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 one observation. Otherwise, this node returns an error.

    Default: 1 — This node assumes that the interaction of factor a and factor b has no effect on the experimental outcome. Both level a and level b must be positive if observations per cell is 1.

    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

    This node calculates significance using the following equations:

    significance a = { Prob { F dofa , dofe > fa } ( if b is fixed ) Prob { F dofa , dofab > fa } ( if b is random )
    significance b = { Prob { F dofb , dofe > fb } ( if a is fixed ) Prob { F dofb , dofab > fb } ( if a is random )
    significance a b = Prob { F dofab , dofe > fab }

    where

    • F dofa , dofe is the F distribution with dofa and dofe 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 dofab , dofe is the F distribution with dofab 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 ab

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

    datatype_icon

    summary

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

    summary = [ ssa dofa ssb dofb ssab dofab sse dofe msa fa msb fb msab fab mse 0.0 ]

    where

    • The first column corresponds to the sum of squares associated with factor a, factor b, ab interaction, 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 L p = 0 a 1 ( x p ¯ x ¯ ) 2
    ssb = a L q = 0 b 1 ( x q ¯ x ¯ ) 2
    ssab = { L p = 0 a 1 q = 0 b 1 ( x p q ¯ x p ¯ x q ¯ + x ¯ ) 2 ( if L > 1 ) 0 ( if L = 1 )
    sse = { p = 0 a 1 q = 0 b 1 r = 0 L 1 ( x p q r x p q ¯ ) 2 ( if L > 1 ) p = 0 a 1 q = 0 b 1 ( x p q 1 x p 1 ¯ x q 1 ¯ + x 1 ¯ ) 2 ( if L = 1 )

    where

    • b is the number of levels in factor b
    • 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
    • x p q ¯ is the mean of all the observational data at the pth and qth levels of factor a and b respectively
    • r is the index of each observational data in a cell defined by the pth and qth levels of factor a and b respectively
    • xpqr is the rth observational data at the pth and qth levels of factor a and b respectively
    • xpq1 is the only observational data in the cell defined by the pth and qth levels of factor a and b respectively, when L = 1
    • x p 1 ¯ is the mean of all the observational data at the pth level of factor a, when L = 1
    • x q 1 ¯ is the mean of all the observational data at the qth levels of factor b, when L = 1
    • x 1 ¯ is the mean of all the observational data, when L = 1

    Algorithm for Calculating Degrees of Freedom

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

    dofa = a 1
    dofb = b 1
    dofab = { ( a 1 ) ( b 1 ) ( if L > 1 ) 0 ( if L = 1 )
    dofe = { a b ( L 1 ) ( if L > 1 ) ( a 1 ) ( b 1 ) ( if L = 1 )

    where

    • a is the number of levels in factor a
    • b is the number of levels in factor b
    • 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
    msab = ssab dofab
    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
    • ssab is a measure of variation attributed to the interaction of factor a and b
    • dofab is the degree of freedom of ssab
    • 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 b is fixed ) msa msab ( if b is random )
    fb = { msb mse ( if a is fixed ) msb msab ( if a is random )
    fab = msab mse

    where

    • msa is the mean square quantity of ssa
    • mse is the mean square quantity of sse
    • msab is the mean square quantity of ssab
    • msb is the mean square quantity of ssb

    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 3
    x [10, 15, 20, 25, 17, 4]
    index a [0, 1, 1, 1, 0, 0]
    index b [0, 0, 2, 1, 1, 2]
    observations per cell 1
    factor b (Level 0) factor b (Level 1) factor b (Level 2)
    factor a (Level 0) 10 17 4
    factor a (Level 1) 15 25 20

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

    The following table defines the levels of age and weight.

    factor a (age) Level 0 6 years old to 10 years old
    Level 1 11 years old to 15 years old
    factor b (weight) Level 0 less than 50 kg
    Level 1 between 50 and 75 kg
    Level 2 more than 75 kg

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

    spd-note-note
    Note  

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

    Person 1 8 years old (Level 0) 30 kg (Level 0) 10 sit-ups
    Person 2 12 years old (Level 1) 40 kg (Level 0) 15 sit-ups
    Person 3 15 years old (Level 1) 76 kg (Level 2) 20 sit-ups
    Person 4 14 years old (Level 1) 60 kg (Level 1) 25 sit-ups
    Person 5 9 years old (Level 0) 51 kg (Level 1) 17 sit-ups
    Person 6 10 years old (Level 0) 80 kg (Level 2) 4 sit-ups

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

    level a 2
    level b 3
    x [10, 15, 20, 25, 17, 4]
    index a [0, 1, 1, 1, 0, 0]
    index b [0, 0, 2, 1, 1, 2]
    observations per cell 1
    summary ssa 140.167
    ssb 102.333
    ssab 0
    sse 32.3333
    dofa 1
    dofb 2
    dofab 0
    dofe 2
    msa 140.167
    msb 51.1667
    msab 0
    mse 16.1667
    fa 8.6701
    fb 3.16495
    fab 0
    0.0 0
    significance significance a 0.0985787
    significance b 0.240099
    significance ab 0

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics