Libraries.Compute.Statistics.Tests.ExperimentalDesign Documentation

Additionally, this class can construct a design matrix, a control 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 design matrix will include only the between-subjects factors chosen. The factors used for the control matrix will include only the control factors/variables chosen. 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 Control Matrix: https://en.wikipedia.org/wiki/Control_variable Contrast Matrix: https://en.wikipedia.org/wiki/Contrast_(statistics)

Inherits from: Libraries.Language.Object

Actions Documentation

AddBetweenSubjectsFactor(text header)

This action adds a new between-subjects factor to this design. This action can be used with long data or wide data when using repeated measures.

Parameters

  • text header: The name of the between-subjects factor.

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddBetweenSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)

This action adds a new between-subjects factor to this design. This action is used for wide data for a between-subjects design, meaning that each level or group of the between subjects factor is in its own column in the original DataFrame.

Parameters

  • text factorHeader: The chosen name for the generated factor.
  • text variableHeader: The chosen name for the generated dependent variable.
  • text columnHeaders: The list of headers for the columns used as each level in the generated factor.

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group", "Response", "Group1,Group2,Group3,Group4")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddBetweenSubjectsFactor(text factorHeader, text columnHeaders)

This action adds a new between-subjects factor to this design. This action is used for wide data for a between-subjects design, meaning that each level or group of the between subjects factor is in its own column in the original DataFrame.

Parameters

  • text factorHeader: The chosen name for the generated factor.
  • text columnHeaders: The list of headers for the columns used as each level in the generated factor.

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group", "Group1,Group2,Group3,Group4")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddDependentVariable(text header)

This action adds a new dependent variable to this design. This action should be used with long data only.

Parameters

  • text header: The name of the dependent variable.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddSubjectIdentifier(text header)

This action adds the subject identifier to this design. This action can be used with long data or wide data. When using repeated measures with long data, the subject identifier is REQUIRED, this is because the design needs to know which responses belong to which subject and when repeated measures are used in long format then the subject ids are repeated in the column and thus not unique for each row. Although not always required, it would be good practice to specify the subject identifier anyway.

Parameters

  • text header: The name of the subject identifier.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddWithinSubjectsFactor(text header)

This action adds a new within-subjects factor to this design. This action should be used with long data only.

Parameters

  • text header: The name of the within-subjects factor.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddWithinSubjectsFactor(text factorHeader, text variableHeader, text columnHeaders)

This action adds a new within-subjects factor to this design. This action is used for wide data for a within-subjects design or a mixed-model design, meaning that each level or measurement of the within-subjects factor is in its own column in the original DataFrame.

Parameters

  • text factorHeader: The chosen name for the generated factor.
  • text variableHeader: The chosen name for the generated dependent variable.
  • text columnHeaders: The list of headers for the columns used as each level in the generated factor.

Example

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

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

ExperimentalDesign design
design:AddWithinSubjectsFactor("Time", "Response", "Before,During,After")
design:Transform(frame)

output design:GetDesignFrame():ToText()

AddWithinSubjectsFactor(text factorHeader, text columnHeaders)

This action adds a new within-subjects factor to this design. This action is used for wide data for a within-subjects design or a mixed-model design, meaning that each level or measurement of the within-subjects factor is in its own column in the original DataFrame.

Parameters

  • text factorHeader: The chosen name for the generated factor.
  • text columnHeaders: The list of headers for the columns used as each level in the generated factor.

Example

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

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

ExperimentalDesign design
design:AddWithinSubjectsFactor("Time", "Before,During,After")
design:Transform(frame)

output design:GetDesignFrame():ToText()

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()

This action copies the design, this is used in several statistical tests.

Return

Libraries.Compute.Statistics.Tests.ExperimentalDesign:

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")

ExperimentalDesign copy = design:Copy()
copy:Transform(frame)
output copy:GetDesignFrame():ToText()

Empty()

This action removes all information from the design.

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Empty()

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()

