-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.stan
More file actions
31 lines (24 loc) · 671 Bytes
/
model.stan
File metadata and controls
31 lines (24 loc) · 671 Bytes
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
data {
int<lower=1> n; // Number of words
int<lower=1> d; // Number of documents
int<lower=0> X[d, n]; // Word-document matrix (assuming word counts)
int<lower=1> m; // Number of topics
vector<lower=0>[m] a; // Dirichlet concentration parameter (provide some initial values)
real<lower=0> alpha; // Word frequency influence
real<lower=0> beta; // Smoothing parameter
}
parameters {
simplex[m] theta[n];
}
model {
for (i in 1:n) {
theta[i] ~ dirichlet(a);
}
for (i in 1:n) {
for (j in 1:d) {
for (k in 1:m) {
target += (alpha * X[j, i]) * log((theta[i, k] + beta) / (sum(theta[i]) + beta * m));
}
}
}
}