Mice Example from WinBUGS

277 views
Skip to first unread message

Cody Ross

unread,
Apr 16, 2015, 4:13:30 PM4/16/15
to stan-...@googlegroups.com

I am about to submit revisions on a paper, and after reading through my methods section again (after a long while of not working on this project), I realized (to my horror) that I no longer really understand a critical line in my model code. This issue comes from the Stan version of the WinBUGS Mice model. The model lines are pasted below. I understand what is going on in the first 'for' loop (this is the observed age of death loop), but the second loop I don't understand very well. t2_censored is a missing data parameter, and censor_time is the observed age of censoring, but why do we divide the second argument of the Weibull by the time of censoring? Should t2_censored be understood as an estimated age of death, or estimated time lived passed the censoring threshold?

My intuition is that this goes back to an old thread about allowing for variable 'time of censoring' constraints in the model, but I'm not quite sure of how this creates such behavior.

model {
  r
~ exponential(0.001);
  beta
~ normal(0, 100);
 
for (n in 1:N_uncensored) {
    t_uncensored
[n] ~ weibull(r, exp(-beta[group_uncensored[n]] / r));
                           
}
   
for (n in 1:N_censored) {
    t2_censored
[n] ~ weibull(r, exp(-beta[group_censored[n]] / r) / censor_time[n]);
                         
}
}




Bob Carpenter

unread,
Apr 17, 2015, 6:42:04 AM4/17/15
to stan-...@googlegroups.com
Hmm. I don't understand the mice.bug example, either.
Here's the JAGS code so someone may help decode --- I
can't recall how dinterval() works in JAGS.

model {
for(i in 1:N) {
is.censored[i] ~ dinterval(t[i], last.t[i]);
t[i] ~ dweib(r,mu[i]);

mu[i] <- exp(beta[group[i]]); # relative risk model
}
for(j in 1:M) {
beta[j] ~ dnorm(0.0, 0.0001); # prior
median[j] <- pow(log(2) * # median survival
exp(-beta[j]), 1/r);
}
r ~ dgamma(1.0,0.0001); # slowly decreasing on +ve reals

irr.control <- beta[1]; # change
veh.control <- beta[2]-beta[1]; # parameterisation
test.sub <- beta[3]-beta[1];
pos.control <- beta[4]-beta[1];
}

- 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.
> For more options, visit https://groups.google.com/d/optout.

Jiqiang Guo

unread,
Apr 17, 2015, 2:53:47 PM4/17/15
to stan-...@googlegroups.com
Note t2_censored has lower bound 1, so essentially t_censored (imagine we have it) has the lower bound being the censor times.  This is a workaround for stan's inability to support different lower bounds for a vector.

Jiqiang 

Cody Ross

unread,
Apr 22, 2015, 4:06:41 PM4/22/15
to stan-...@googlegroups.com

Jiqiang,

Ok, that is what I expected regarding the constraints, but why do we divide the second argument of the Weibull by the time of censoring? What does this do exactly? Should t2_censored be understood as an estimated age of death, or estimated time lived passed the censoring threshold?

Jiqiang Guo

unread,
Apr 23, 2015, 9:25:29 PM4/23/15
to stan-...@googlegroups.com
If we were able to specify a vector lower bound in stan, we would have

 t_censored[n] ~ weibull(r, exp(-beta[group_censored[n]] / r));

where t_censored are parameters and are defined as

real<lower=censor_time> t_censored.

But we cannot do the above, so a t2_censored is defined with lower bound 1.  Essentially,
t2_censored = t_censored / censor_time


Then the distribution of t2_censored needs to be derived from the distribution of t_censored and that is why the second argument of the weibull distribution is divided by censor_time.


Jiqiang  

On Wed, Apr 22, 2015 at 4:06 PM, Cody Ross <ctr...@ucdavis.edu> wrote:

Jiqiang,

