Skip to content

Commit

Permalink
fix AR process
Browse files Browse the repository at this point in the history
  • Loading branch information
damonbayer committed Jul 30, 2024
1 parent a73a85f commit a162235
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo_hosp_only_ww_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def convert_to_logmean_log_sd(mean, sd):

autoreg_p_hosp_a = stan_data["autoreg_p_hosp_a"][0]
autoreg_p_hosp_b = stan_data["autoreg_p_hosp_b"][0]
autoreg_p_hosp_rv = DeterministicVariable(
autoreg_p_hosp_rv = DistributionalRV(
"autoreg_p_hosp", dist.Beta(autoreg_p_hosp_a, autoreg_p_hosp_b)
)

Expand Down
19 changes: 14 additions & 5 deletions model/src/pyrenew/model/hosp_only_ww_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,22 @@ def sample(self): # numpydoc ignore=GL08

eta_sd = self.eta_sd_rv()[0].value

Check warning on line 78 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L78

Added line #L78 was not covered by tests

autoreg_rt = self.autoreg_rt_rv()[0].value
autoreg_rt_det_rv = DeterministicVariable("autoreg_rt_det", autoreg_rt)

Check warning on line 81 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L80-L81

Added lines #L80 - L81 were not covered by tests

log_r_mu_intercept = self.log_r_mu_intercept_rv()[0].value

Check warning on line 83 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L83

Added line #L83 was not covered by tests

init_rate_of_change_rv = DistributionalRV(

Check warning on line 85 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L85

Added line #L85 was not covered by tests
"init_rate_of_change", dist.Normal(0, eta_sd)
"init_rate_of_change",
dist.Normal(0, eta_sd / jnp.sqrt(1 - jnp.pow(autoreg_rt, 2))),
)

init_rate_of_change = init_rate_of_change_rv()[0].value

Check warning on line 90 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L90

Added line #L90 was not covered by tests
log_r_mu_intercept = self.log_r_mu_intercept_rv()[0].value

rt_proc = RtWeeklyDiffProcess(

Check warning on line 92 in model/src/pyrenew/model/hosp_only_ww_model.py

View check run for this annotation

Codecov / codecov/patch

model/src/pyrenew/model/hosp_only_ww_model.py#L92

Added line #L92 was not covered by tests
name="rtu_weekly_diff",
offset=0,
log_rt_prior=DeterministicVariable(
log_rt_rv=DeterministicVariable(
name="log_rt",
value=jnp.array(
[
Expand All @@ -96,8 +101,8 @@ def sample(self): # numpydoc ignore=GL08
]
),
),
autoreg=self.autoreg_rt_rv,
periodic_diff_sd=DeterministicVariable(
autoreg_rv=autoreg_rt_det_rv,
periodic_diff_sd_rv=DeterministicVariable(
name="periodic_diff_sd", value=jnp.array(eta_sd)
),
)
Expand All @@ -111,6 +116,10 @@ def sample(self): # numpydoc ignore=GL08
gen_int=generation_interval_pmf[0].value,
)

# p_hosp_ar = ARProcess("p_hosp", mean=x, autoreg=[x, y], noise_sd=z)

# Now expand it to daily?

# infection_hosp_rate, *_ = self.infect_hosp_rate_rv(**kwargs)

# infection_hosp_rate_t = infection_hosp_rate.value * latent_infections
Expand Down

0 comments on commit a162235

Please sign in to comment.