rstanarm

104 views
Skip to first unread message

Krzysztof Sakrejda

unread,
Feb 10, 2016, 6:00:48 PM2/10/16
to stan development mailing list
Is there room in rstanarm for a Cormack-Jolly-Seber model Stan implementation? I have a pretty solid implementation from my dissertation that could include both CJS and other more complex mark-recapture data.

The simplest version of the interface would just be one formula for survival part of the model and one for recapture part, ideally implementing all the bells and whistles you have for GLMM's. It's something I'll be looking at getting into in April.

Krzysztof

Ben Goodrich

unread,
Feb 10, 2016, 8:10:20 PM2/10/16
to stan development mailing list

I'm not familiar with that model, but I don't see why not. Aki made a feature request to emulate survival::survreg, so I guess what you are proposing is an extension of that.

Ben

 

Krzysztof Sakrejda

unread,
Feb 10, 2016, 10:12:43 PM2/10/16
to stan development mailing list
On Wednesday, February 10, 2016 at 8:10:20 PM UTC-5, Ben Goodrich wrote:
> On Wednesday, February 10, 2016 at 6:00:48 PM UTC-5, Krzysztof Sakrejda wrote:Is there room in rstanarm for a Cormack-Jolly-Seber model Stan implementation?  I have a pretty solid implementation from my dissertation that could include both CJS and other more complex mark-recapture data.
> The simplest version of the interface would just be one formula for survival part of the model and one for recapture part, ideally implementing all the bells and whistles you have for GLMM's.  It's something I'll be looking at getting into in April.
> Krzysztof
>
> I'm not familiar with that model, but I don't see why not.

Sweet, clearly I'm not implementing anything yet but it's nice not to have to look forward to figuring out how to package another thing.

>Aki made a feature request to emulate survival::survreg, so I guess what you are proposing is an extension of that.

Ideally yes, but the only way I got that to work was with an event time parameter (so N more parameters) and even then the event time parameter has a step function shape on top of the survival distribution that you have to smooth out before you throw HMC at it. Computationally it's way more efficient as a sort-of discrete time survival model although I'd be excited to get a more solid continuous time implementation working.

Krzysztof

>
> Ben
>
>  

Michael Betancourt

unread,
Feb 11, 2016, 2:30:22 AM2/11/16
to stan...@googlegroups.com
Bob, Dan, and Franzi did a CJS implementation in Stan — not sure
what tricks they used for marginalization but it’s been used quite
successfully.
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Krzysztof Sakrejda

unread,
Feb 11, 2016, 3:51:22 AM2/11/16
to stan development mailing list
Is there code posted somewhere? I can never find this when I look for it?

Daniel Lee

unread,
Feb 11, 2016, 7:59:13 AM2/11/16
to stan...@googlegroups.com
Search is tough. Fortunately, I know where it is:

https://github.com/stan-dev/example-models/tree/master/misc/ecology/mark-recapture



> On Feb 11, 2016, at 3:51 AM, Krzysztof Sakrejda <krzysztof...@gmail.com> wrote:
>
> Is there code posted somewhere? I can never find this when I look for it?
>

Krzysztof Sakrejda

unread,
Feb 11, 2016, 9:03:23 AM2/11/16
to stan development mailing list
On Thursday, February 11, 2016 at 7:59:13 AM UTC-5, Daniel Lee wrote:
> Search is tough. Fortunately, I know where it is:
>
> https://github.com/stan-dev/example-models/tree/master/misc/ecology/mark-recapture

I see, thanks Daniel. The model I'm proposing incorporating differs because:

a) recapture/survival (or other event probabilities) can be specified by passing in a (sparse) model matrix, so we could borrow a lot of the other rstanarm parameterization machinery. In my case it made it easy to do efficient 3-D spline models.
b) individuals do not need to be recaptured at the same time for each occasion. In CJS it's often assumed that whenever there is a recapture occasion all the individuals are "at risk" for recapture for the same short period of time. Different datasets stretch this assumption to different extents and it's not really necessary.

The formulations that have this N (individuals) by K (occasions) parameterization are standard within the field but as far as I can tell they are a relic of the original estimators based on sufficient statistics. They're great if you really need to estimate a few survival parameters or test if parameters vary by occasion but there's no need to jam everything into that framework.

