--
At first I generate synthetic data as follows:K=10N=5000theta=runif(K,0,1)theta=theta/sum(theta)mu=runif(K,0,1)sigma=runif(K,0,2)prob=function(y,theta,mu,sigma){p=c(1:K)for(k1 in c(1:K)){p[k1]=theta[k1]*dnorm(y,mu[k1],sqrt(sigma[k1]))}return(sum(p))}y=rep(NA,N) # generate y based on rejection-methodn1=1while(n1<(N+1)){temp1=runif(1,-5,5)p=prob(temp1,theta,mu,sigma)temp2=runif(1,0,0.2)if(temp2<p){y[n1]=temp1n1=n1+1}}Then build the model:data{
int<lower=1> K;
int<lower=1> N;
real y[N];
}
parameters{
simplex[K] theta;
real mu[K];
real<lower=0> sigma[K];
}
model {
real ps[K];
sigma ~ cauchy(0,0.5);
mu~normal(0,1);
for(n in 1:N){
for(k in 1:K){
ps[k]=log(theta[k])+normal_lpdf(y[n]|mu[k],sigma[k]);
}
target+=log_sum_exp(ps);
}
}
The sampling is very slow and some errors appears:SAMPLING FOR MODEL 'gmm' NOW (CHAIN 1).WARNING: The initial buffer, adaptation window, and terminal bufferoverflow the total number of warmup iterations.Defaulting to a 15%/75%/10% partition,init_buffer = 3adapt_window = 20term_buffer = 2Chain 1, Iteration: 1 / 50 [ 2%] (Warmup)Chain 1, Iteration: 5 / 50 [ 10%] (Warmup)Chain 1, Iteration: 10 / 50 [ 20%] (Warmup)Chain 1, Iteration: 15 / 50 [ 30%] (Warmup)Chain 1, Iteration: 20 / 50 [ 40%] (Warmup)Chain 1, Iteration: 25 / 50 [ 50%] (Warmup)Chain 1, Iteration: 26 / 50 [ 52%] (Sampling)Chain 1, Iteration: 30 / 50 [ 60%] (Sampling)Chain 1, Iteration: 35 / 50 [ 70%] (Sampling)Chain 1, Iteration: 40 / 50 [ 80%] (Sampling)Chain 1, Iteration: 45 / 50 [ 90%] (Sampling)Chain 1, Iteration: 50 / 50 [100%] (Sampling)Elapsed Time: 25.5386 seconds (Warm-up)28.9616 seconds (Sampling)54.5001 seconds (Total)The following numerical problems occured the indicated number of times after warmup on chain 1countException thrown at line 19: normal_log: Scale parameter is 0, but must be > 0! 3When a numerical problem occurs, the Hamiltonian proposal gets rejected.If the number in the 'count' column is small, do not ask about this message on stan-users.Could anyone help me with this problem? I think there might be something wrong with the prior.Thank you.
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+unsubscribe@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.