Rotations

The following documentation describes available dimension reduction, or "rotations," available in this package.

Which rotation you choose should be informed by your sense of your research story:

  • Want to get a high level view of your data? SVDRotation will capture the most variance and is good for getting an initial sense of your data's major features
  • Want to compare groups? Use MeanRotation when you have exactly two groups. Otherwise, consider LDARotation or MulticlassRotation. The distinction between these is spelled out in "Multiclass Rotations in Epistemic Network Analysis"
  • Want to see how your qualitative data relates to continuous or hierarchical variables? Use FormulaRotation, a rotation based on a regression framework described in "Hierarchical Epistemic Network Analysis"
  • Want to model a theoretical topic directly? Use TopicRotation to force certain connections to the left and others to the right. This is useful when you have suspicions that certain codes account for group differences and want to test those suspicions directly instead of inferring them by other means.
  • Want to test the generlizability or cross-validation of your model? Use TrainedRotation to create a new model that uses the same embedding and runs the same tests as an existing model.

Once you're familiar with them, continue to learn more about plotting.

SVDRotation

MeansRotation

Main.EpistemicNetworkAnalysis.MeansRotationType
MeansRotation(
    # Required, groups to compare along the x-axis
    groupVar1::Symbol,
    controlGroup1::Any,
    treatmentGroup1::Any,

    # Optional, groups to compare along subsequent axes
    args...;

    # Optional, whether to moderate the interactions between group dimensions
    moderated=false
)

Define a rotation for comparing pairs of groups, by maximizing the variance between pairs

See also: LDARotation and MulticlassRotation

Example

rotation = MeansRotation(
    :Play, "Romeo and Juliet", "Hamlet",
    :Act, 1, 5
)

Statistical Tests

Models using a MeansRotation will run the following statistical tests:

  • KruskalWallisTest for each dimension with a group pair
source

LDARotation

MulticlassRotation

Main.EpistemicNetworkAnalysis.MulticlassRotationType
MulticlassRotation(
    groupVar::Symbol
)

Define a rotation for comparing multiple groups, by maximizing between-group variance

See also: MeansRotation and LDARotation

Example

rotation = MulticlassRotation(:Act)

Statistical Tests

Models using an MulticlassRotation will run the following statistical tests:

  • KruskalWallisTest for each dimension
source

FormulaRotation

Main.EpistemicNetworkAnalysis.FormulaRotationType
FormulaRotation(
    regression_model1::Type{T},
    formula1::FormulaTerm,
    coef_index1::Int,
    contrast1::Union{Nothing,Dict},
    args...
) where {T <: RegressionModel}

Define a rotation that uses regression models to determine axes most closely associated with some linear trend

Note: RegressionModels must be imported from other stats packages

Note: contrasts are used to model categorical data

Example

using GLM

rotation = EpistemicNetworkAnalysis.FormulaRotation(
    LinearModel, @formula(edge ~ 1 + FinalGrade), 2, nothing
)

This will fit the x-axis to the FinalGrade metadata, because:

  1. We use LinearModel from the GLM package
  2. We use the formula edge ~ 1 + FinalGrade
  3. And we use the 2nd coefficient of the LinearModel (in this case FinalGrade) to determine the values of the embedding
  4. We have no categorical data in the LinearModel, so we leave the contrasts as nothing

Additional formulae may be used to define subsequent axes:

rotation = EpistemicNetworkAnalysis.FormulaRotation(
    LinearModel, @formula(edge ~ 1 + PretestGrade + PosttestGrade), 2, nothing,
    LinearModel, @formula(edge ~ 1 + PretestGrade + PosttestGrade), 3, nothing
)

Note: When multiple formulae are given, FormulaRotation finds the plane of the effects in the accum space, rotating it such that the first formula aligns with the x-axis, and the second formula aligns approximately with the y-axis. Unless this approximation is strong, a warning will be raised describing possible issues.

Statistical Tests

Models using a MeansRotation will run the following statistical tests:

  • R^2 and adjusted-R^2 for each dimension with a formula
source

TopicRotation

Main.EpistemicNetworkAnalysis.TopicRotationType
TopicRotation(
    topicName::AbstractString,
    controlNodes::Array{Symbol},
    treatmentNodes::Array{Symbol}
)

Define a rotation that places its x-axis through the mean of controlNodes on the left and the mean of treatmentNodes on the right, ie., through an a priori defined topic

Example

rotation = TopicRotation(
    "Gendered Language",
    [:Women, :Love],
    [:Men, :Honor]
)
source

TrainedRotation

Main.EpistemicNetworkAnalysis.TrainedRotationType
TrainedRotation(
    trainmodel::AbstractLinearENAModel
)

Define a rotation that copies the embedding of an existing "training" model for use in a second "testing" model

Example

# Randomly assign units to train or test sets
data[!, :rand] = rand(1:100, nrow(data))
trainFilter(unit) = unit.rand < 80
testFilter(unit) = !trainFilter(unit)

# Run model on the training set
trainmodel = ENAModel(
    data, codes, conversations, units,
    unitFilter=trainFilter,
    rotation=LDARotation(:Act)
)

# Run new model on the test set, but using the embedding of the trained model
testmodel = ENAModel(
    data, codes, conversations, units,
    unitFilter=testFilter,
    rotation=TrainedRotation(trainmodel)
)

Statistical Tests

Models using a TrainedRotation will run the same statistical tests as the trainmodel.

source