Dear stan users and developers:

I have some problems recovering the ‘known’ parameter values from my proposed model.

My model is a 2-component mixture model where the mixing weights are time-dependent and I model it as an AR(1) process on eta[t] = log(lambda[t] / (1-lambda[t]) and lambda[t] is the mixing weights at time t.

eta[1] = 0

eta[2:TT] = normal( rho * eta[1:(TT-1)], 0.05).

the data y_it ~ lambda[t] * N(mu_t + d_1t, sigma[1] ) + (1-lambda[t]) * N(mu_t + d_2t, sigma[2])

I impose a constraint on the overall mean E(y_it ) = lambda[t] *(mu_t+d_1t) + (1-lambda[t]) * (mu_t + d_2t) = mu_t .

In other words, lambda[t] *d_1t + (1-lambda[t]) * d_2t = 0

mu_t are modeled as B-spline with a cyclic b-spline basis function and b-spline coefficients.

d_1t and d_2t are mixture component deviations and due to the constraint imposed above,

d_2t is modeled as a deterministic term

d_2t = lambda_t /(1-lambda{t) * (-d_1t)

To ensure components are identifiable, I let d_2t > d_1t for all time periods in other words,

d_1t <0 and impose an upper =0 constraint.

The prior on d_1t is another AR(1) process similar to the one imposed on the logit of mixing weights.

I simulate some data from this proposed model and use the data to fit the model,

however, 95% CI does not capture all the parameters.

I suspect it got something to do with the lambda estimation and then I refit the model supplied ‘true’ lambda values and then estimate the rest of the parameters and in this case, all the parameters are well-estimated.

Next, I supply ‘true’ values of all the other parameters and just to estimate eta_t and thus lambda_t, but the model still fails to recover the parameter values.

I know it must be something wrong with my eta_t set up, however, I am kind of lost in where to debug and hoping to gain some insights. Can some one please suggest where the model can potentially go wrong?

I have attached my model and also the simulated data below, thanks in advance.

I also uploaded a graph which illustrates my model, the black line is the underlying overall mean of the 2-component mixture model which is modeled by cyclic b-spline,

the two red lines are mixture component locations and the distance between the red and the black lines are d_1t and d_2t modeled as described above

the mixing weights lambda_t is modeled as inverse_logit eta[t] and follows an AR(1) process

time_varying_mixture_model.r (1.5 KB)

bspline basis construction function.r (3.8 KB)

state_space_true_classical.stan (4.2 KB)the_model.pdf (18.8 KB)

Since, I suspect lambda_t is not estimated well and thus causes overall failure of the model to recover the other parameters.

I changed lambda_t to be just time-independent and simulate from Beta(5,5) distribution

and then in my model I lose AR(1) on eta_t and just estimate lambda directly with prior distribution beta(5,5) -same as I simulated the ‘truth’ and generate the fake data and fit into the model.

This time, surprisingly, all parameters are well-estimated. It seems that I cannot use AR(1) structure on lambda_t, but I would like to model mixing weights are time-dependent as indicated in my real data, can someone please suggest some alternative way of modeling time-dependent mixing weights or my previous AR(1) structure is appropriate but I just have not implemented correctly in Rstan.

Thanks