An S4 class to represent a multivariate mixture of regression model. The model follows [minka-linear](https://tminka.github.io/papers/minka-linear.pdf) . The model corresponds to the following generative model: $$ \pi \sim Dirichlet(\alpha)$$ $$ Z_i \sim \mathcal{M}(1,\pi)$$ $$ V_k \sim \mathcal{W}(\varepsilon^{-1},n_0)$$ $$ A_k \sim \mathcal{MN}(0,(V_k)^{-1},\tau XX^\top)$$ $$ Y_{i.}|X_{i.}, A_k, Z_{ik}=1 \sim \mathcal{N}(A_k x_{i.},V_{k}^{-1})$$ with \(\mathcal{W}(\epsilon^{-1},n_0)\) the Wishart distribution and \(\mathcal{MN}\) the matrix-normal distribution. The MoR-class must be used when fitting a simple Mixture of Regression whereas the MoRPrior-class must be used when fitting a CombinedModels-class.

MoRPrior(formula, tau = 0.001, N0 = NaN, epsilon = as.matrix(NaN))

MoR(formula, alpha = 1, tau = 0.1, N0 = NaN, epsilon = as.matrix(NaN))

Arguments

formula

a formula that describe the linear model to use

tau

Prior parameter (inverse variance) default 0.001

N0

Prior parameter (default to NaN, in this case N0 will be fixed equal to the number of columns of Y.)

epsilon

Covariance matrix prior parameter (default to NaN, in this case epsilon will be fixed to a diagonal variance matrix equal to 0.1 time the variance of the regression residuals with only one cluster.)

alpha

Dirichlet prior parameter over the cluster proportions (default to 1)

Value

a MoRPrior-class object a MoR-class object

Examples

MoRPrior(y ~ x1 + x2)
#> An object of class "MoRPrior"
#> Slot "formula":
#> y ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.001
#> 
#> Slot "N0":
#> [1] NaN
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
MoRPrior(y ~ x1 + x2, N0 = 100)
#> An object of class "MoRPrior"
#> Slot "formula":
#> y ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.001
#> 
#> Slot "N0":
#> [1] 100
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
MoRPrior(cbind(y1, y2) ~ x1 + x2, N0 = 100)
#> An object of class "MoRPrior"
#> Slot "formula":
#> cbind(y1, y2) ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.001
#> 
#> Slot "N0":
#> [1] 100
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
MoR(y ~ x1 + x2)
#> An object of class "MoR"
#> Slot "formula":
#> y ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.1
#> 
#> Slot "N0":
#> [1] NaN
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
#> Slot "alpha":
#> [1] 1
#> 
MoR(y ~ x1 + x2, N0 = 100)
#> An object of class "MoR"
#> Slot "formula":
#> y ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.1
#> 
#> Slot "N0":
#> [1] 100
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
#> Slot "alpha":
#> [1] 1
#> 
MoR(cbind(y1, y2) ~ x1 + x2, N0 = 100)
#> An object of class "MoR"
#> Slot "formula":
#> cbind(y1, y2) ~ x1 + x2
#> <environment: 0x55aff4819fd0>
#> 
#> Slot "tau":
#> [1] 0.1
#> 
#> Slot "N0":
#> [1] 100
#> 
#> Slot "epsilon":
#>      [,1]
#> [1,]  NaN
#> 
#> Slot "alpha":
#> [1] 1
#>