Ok, that is what I expected regarding the constraints, but why do we divide the second argument of the Weibull by the time of censoring? What does this do exactly? Should t2_censored be understood as an estimated age of death, or estimated time lived passed the censoring threshold?

--

Cody Ross

unread,
Oct 13, 2015, 11:00:32 PM10/13/15
to Stan users mailing list
Sorry to bring this thread up again, but why do we have:
the r parameter showing up in both parameter slots in weibull_log? here:

t_uncensored[n] ~ weibull(r, exp(-beta[group_uncensored[n]] / r));

 I mean, why do we divide by r in the second slot? This doesn't seem to make sense when I compare the Stan model with the Bugs model and the PDF from wikipedia.

Bob Carpenter

unread,
Oct 14, 2015, 5:34:16 PM10/14/15
to stan-...@googlegroups.com
Wasn't that the same question Jiqiang answered last time? I'm appending
his original response, which hopefully has the clues you need to sort
it out.

- Bob

From Jiqiang:
---------------
If we were able to specify a vector lower bound in stan, we would have

t_censored[n] ~ weibull(r, exp(-beta[group_censored[n]] / r));

where t_censored are parameters and are defined as

real<lower=censor_time> t_censored.

But we cannot do the above, so a t2_censored is defined with lower bound 1. Essentially,
t2_censored = t_censored / censor_time

Then the distribution of t2_censored needs to be derived from the distribution of t_censored and that is why the second argument of the weibull distribution is divided by censor_time.
----------------------

Cody Ross

unread,
Oct 14, 2015, 5:45:05 PM10/14/15
to Stan users mailing list
Bob,

No,

I think Jiqiang answered why we divide by age of censoring in the censored model.

I am now wondering about why we divide by 'r'

Jiqiang Guo

unread,
Oct 14, 2015, 6:54:42 PM10/14/15
to stan-...@googlegroups.com
It's just because Stan and BUGS use different parameterization.  

--
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.

Tohid Jafari Koshki

unread,
Jul 7, 2016, 10:47:24 AM7/7/16
to Stan users mailing list
Exactly. We usually model lambda=exp(XB) but this lambda is not the scale sigma of the Weibull. In fact, lambda=1/(sigma^shape). Hence we have sigma of stan as sigma= exp(_XB/shape).

Tohid Jafari Koshki

unread,
Jul 7, 2016, 10:59:26 AM7/7/16
to Stan users mailing list
I really apologize, but I did not understand hot it works. This way scale parameter is bounded at zero. Because the numerator is >0 and the denominator is also >0. Then the scale is >0 not 1. Could you please help me on this. I really need this help.

Tohid Jafari Koshki

unread,
Jul 7, 2016, 1:32:46 PM7/7/16
to Stan users mailing list
Why not able to use Weibull lccdf for censored data? Isn't it possible to do similar to page 112 of manual 2.10? Isn't is possible to use multiple lower bound for each censored observation?


On Friday, April 24, 2015 at 5:55:29 AM UTC+4:30, Jiqiang Guo wrote:

Bob Carpenter

unread,
Jul 7, 2016, 3:41:22 PM7/7/16
to stan-...@googlegroups.com

> On Jul 7, 2016, at 1:32 PM, Tohid Jafari Koshki <tjko...@gmail.com> wrote:
>
> Why not able to use Weibull lccdf for censored data? Isn't it possible to do similar to page 112 of manual 2.10? Isn't is possible to use multiple lower bound for each censored observation?

It is, you just can't vectorize it easily.

- Bob

Tohid Jafari Koshki

unread,
Jul 10, 2016, 3:43:55 AM7/10/16
to Stan users mailing list
You mean this way t2_censored is >censor_time. Why? Can adjusting the second argument modify the threshold of the variable? 


On Friday, April 24, 2015 at 5:55:29 AM UTC+4:30, Jiqiang Guo wrote:
Reply all
Reply to author
Forward
0 new messages