We're shuttering this list and moving to:
http://discourse.mc-stan.org
I'm surprised the revised model is three times slower. Did you do runs
from the same initial points or do multiple runs to collect average timings?
To speed up both of your models, there are a lot of things that can
vectorized. Most importantly this:
> for (i in 1:datp){ // likelihood for each data point
> mu = (beta_mu[1] + betas0[subID[i]])*x[i,1] + (beta_mu[2] + betas1[subID[i]])*x[i,2];
> y[i] ~ lognormal(mu,sigma_e); // the '~' means rt is distributed according to a lognormal distribution, with mean mu and standard deviation sigma_e
> }
can be
y ~ lognormal((beta_mu[1] + betas0[subId]) .* x[, 1]
+ (beta_mu[2] + betas1[subID]) .* x[, 2]),
sigma_e);
You could make this even more efficient by packing everything up into
matrices, but that's probably not worth it. This will get most of the
efficiency gain to be had.
Did you mean to leave out a global intercept? It can be hard to fit
a lot of models without it.
In the second model, are you sure this is right:
> for (i in 1:datp){ // likelihood for each data point
> mu=to_vector(betas[:,subID[i]])'*x[i]';
> y[i] ~ lognormal(mu,sigma_e);
> }
The way you have it, mu is going to be a vector, but y[i] is just a scalar,
so it'll be equivalent to PROD_n y[i] ~ lognormal(mu[n], sigma_e), which
is probably not what you want.
- Bob
> // Run the regressionA
> for (i in 1:datp){ // likelihood for each data point
> mu=to_vector(betas[:,subID[i]])'*x[i]';
> y[i] ~ lognormal(mu,sigma_e);
> }
> }
>
>
> --
> 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.
> <ranIntSlopeSubjMyInp.stan><GenericRegressionRT2levelsReparam.stan><temp.data.R>