-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
executable file
·272 lines (197 loc) · 7.51 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
---
output: github_document
bibliography: bibliography.bib
csl: chicago-author-date.csl
nocite: '@*'
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.align = "center",
fig.path = "man/figures/README-"
)
```
# **MEteorits:** Mixtures-of-ExperTs modEling for cOmplex and non-noRmal dIsTributions
<!-- badges: start -->
[![Travis build status](https://travis-ci.org/fchamroukhi/MEteorits.svg?branch=master)](https://travis-ci.org/fchamroukhi/MEteorits)
[![CRAN versions](https://www.r-pkg.org/badges/version/meteorits)](https://CRAN.R-project.org/package=meteorits)
[![CRAN logs](https://cranlogs.r-pkg.org/badges/meteorits)](https://CRAN.R-project.org/package=meteorits)
<!-- badges: end -->
MEteorits is an open source toolbox (available in R and Matlab) containing
several original and flexible mixtures-of-experts models to model, cluster and
classify heteregenous data in many complex situations where the data are
distributed according to non-normal and possibly skewed distributions, and
when they might be corrupted by atypical observations. The toolbox also
contains sparse mixture-of-experts models for high-dimensional data.
Our (dis-)covered meteorits are for instance the following ones:
* NMoE (Normal Mixtures-of-Experts);
* tMoE (t Mixtures-of-Experts);
* SNMoE (Skew-Normal Mixtures-of-Experts);
* StMoE (Skew t Mixtures-of-Experts).
The models and algorithms are developped and written in Matlab by Faicel
Chamroukhi, and translated and designed into R packages by Florian Lecocq,
Marius Bartcus and Faicel Chamroukhi.
# Installation
You can install the development version of MEteorits from [GitHub](https://github.com/fchamroukhi/MEteorits) with:
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("fchamroukhi/MEteorits")
```
To build *vignettes* for examples of usage, type the command below instead:
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("fchamroukhi/MEteorits",
build_opts = c("--no-resave-data", "--no-manual"),
build_vignettes = TRUE)
```
Use the following command to display vignettes:
```{r, eval = FALSE}
browseVignettes("meteorits")
```
# Usage
```{r, message = FALSE}
library(meteorits)
```
<details>
<summary>NMoE</summary>
```{r, echo = TRUE}
# Application to a simulated data set
n <- 500 # Size of the sample
alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network
betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts
sigmak <- c(1, 1) # Standard deviations of the experts
x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors)
# Generate sample of size n
sample <- sampleUnivNMoE(alphak = alphak, betak = betak,
sigmak = sigmak, x = x)
y <- sample$y
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
nmoe <- emNMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
nmoe$summary()
nmoe$plot()
```
```{r, echo = TRUE}
# Application to a real data set
data("tempanomalies")
x <- tempanomalies$Year
y <- tempanomalies$AnnualAnomaly
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
nmoe <- emNMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
nmoe$summary()
nmoe$plot()
```
</details>
<details>
<summary>TMoE</summary>
```{r, echo = TRUE}
# Application to a simulated data set
n <- 500 # Size of the sample
alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network
betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts
sigmak <- c(0.5, 0.5) # Standard deviations of the experts
nuk <- c(5, 7) # Degrees of freedom of the experts network t densities
x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors)
# Generate sample of size n
sample <- sampleUnivTMoE(alphak = alphak, betak = betak, sigmak = sigmak,
nuk = nuk, x = x)
y <- sample$y
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
tmoe <- emTMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
tmoe$summary()
tmoe$plot()
```
```{r, echo = TRUE}
# Application to a real data set
library(MASS)
data("mcycle")
x <- mcycle$times
y <- mcycle$accel
K <- 4 # Number of regressors/experts
p <- 2 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
tmoe <- emTMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
tmoe$summary()
tmoe$plot()
```
</details>
<details>
<summary>SNMoE</summary>
```{r, echo = TRUE}
# Application to a simulated data set
n <- 500 # Size of the sample
alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network
betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts
lambdak <- c(3, 5) # Skewness parameters of the experts
sigmak <- c(1, 1) # Standard deviations of the experts
x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors)
# Generate sample of size n
sample <- sampleUnivSNMoE(alphak = alphak, betak = betak,
sigmak = sigmak, lambdak = lambdak,
x = x)
y <- sample$y
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
snmoe <- emSNMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
snmoe$summary()
snmoe$plot()
```
```{r, echo = TRUE}
# Application to a real data set
data("tempanomalies")
x <- tempanomalies$Year
y <- tempanomalies$AnnualAnomaly
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
snmoe <- emSNMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
snmoe$summary()
snmoe$plot()
```
</details>
<details>
<summary>StMoE</summary>
```{r, echo = TRUE}
# Applicartion to a simulated data set
n <- 500 # Size of the sample
alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network
betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts
sigmak <- c(0.5, 0.5) # Standard deviations of the experts
lambdak <- c(3, 5) # Skewness parameters of the experts
nuk <- c(5, 7) # Degrees of freedom of the experts network t densities
x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors)
# Generate sample of size n
sample <- sampleUnivStMoE(alphak = alphak, betak = betak,
sigmak = sigmak, lambdak = lambdak,
nuk = nuk, x = x)
y <- sample$y
K <- 2 # Number of regressors/experts
p <- 1 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
stmoe <- emStMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
stmoe$summary()
stmoe$plot()
```
```{r, echo = TRUE}
# Applicartion to a real data set
library(MASS)
data("mcycle")
x <- mcycle$times
y <- mcycle$accel
K <- 4 # Number of regressors/experts
p <- 2 # Order of the polynomial regression (regressors/experts)
q <- 1 # Order of the logistic regression (gating network)
stmoe <- emStMoE(X = x, Y = y, K = K, p = p, q = q, verbose = TRUE)
stmoe$summary()
stmoe$plot()
```
</details>
# References