Mixture Models

A mixture model is a probabilistic model that assumes that the observed data is generated from a mixture of several underlying distributions, each representing a different component of the data. In the context of temporal mixture models, each component is a temporal regression model that captures the underlying patterns in the time series data.

Univariate Mixture Model

The UnivariateMixtureModel is designed for clustering univariate time series data. It consists of multiple component models, each representing a different cluster in the data.

TemporalMixtureModels.UnivariateMixtureModelType

Create a univariate mixture model with n_components where each component is defined as the model passed in component.

Arguments

  • n_components::Int: Number of mixture components.
  • component::AbstractMixtureModelComponent{T}: An instance of a component model (e.g., PolynomialRegression(2) for a second order polynomial regression).

A univariate mixture model is defined as:

\[y_i(t) \sim \sum_{k=1}^{K} \pi_k f(y_i(t) | t, \theta_k)\]

where $f(y_i(t) | t, \theta_k)$ is the density defined by the regression model (e.g., polynomial regression) with parameters $\theta_k$, and $\pi_k$ are the mixture weights and $t$ is time.

Example

Creating a univariate mixture model with 3 components, each a polynomial of degree 2:

component = PolynomialRegression(2)
model = UnivariateMixtureModel(3, component)
source

Multivariate Mixture Model

The MultivariateMixtureModel is designed for clustering multivariate time series data. It consists of multiple component models, each representing a different cluster in the data. Each component model is a dictionary mapping variable names to their respective component models.

TemporalMixtureModels.MultivariateMixtureModelType

Create a multivariate mixture model with n_components where each component is defined by the models passed in the components dictionary.

Arguments

  • n_components::Int: Number of mixture components.
  • components::Dict{Symbol, <:AbstractMixtureModelComponent{T}}: A dictionary where keys are variable names (as Symbol) and values are instances of component models (e.g., PolynomialRegression(2) for a second order polynomial regression).

In this case, a multivariate mixture model is defined using independent components as:

\[(y_{i1}, y_{i2}, ..., y_{iJ}) \sim \sum_{k=1}^{K} \pi_k \prod_{j = 1}^{J} f_j(y_{ij} | t, \theta_{kj})\]

where $f_j(y_{ij} | t, \theta_{kj})$ is the density defined by the regression model for variable $j$with parameters\theta_{kj}, and\pi_k` are the mixture weights.

It is assumed that the variables are independent given the component assignment, i.e., the joint density is the product of the individual densities.

Example

Creating a multivariate mixture model with 2 components, each a polynomial of degree 2 for variables :y and :z:

components = Dict(:y => PolynomialRegression(2), :z => PolynomialRegression(2))
model = MultivariateMixtureModel(2, components)
source

Predicting

Both UnivariateMixtureModel and MultivariateMixtureModel support making predictions at specified time points using the predict function.

TemporalMixtureModels.predictMethod

Predict the values at given timepoints for each component of the mixture model for a univariate mixture model.

Arguments

  • model::UnivariateMixtureModel{T}: The fitted mixture model.
  • timepoints::Vector{T}: A vector of timepoints at which to predict

Returns

A matrix of size (length(timepoints), n_components) where each column corresponds to the predictions from one component.

source
TemporalMixtureModels.predictMethod

Predict the values at given timepoints for each component of the mixture model for a multivariate mixture model.

Arguments

  • model::MultivariateMixtureModel{T}: The fitted mixture model.
  • timepoints::Vector{T}: A vector of timepoints at which to predict

Returns

A dictionary where keys are variable names (as Symbol) and values are matrices of size (length(timepoints), n_components) where each column corresponds to the predictions from one component for that variable.

source