Libraries.Compute.Statistics.Tests.ExperimentalDesign Documentation

ExperimentalDesign is a helper class for several statistical tests including CompareMeans, CompareVariances and CompareDistributions. This class will take and hold various factor and column selections and transform the dataset into a necessary format for each test calculation. Additionally this class can construct a design matrix and a contrast matrix based on selected factors. These matrices are used in several calculations throughout the statistical tests. The factors used for the contrast matrix will include only the within-subjects factors chosen. For more information: Types of designs: https://vault.hanover.edu/~altermattw/courses/220/readings/BetweenWithinMixed.pdf Experimental Design: https://en.wikipedia.org/wiki/Design_of_experiments Design Matrix: https://en.wikipedia.org/wiki/Design_matrix Contrast Matrix: https://en.wikipedia.org/wiki/Contrast_(statistics)

Example Code

use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.ExperimentalDesign

DataFrame frame
frame:Load("Data.csv")

// An example of a mixed design 
ExperimentalDesign design
design:AddBetweenSubjectsFactor("factor1")                      // example of a between-subjects factor
design:AddWithinSubjectsFactor("factor2", "Time1,Time2,Time3")  // example of a within-subjects factor in wide format (repeated measures)
design:AddSubjectIdentifier("participant")                      // subject id is not needed for within-subjects wide format, but it won't hurt 

design:Transform(frame)                                         // this will check that selections above are valid and create the design dataframe
output design:GetDesignFrame():ToText()

Inherits from: Libraries.Language.Object

Actions Documentation

AddBetweenSubjectsFactor(text header)

For long or wide data.

Parameters

  • text header

AddBetweenSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)

For wide data in between design.

Parameters

  • text factorHeader
  • text variableHeader
  • text columnHeaders

AddBetweenSubjectsFactor(text factorHeader, text columnHeaders)

For wide data in between design.

Parameters

  • text factorHeader
  • text columnHeaders

AddDependentVariable(text header)

For long data.

Parameters

  • text header

AddSubjectIdentifier(text header)

For long or wide data.

Parameters

  • text header

AddWithinSubjectsFactor(text header)

For long data.

Parameters

  • text header

AddWithinSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)

For wide data in within design or mixed design.

Parameters

  • text factorHeader
  • text variableHeader
  • text columnHeaders

AddWithinSubjectsFactor(text factorHeader, text columnHeaders)

For wide data in within design or mixed design.

Parameters

  • text factorHeader
  • text columnHeaders

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Copy()

Binary activation encoded, used in contrast matrix

Return

Libraries.Compute.Statistics.Tests.ExperimentalDesign:

Empty()

Binary activation encoded, used in contrast matrix

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetBetweenSubjectsFactors()

Returns an array of all the between-subjects factor headers

Return

Libraries.Containers.Array:

GetContrastMatrix(text source)

Returns the contrast matrix for a given source (main effect or interaction)

Parameters

  • text source

Return

Libraries.Compute.Matrix:

GetContrastSources()

Returns an array of sources used for the contrast matrix (main effects and interactions)

Return

Libraries.Containers.Array:

GetDependentVariables()

Returns an array of all the dependent variable headers

Return

Libraries.Containers.Array:

GetDesignFrame()

Returns the long format design dataframe

Return

Libraries.Compute.Statistics.DataFrame:

GetDesignMatrix()

Returns the design matrix for all sources (main effects and interactions)

Return

Libraries.Compute.Matrix:

GetDesignSources()

Returns an array of sources used for the design matrix (main effects and interactions)

Return

Libraries.Containers.Array:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetNumberOfBetweenSubjectsFactors()

Returns an array of all the between-subjects factor headers

Return

integer:

GetNumberOfDependentVariables()

Returns an array of all the dependent variable headers

Return

integer:

GetNumberOfIndependentGroups()

Returns the number of independent groups

Return

integer:

GetNumberOfMeasurements()

Returns the number of repeated measurements

Return

integer:

GetNumberOfObservations()

Returns the number of total observations

Return

integer:

GetNumberOfSubjects()

Returns the number of individual subjects

Return

integer:

GetNumberOfWithinSubjectsFactors()

Returns an array of all the within-subjects factor headers

Return

integer:

GetOriginalFrame()

Returns the original format dataframe

Return

Libraries.Compute.Statistics.DataFrame:

GetSubjectIdentifier()

Returns the subject identifier header

Return

text:

GetWithinSubjectsFactors()

Returns an array of all the within-subjects factor headers

Return

Libraries.Containers.Array:

HasBetweenSubjectsFactors()

Returns the subject identifier header

Return

boolean:

HasWithinSubjectsFactors()

Holds the levels for each within-subjects factor (sorted)

Return

boolean:

Multivariate(boolean multivariate)

Flag to assume individual dependent variables (i.e. not same variable repeated) when no factor is selected in frame (useful in wide format)

Parameters

  • boolean multivariate

RepeatedMeasures()

Returns true if a within-subjects factor is used

Return

boolean:

RepeatedMeasures(boolean repeated)

Flag to use repeated measures when no factor is selected in frame (useful in wide format)

Parameters

  • boolean repeated

Transform(Libraries.Compute.Statistics.DataFrame frame)

Binary activation encoded, used in contrast matrix

Parameters