On 3/23/13 8:44 AM, M.F. Jonker wrote:
> It took a while but I completed a simple version of my model. It works well (see the attached code and data) but I do
> have several questions about the code. Can I ask them on the forum?
Ask away...
> a) it appears that print commands in the "generated quantities" section still do not work; is this correct?
> I'd like to use them for debugging and for printing a few key parameters during estimation.
They should work in version 1.2.0.
> b) the compiled command-line print.exe sometimes crashes when I try to print the samples.csv. I don't use R, so this
> function is GREAT! I can attach one of the problematic files?
Yes, please send us something that crashes.
> c) my pilot model currently uses a subset of ~600 respondents; even without respondent-specific beta parameters, there
> are ~1,200 parameters that need not be monitored (i.e. the s[] and s_star[] parameters). With respondent-specific
> parameters, there are ~ 14,000 parameters that need not be monitored. And with a real-life dataset with many more
> respondents, even many many more. So, is a new STAN feature that allows several parameters to be excluded from the
> samples.csv output a possibility? I've briefly mentioned this before, apologies for the duplication.
As I believe we've replied before, we're reluctant to do this
because of the implications for convergence monitoring.
> d) using an array in the likelihood declaration does not work (yet)?
> e) I've tried to replace the poisson with a categorical distribution. In BUGS this is coded as follows:
>
> for (n in 1:N){
> for (t in 1:T){
> Y[n,t] ~ dcat(prob[n, t, 1:A])
> }}
>
> I've tried several options,
You can use
Y[n,t] ~ categorical(prob[n,t]);
in Stan.
but always got an error in the calculation of the probabilities when I initialized them as:
> vector[A] prob[N,T], which is -I think- the required form(?). A suggestion would be much appreciated!
You want a simplex if it's categorical probability.
Stan requires the constraints to be specified. So that's
simplex[A] prob[N,T];
I'd stay away from using variables named "prob" in a model!
> f) the multiplication of s[n] and beta[] is not fully identified, hence the mean-of-1 constraint on the s[n]. I don't
> understand, however, why the posterior mean of the s_star[n] are so much smaller than 1. Did I specify the constraint on
> mu_s incorrectly, or perhaps any other idea why?
I don't think the following does what you intend:
parameters {
...
vector[N] s_star;
}
transformed parameters{
vector[N] s;
s <- s_star/mean(s_star);
}
model {
...
s_star ~ lognormal(-0.5 * square(sigma_s) , sigma_s);
First, you probably want a prior on sigma_s -- it's unbounded here.
I'd then expect sigma_s to go to zero anyway given the way you
set up the sampling distribution on s_star. But what you really
want is something like a prior on the transformed parameter. But
to do that you'll need to adjust for the Jacobian.
Or find some other way to identify the model.
- Bob