This action returns an array of all the between-subjects factor headers.

Return

Libraries.Containers.Array: The array holding the between-subjects factor headers.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

Array<text> headers = design:GetBetweenSubjectsFactors()

GetContrastMatrix(text source)

This action returns the contrast matrix generated from a specific within-subjects factor. These factors are treated as categorical, thus this matrix will be generated from dummy-codes. This action has no need to be directly accessed, it is here for the CompareMeans tests to use when necessary.

Parameters

  • text source: The name of the within-subjects effect for the desired contrast matrix.

Return

Libraries.Compute.Matrix: The dummy-coded contrast matrix for the given within-subjects factors.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddWithinSubjectsFactor("Time", "Time1,Time2,Time3") 
design:Transform(frame)

output design:GetContrastMatrix("Time"):ToText()

GetContrastSources()

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

Return

Libraries.Containers.Array:

GetDependentVariables()

This action returns an array of all the dependent variable headers.

Return

Libraries.Containers.Array: The array holding the dependent variable headers.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response1")
design:AddDependentVariable("Response2")
design:Transform(frame)

Array<text> headers = design:GetDependentVariables()

GetDesignFrame()

This action returns the long format design dataframe.

Return

Libraries.Compute.Statistics.DataFrame: The dataframe as long format, ideal for statistical tests.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time", "Time1,Time2,Time3,Time4")
design:Transform(frame)

output design:GetDesignFrame():ToText()

GetDesignMatrix()

This action returns the design matrix generated from the between-subjects factors. These factors are treated as categorical, thus this matrix will be generated from dummy-codes for each main effect and interaction effect.

Return

Libraries.Compute.Matrix: The dummy-coded design matrix for the between-subjects factors.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetDesignMatrix():ToText()

GetDesignSources()

This action returns an array of sources (main effects and interaction effects) used for the design matrix.

Return

Libraries.Containers.Array: The array of the sources used to generate the design matrix.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

Array<text> sources = design:GetDesignSources()

GetGroupsFrame()

This action returns a wide format dataframe with each group/sample/measure as it's own column

Return

Libraries.Compute.Statistics.DataFrame: The dataframe as wide format with columns holding each sample

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time", "Time1,Time2,Time3,Time4")
design:Transform(frame)

output design:GetGroupsFrame():ToText()

GetGroupsTable()

This action returns a table with each multivariate group/sample/measure as it's own dataframe.

Return

Libraries.Containers.HashTable: The table dataframe holding each multivariate sample

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Groups")
design:AddDependentVariable("Weight")
design:AddDependentVariable("Height")
design:Transform(frame)

HashTable<text, DataFrame> groupsTable = design:GetGroupsTable()

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()

This action returns the number of between-subjects factors in this design.

Return

integer: The number of between-subjects factors in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfBetweenSubjectsFactors()

GetNumberOfDependentVariables()

This action returns the number of dependent variables in this design.

Return

integer: The number of dependent variables in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response1")
design:AddDependentVariable("Response2")
design:Transform(frame)

output design:GetNumberOfDependentVariables()

GetNumberOfIndependentGroups()

This action returns the number of independent groups in this design.

Return

integer: The number of independent groups in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfIndependentGroups()

GetNumberOfMeasurements()

This action returns the number of repeated measurements in this design.

Return

integer: The number of repeated measurements in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfMeasurements()

GetNumberOfObservations()

This action returns the number of total observations in this design.

Return

integer: The number of total observations in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfObservations()

GetNumberOfSubjects()

This action returns the number of individual subjects in this design.

Return

integer: The number of individual subjects in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfSubjects()

GetNumberOfWithinSubjectsFactors()

This action returns the number of within-subjects factors in this design.

Return

integer: The number of within-subjects factors in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetNumberOfWithinSubjectsFactors()

GetOriginalFrame()

This action returns the original untransformed dataframe.

Return

Libraries.Compute.Statistics.DataFrame: The original untransformed dataframe used in this design.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time", "Time1,Time2,Time3,Time4")
design:Transform(frame)

