RandomEffect<T>

Models & Types · AiDotNet.Regression.MixedEffects

Represents a random effect specification in a mixed-effects model.

For Beginners

Random effects are like “adjustments” for each group in your data.

For example, if studying student test scores across different schools:

  • Fixed effect: Overall relationship between study time and scores
  • Random effect: Each school might have its own baseline score level

Random effects model this group-level variation properly, accounting for the fact that students in the same school are more similar to each other than to students from other schools.

How It Works

Random effects model group-level variation around population-level (fixed) effects. They capture correlation within groups and account for unobserved heterogeneity.

Constructors

Constructor Summary
RandomEffect() Initializes an empty random effect for state restoration.
RandomEffect(string name, int groupColumnIndex) Initializes a new instance of RandomEffect for a random intercept.
RandomEffect(string name, int groupColumnIndex, int[] randomSlopeColumns, bool includeIntercept) Initializes a new instance of RandomEffect with random slopes.

Properties

Property Summary
Dictionary<double, Vector<T>> GroupCoefficients { get; set; } Gets or sets the estimated random effect coefficients for each group.
Matrix<T> CovarianceMatrix { get; set; } Gets or sets the variance-covariance matrix of random effects.
bool IsRandomIntercept { get; set; } Gets or sets whether this is a random intercept.
int Dimension { get; } Gets the dimension of the random effect (1 for intercept only, more with slopes).
int GroupColumnIndex { get; set; } Gets or sets the grouping variable column index.
int NumberOfGroups { get; } Gets the number of unique groups in this random effect.
int[] RandomSlopeColumns { get; set; } Gets or sets the feature column indices for random slopes.
string Name { get; set; } Gets or sets the name of this random effect.

Methods

Method Summary
Vector<T> GetGroupEffect(double groupId) Gets the random effect vector for a specific group.
void SetGroupEffect(double groupId, Vector<T> coefficients) Sets the random effect vector for a specific group.