On Wed, 2010-07-14 at 18:15 +0200, Tamas Papp wrote:
> Hi,
>
> I am doing inference for a model where the change in log wage, dw, is
> normally distributed conditional on individual-specific covariates (eg
> age, education) and the date of the observation. I am still in the
> stage of exploring the model, now it is assumed that each year has its
> own means and variances common for all observation in that year, that
> depend linearly on the unemployment rate for that year (avg.u) and its
> first difference (d.avg.u), plus some noise.
>
> I am using JAGS, and the model spec looks like this:
>
> model {
> ## first level - common means and variances by year
> for (j in 1:N.years) {
> ## common mean for each year
> mu[j] <- a.mu+b.mu*avg.u[j]+b.d.mu*d.avg.u[j]
> eta[j] ~ dnorm(0,sigma.mu^-2);
> ## common (log) standard deviation for each year
> log.sigma.mu[j] <- a.sigma+b.sigma*avg.u[j]+b.d.sigma*d.avg.u[j]
> log.sigma.eta[j] ~ dnorm(0,sigma.log.sigma^-2);
> }
> ## second level - means
> for (i in 1:N) {
> dw[i] ~ dnorm(mu[year[i]]+eta[year[i]]+b.age*age[i]+b.edu*edu[i],
> exp(-2*(log.sigma.mu[year[i]]+log.sigma.eta[year[i]])));
> }
> ## priors - first level
> a.mu ~ dnorm(0,1e-4);
> b.mu ~ dnorm(0,1e-4);
> b.d.mu ~ dnorm(0,1e-4);
> sigma.mu ~ dunif(0,100);
> a.sigma ~ dnorm(0,1e-4);
> b.sigma ~ dnorm(0,1e-4);
> b.d.sigma ~ dnorm(0,1e-4);
> sigma.log.sigma ~ dunif(0,100);
> ## priors - second level
> b.age ~ dnorm(0,1e-4);
> b.edu ~ dnorm(0,1e-4);
> }
>
> Regarding the size of the problem: N.years is around 25, while N is
> about 23 thousand.
>
> I am calling JAGS from R, using rjags. The setup stage (jags.model)
> literally takes hours (Graph Size: 206009), but the sampling stage
> (coda.samples) is comparatively fast.
>
> I am looking for help regarding the following:
>
> 1. I have read that JAGS has a GLM module. I have loaded it, but I am
> wondering how to best take advantage of it. Is it automatic, or
> should I restructure the model in a specific way?
If you load the glm model then you should get block updating of fixed
and random effects, which - in most cases - gives a considerable
improvement to the mixing of the chain. (It also means that you do not
have to rely on tricks like centering the covariates to improve mixing)
You may still get poor mixing of the variance components but I am
currently working on this.
> 2. Is there any way I can speed up jags.model? Why is it taking such
> a long time? Would I gain anything by calling it from the command line?
The bottleneck is probably in the choice of samplers. If you can send me
your model, data, and initial values then I can use it to find the part
of the program that is currently causing the problem and fix it.
> 3. Am I stretching the limit of JAGS/BUGS/automated Gibbs with this
> many observations?
No, not really. Large problems tend to highlight programming bottlenecks
that are not evident in smaller problems, but they are all fixable.
> The alternative, I guess, is to program the Gibbs
> sampler manually.
M
> Thanks,
>
> Tamas
-----------------------------------------------------------------------
This message and its attachments are strictly confidential. If you are
not the intended recipient of this message, please immediately notify
the sender and delete it. Since its integrity cannot be guaranteed,
its content cannot involve the sender's responsibility. Any misuse,
any disclosure or publication of its content, either whole or partial,
is prohibited, exception made of formally approved use
-----------------------------------------------------------------------
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|