output design:GetOriginalFrame():ToText()

GetRankedFrame()

This action returns the long format design dataframe but with ranked dependent variables. If the design has only between-subjects factors the dependent variables will be ranked as a whole. If the design contains only within-subjects factors the dependent variable will be ranked for each subject id. If the design contains both between and within subject factors (i.e. mixed design), this action will alert the user with an error message explaining that it cannot rank the data properly.

Return

Libraries.Compute.Statistics.DataFrame: The dataframe as long format with ranked data, ideal for nonparametric statistical tests.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time", "Time1,Time2,Time3,Time4")
design:Transform(frame)

output design:GetRankedFrame():ToText()

GetSubjectIdentifier()

This action returns the subject identifier header.

Return

text: The header associated with the subject identifier.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:GetSubjectIdentifier()

GetWithinSubjectsFactors()

This action returns an array of all the within-subjects factor headers.

Return

Libraries.Containers.Array: The array holding the within-subjects factor headers.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time")
design:AddDependentVariable("Response")
design:Transform(frame)

Array<text> headers = design:GetWithinSubjectsFactors()

HasBetweenSubjectsFactors()

This action returns true if this design uses between-subjects factors.

Return

boolean: Boolean indicating use of between-subjects factors.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:HasBetweenSubjectsFactors()

HasWithinSubjectsFactors()

This action returns true if this design uses within-subjects factors.

Return

boolean: Boolean indicating use of within-subjects factors.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddWithinSubjectsFactor("Time")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:HasWithinSubjectsFactors()

Multivariate(boolean multivariate)

This action forces multivariate design when no factor is selected or specified in frame. This ensures that the design will not recognize individual dependent variables as repeated measures when using wide format.

Parameters

  • boolean multivariate: The boolean indicating if this design uses multiple dependent variables if there is no factor specified.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Groups")
design:AddDependentVariable("Variable1")
design:AddDependentVariable("Variable2")
design:AddDependentVariable("Variable3")
design:Multivariate(true)
design:Transform(frame)

output design:GetDesignFrame():ToText()

RemoveUndefined(boolean removeUndefined)

This action forces multivariate design when no factor is selected or specified in frame. This ensures that the design will not recognize individual dependent variables as repeated measures when using wide format.

Parameters

  • boolean removeUndefined

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Groups")
design:AddDependentVariable("Variable1")
design:AddDependentVariable("Variable2")
design:AddDependentVariable("Variable3")
design:Multivariate(true)
design:Transform(frame)

output design:GetDesignFrame():ToText()

RepeatedMeasures()

This action returns true if this design uses repeated measures.

Return

boolean: The boolean indicating if this design uses repeated measures.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)

output design:RepeatedMeasures()

RepeatedMeasures(boolean repeated)

This action forces repeated measures when no factor is selected or specified in frame. This is useful with wide format when conducting a one-way repeated measures anova (CompareMeans). By default, this action will lengthen the selected columns or dependent variables into an implicit within-subjects factor and name the factor "Measures" and the dependent variable will be named "Values". If any factors are specified, whatever boolean is set here will be overwritten by the specified design.

Parameters

  • boolean repeated: The boolean indicating if this design uses repeated measures if there is no factor specified.

Example

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

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

ExperimentalDesign design
design:AddSubjectIdentifier("ResponseID")
design:AddDependentVariable("Time1")
design:AddDependentVariable("Time2")
design:AddDependentVariable("Time3")
design:RepeatedMeasures(true)
design:Transform(frame)

output design:RepeatedMeasures()

Transform(Libraries.Compute.Statistics.DataFrame frame)

This action transforms the given frame to the proper format based on chosen factors/variables.

Parameters

Example

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

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

ExperimentalDesign design
design:AddBetweenSubjectsFactor("Group")
design:AddDependentVariable("Response")
design:Transform(frame)
  
output design:GetDesignFrame():ToText()