Krzysztof

Bob Carpenter

unread,
Feb 11, 2016, 11:03:08 AM2/11/16
to stan...@googlegroups.com
There's also a worked example in the manual chapter on
marginalizing latent discrete parameters.

- Bob

Bob Carpenter

unread,
Feb 11, 2016, 11:05:07 AM2/11/16
to stan...@googlegroups.com
Oh, and Fraenzi's book also has a logistic version with
predictors that models the population by individual.

- Bob

Krzysztof Sakrejda

unread,
Feb 11, 2016, 11:05:25 AM2/11/16
to stan development mailing list
On Thursday, February 11, 2016 at 11:03:08 AM UTC-5, Bob Carpenter wrote:
> There's also a worked example in the manual chapter on
> marginalizing latent discrete parameters.

That's implemented in both versions as far as I can tell. Krzysztof

Krzysztof Sakrejda

unread,
Feb 11, 2016, 11:39:26 AM2/11/16
to stan development mailing list
On Thursday, February 11, 2016 at 11:05:07 AM UTC-5, Bob Carpenter wrote:
> Oh, and Fraenzi's book also has a logistic version with
> predictors that models the population by individual.

I think it would be useful to have a version in rstanarm rather than in a book. Krzysztof

Bob Carpenter

unread,
Feb 11, 2016, 2:01:09 PM2/11/16
to stan...@googlegroups.com
Absolutely --- I didn't mean to suggest otherwise.

I just thought people were asking if there
were references or if someone had done it before.

- Bob

Krzysztof Sakrejda

unread,
Feb 11, 2016, 4:18:57 PM2/11/16
to stan development mailing list
On Thursday, February 11, 2016 at 2:01:09 PM UTC-5, Bob Carpenter wrote:
> Absolutely --- I didn't mean to suggest otherwise.
>
> I just thought people were asking if there
> were references or if someone had done it before.

Oops I see, sorry, I guess I am curious if you guys have implementations you think do belong in there but I think we can generalize a fair bit past CJS in a way that's going to be much more useful for ecologists w.r.t. experimental design. Krzysztof

Bob Carpenter

unread,
Feb 11, 2016, 4:34:08 PM2/11/16
to stan...@googlegroups.com
That's all I have other than Dorazio-Royle occupancy model
that's in example-models/knitr.

I don't have an opinion about what should go in RStanARM.

- Bob

Jonah Gabry

unread,
Feb 11, 2016, 11:52:15 PM2/11/16
to stan development mailing list
Hi Krzysztof, I'm not very familiar with the CJS model but if you think it will be useful for a lot people then I'm definitely open to including it in rstanarm. Is there anything in particular that you'd recommend I read familiarize myself with these models?

Krzysztof Sakrejda

unread,
Feb 12, 2016, 7:33:31 AM2/12/16
to stan development mailing list
On Thursday, February 11, 2016 at 11:52:15 PM UTC-5, Jonah Gabry wrote:
> Hi Krzysztof, I'm not very familiar with the CJS model but if you think it will be useful for a lot people then I'm definitely open to including it in rstanarm. Is there anything in particular that you'd recommend I read familiarize myself with these models?

It's a funny literature---or at least I think it's funny, some people take it very seriously, especially calling models by their right and true name. My touchstones for it are the original three papers (by Cormack, Jolly, and Seber, respectively) because they derive the sufficient statistics-based estimators that still have their mark on the current software implementations (e.g.-program MARK and a few others). They also state the problem pretty clearly. I just peeked at Jolly (1965) again and it gives a good sense of where this is all coming from. Then there was an extended "bells and whistles" period that's summarized nicely in Lebreton (1992), though I think a few features arrived afterwards. All that just deals with a two-state partially observed system. I think the next big touchstone is Kendall (2002) which (maybe?) is the original multi-state version of the model.

If you skim Jolly (1965), read Lebreton (1992), and assume you know what's in Kendall (2002) based on modern stats you end up with a decent sense of what the field is like. If you want the gory details of how all the intervening papers are related to each other and medical multi-state survival models I have a lit review in my dissertation... :)

