Priesemann-Group/covid19_inference

Plotting: AssertionError: var should be in trace.varnames

Closed this issue · 6 comments

I meet a problem when I run "example_what_if.ipynb" using my own data. When I run fig, axes = cov19.plot.timeseries_overview(), An error displays: "AssertionError: var should be in trace.varnames". The error is as follow:
image
How to address the problem? Ask for help.

I dont know how your model looks but you do have to use our variable names if you want to use these high level plotting functions. As far as I remember the pymc3 name for the new cases has to be "new_cases" otherwise the timeseries_overview plotting will not work.

You could also change "new_cases" to your variable name here or here in the what if script.

I hope this helps you to understand your problem.

I use your SIR model and I don't change all default variable names.

Hmm this is quite strange than, I'm going to test it.

Oh! I know, I cancel the weekend modulation because I don't need the weekend modulation. When I add the line of code. It can run correctly.
image
However, We really don't need the weekend modulation for Chinese CDC. How to cancel the weekend modulation at the same time, assure the correct variable name "new_cases"?

I see 👍

You can just change the name in this line from "delayed_cases" to "new_cases" and it should work.

        new_cases = cov19.model.delay_cases(
            cases=new_cases,
            name_cases="delayed_cases",
            pr_mean_of_median=pr_delay,
            pr_median_of_width=0.3,
        )

Or add it manually to the trace with:

pm.Deterministic("new_cases",new_cases)

I see. Thank you very much!