inc2prev icon indicating copy to clipboard operation
inc2prev copied to clipboard

simple-example

Open jonathonmellor opened this issue 7 months ago • 3 comments

Hello,

I've been exploring this package to perform sensitivity on an approximation I've done for a paper, requested by a reviewer.

I thought the best place to start would be to run the scripts/simple-example.R before trying to do the plumbing to get my data working with the model.

Unfortunately, when trying to run the simple-example the data is read in fine, model compiles, but fails on the MCMC. I'm using the most up-to-date cran versions of packages up to August 2025.

Below is the error I get. I'm not familiar with the internals of the model so hesitant to touch the stan side.

Image

Any thoughts welcome - I appreciate this isn't an actively developed package at the moment. I may need to perform sensitivity with an alternative method.

jonathonmellor avatar Sep 09 '25 13:09 jonathonmellor

Hi @jonathonmellor,

Sorry about that. You are right that its been a hot minute since anyone worked on this. It was recently used here to compare to another method so in principle what you are aiming to do should be doable (https://www.medrxiv.org/content/10.1101/2025.04.16.25325936v2 - didn't love this paper FYI but the principle of comparing to another method seems like a good one)

Since we wrote this I think stan has changed how it accepts initialisations. It used to be the case that you could pass things at initialisation that weren't used in the model and now that causes an error (that is my read of what above is saying). We used to do this as it made it easier to make modules easier so I can also see how that might be the problem.

The fix is either to just pass the variables as inits that are actually used or to fall back to an earlier version of stan (annoying).

When I get a minute (some time this week) I should be able to update this code to see if this is the problem.

seabbs avatar Sep 09 '25 14:09 seabbs

Having a quick dig I think it might be another change actually as sigma doesn't look like an optional parameter. I think you used to need to pass everything as an array i.e. with some dimension and now you don't

So

https://github.com/epiforecasts/inc2prev/blob/78e3d8717219c4238fb9dc971405d0562695a6f3/R/model.R#L239

is wrapped in an array but in the model it is not

https://github.com/epiforecasts/inc2prev/blob/78e3d8717219c4238fb9dc971405d0562695a6f3/stan/inc2prev.stan#L74

As I said when I get a chance will try running this to unpick it.

seabbs avatar Sep 09 '25 14:09 seabbs

Thanks @seabbs!

I've currently gone for an approximation using the Richardson-Lucy deconvolution as a sensitivity check but would be great to do this one as well.

I'll have a read of that paper - v relevant

jonathonmellor avatar Sep 09 '25 14:09 jonathonmellor