Sorry, that's long. It's been a while since I had to think this through. If you want it to be easy I have the pdf's, just ask. I guess I'm not supposed to post them here...

Bob Carpenter

unread,
Feb 12, 2016, 11:37:10 AM2/12/16
to stan...@googlegroups.com
I really liked Matt 2's dissertation:

Schofield, M. R. (2007). Hierarchical Capture-Recapture Models.
PhD thesis, Depart- ment of of Statistics, University of Otago, Dunedin

He speaks our language and has a great literature review.
Or you could try Kery's book or one of the many other BUGS-based
intros to ecological modeling.

Ruth King also has a very nice review that puts things in
a general state-space framework:

http://rsfs.royalsocietypublishing.org/content/2/2/190

- Bob

Daniel Lee

unread,
Feb 12, 2016, 11:43:09 AM2/12/16
to stan-dev mailing list
+1 for Matt's dissertation.

Krzysztof Sakrejda

unread,
Feb 12, 2016, 1:31:46 PM2/12/16
to stan development mailing list
On Friday, February 12, 2016 at 11:37:10 AM UTC-5, Bob Carpenter wrote:
> I really liked Matt 2's dissertation:
>
> Schofield, M. R. (2007). Hierarchical Capture-Recapture Models.
> PhD thesis, Depart- ment of of Statistics, University of Otago, Dunedin
>
> He speaks our language and has a great literature review.
> Or you could try Kery's book or one of the many other BUGS-based
> intros to ecological modeling.
>
> Ruth King also has a very nice review that puts things in
> a general state-space framework:
>
> http://rsfs.royalsocietypublishing.org/content/2/2/190
>

It would be fun to talk about this at the next Stan meeting if the language issues don't take up the whole meeting.

Jonah Gabry

unread,
Feb 12, 2016, 2:12:40 PM2/12/16
to stan development mailing list
Thanks for all the suggestions. Anyone know where I can find Matt 2's dissertation? I've found a bunch of his other papers online but can't seem to track down his thesis.

Krzysztof Sakrejda

unread,
Feb 12, 2016, 2:27:09 PM2/12/16
to stan development mailing list
On Friday, February 12, 2016 at 2:12:40 PM UTC-5, Jonah Gabry wrote:
> Thanks for all the suggestions. Anyone know where I can find Matt 2's dissertation? I've found a bunch of his other papers online but can't seem to track down his thesis.

Turns out I have it too. Just sent it. K

Jonah Sol Gabry

unread,
Feb 12, 2016, 2:38:58 PM2/12/16
to stan...@googlegroups.com
Gracias


--
You received this message because you are subscribed to a topic in the Google Groups "stan development mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-dev/vuQiz5l6nkU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-dev+u...@googlegroups.com.

Bob Carpenter

unread,
Feb 12, 2016, 3:10:09 PM2/12/16
to stan...@googlegroups.com
Nope --- we're done with the language issues for the
time being and waiting on me to deliver the new prototype.
At which point, there'll be time to fiddle with exact
style. It's not that hard to do, but I'm a bit backed up
with grant proposals, updating the web site, then some
code review. That means I can't really start until end of
next week. But I don't think it'll take long.

- Bob
Message has been deleted

Ben Goodrich

unread,
Feb 14, 2016, 12:24:01 PM2/14/16
to stan development mailing list
We have up until this point based each stan_ function in rstanarm on an existing R function that is familiar to R users that are interested in that model. There will probably come a time where we want to include a model in rstanarm that has no predecessor, but I doubt that would be the case for a survival model. You probably are familiar with the packages in the Population Dynamics section of

https://cran.r-project.org/web/views/Environmetrics.html

so I would say to pick whichever one has the most appropriate syntax (presumably one with a formula and a data.frame). We have removed arguments from the original function that pertain to the estimation and have no analogue in Stan and have added arguments that pertain to priors and things like that.

There is also an incomplete wiki page

https://github.com/stan-dev/rstanarm/wiki/Adding-a-new-model-to-rstanarm

that hopefully will be finished before you start seriously working on adding your model.

Ben

Reply all
Reply to author
Forward
0 new messages