Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Parameter matrix generated by stratifying certain model transitions are wrong #4305

Closed
liunelson opened this issue Jul 29, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@liunelson
Copy link
Member

liunelson commented Jul 29, 2024

We have this SEIRDH model where the infection-exposure process is S -> E controlled by I

\frac{d S}{d t} = - \beta S I
\frac{d E}{d t} = \beta S I - r_{EI} E
\frac{d I}{d t} = r_{EI} E - r_{IR} p_{IR} I - r_{IH} p_{IH} I
\frac{d H}{d t} = r_{IH} p_{IH} I - r_{HR} p_{HR} H - r_{HD} p_{HD} H
\frac{d R}{d t} = r_{IR} p_{IR} I + r_{HR} p_{HR} H
\frac{d D}{d t} = r_{HD} p_{HD} H

SEIRHD_base.json

When this model is stratified, we get this strange 2 x 4 transition matrix between S and E, wherein the S_u, S_v states appear on both the rows and columns. This doesn't sense.

  • The transitions t0_v_u and t0_u_v are misplaced since they do not have S_u, S_v as output states
  • If the rows are input states and the columns are output states, then t0_u_u and t0_u_v should be grouped; similarly for t0_v_v, t0_v_u (second index is for vax status of the I)
  • This is suboptimal since it'd have two entries per matrix element
  • Ideally, the column would use "hierarchical indexing" as in Pandas (https://pandas.pydata.org/docs/user_guide/advanced.html) where the first level is the output state combinations and the second level is the controller state combinations

Image
Image
Image

This bug changes when I toggle off the "Create new transitions between strata":

  • the transition matrix becomes 2 x 2 and the t0_u_u, t0_v_v transitions are no longer shown 👎

Image
Image

@github-actions github-actions bot added the bug Something isn't working label Jul 29, 2024
@liunelson
Copy link
Member Author

This is probably a bug that @mwdchang is most familiar?

@shawnyama
Copy link
Contributor

shawnyama commented Aug 2, 2024

After digging around I found that there are two templates of the same name generated by MIRA. These are the templates in the mmt:
miratemplates.json

Here are the ones that are the same in the above file
image

Looking at the expanded view in the model diagram also shows that those connections do exist. The first pair is an S-> E transition which isn't expected. The second pair is S -> S which is expected.

@shawnyama
Copy link
Contributor

shawnyama commented Aug 6, 2024

Model from equations: sierdh.json
Stratified model: sierdh_strat.json

@mwdchang
Copy link
Member

mwdchang commented Aug 6, 2024

The duplicated template names aren't handled in our collapseTemplates function, but more than that the resulting AMR has more than one expressions point at a singular target. I filed a ticket with MIRA:

gyorilab/mira#348

@mwdchang
Copy link
Member

mwdchang commented Aug 9, 2024

This seemed okay after the MIRA fix.

@mwdchang mwdchang closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants