> On Mar 27, 2016, at 3:39 PM, sepehr akhavan <
akhavan...@gmail.com> wrote:
>
> Hi everyone,
>
> I read all the messages posted in the user group about Dirichlet Process models in Stan and I completely understand that stan uses HMC and hence, is not able to sample discrete parameters yet.
The problem isn't the discrete parameters, it's that the
DP has different numbers of parameters each iteration.
> I needed to somehow find a way to implement DP and DPM models and I thought of two solutions:
>
>
> • idea 1: I wrote my own DP sampling code in R. I then combined my code with my Stan model in a Gibbs sampling fashion where all parameters are sampled in Stan except beta0. Then given sampled parameters, I use my own code to sample beta0. I put this sampling into a loop from 1 to Num-of-iterations and in each iteration, I use stan with iter = 2, and warmup = 1 and my own code. The code seems working and converges. Would this idea make sense to you?
You have to balance the number of iterations in Stan with
the autocorrelation time; too few iterations and you don't
move far enough, too many and you do too much work.
> • idea 2: In Stan manual, there is an example of using LDA for topic modeling where authors propose marginalizing over the discrete parameter. We know with Latent Dirichlet Allocation, we can choose a fixed number of mixtures to approximate DP. Therefore, I used the same idea to approximate DP. The issue is my code is super slow. I fixed number of mixture components to 30 and ran the code for 300 subjects (this basically leads to two nesting loops with 30*300 iterations). As the tutorial highlighted for the mixture models, we should avoid vectorizing for this models. Is there any way to make the code faster? What would you think?
This is a common approach (it's one of the later BUGS example).
There's not a way to make the code faster.
And given that the posterior is so multimodal, you can't use
the usual convergence diagnostics.
You might try something like variational approximation
or even penalized maximum likelihood.
I'm afraid I didn't follow the combination of regression and
something labeled LDA in the program, or in the math below --- I
don't see how the betas connect to anything.
Are you trying to do a DP mixture of regressions?
- Bob
> Attached are my .stan and my .R code for idea 2 and for the model below:
>
> Y_i = beta0_i + beta_1 * X[i] + \epsilon
> \epsilon ~ Normal(0, var = sigma^2)
>
> --- Priors:
> beta0_i ~ G
> G ~ DP(\alpha, G0 = N(0, 10))
>
> beta_1 ~ Normal()
> sigma^2 ~ flat prior
>
> Thanks very much for your help,
> -Sepehr
>
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
> <simpleReg_DP.R><simpleReg_DP.stan>