> On Jun 7, 2016, at 11:34 AM, Mike Lawrence <
mike....@gmail.com> wrote:
>
> Several issues:
>
> - You'll need to explain your data. I don't understand what you're doing with NA data. It looks like you're only ever asserting sampling when the data is not NA, in which case there's no need to include the NA cases in the first place. Including NA data is usually done when you want to use the non-NA data to infer what the NA data might have been.
I also couldn't follow this.
> - I also suspect you might be able to get a speedup by using a non-centered parameterization on paramP and paramQ and thereby avoiding looping over them to assert the sampling of their rows individually and instead simply asserting to_vector(paramP_raw) ~ normal(0,1), etc.
If there's not a lot of data, non-centering is a win.
The "centering" in question is of both the mean and the log scale
around zero.
>
> - why are you using inv_sqrt(0.001) in the specification of the scale for the normal priors on muP & muQ? Why not just put 30? (Stan gurus: if 30ish is indeed desired as the scale of these priors, should we furthermore expect improved efficiency from a non-centered parameterization where, for example, muP_raw is defined as normal(0,1) and muP is defined in the transformed parameters section as muP_raw*30 ?
Yes, because then muP_raw, which is what's actually being sampled, is
on the unit scale, so we don't have to estimate that scale during
warmup. So warmup should go faster and be more accurate.
> - You are computing diag_pre_multiply(sigmaP,L_OmegaP) for every iteration of the outter loop over 1:P, and, worse, computing diag_pre_multiply(sigmaQ,L_OmegaQ) on every inner loop over 1:Q. You should just compute both once, storing the result to a variable that is then referenced inside the loops.
What you really need to do is vectorize these. That way, even the
Cholesky factor is only factored once.
> - You also might try to move all computations you can to the transformed parameters block. For example, here's your code in a cleaned-up format (please try to use consistent spacing)
+1 on consistent spacing (and no tabs!).
> with those cholesky-decomposed covariance matrices computed in the transformed parameters block:
Computing in the transformed parameters block saves the parameters
in the output, so only define there if you want to save. Otherwise,
you can use a local variable in the model block. Either way, it's
better to just vectorize. Then you can just write the expression directly
inside the call to the density.
- Bob
> --
> 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.