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

Update time_var to incorporate default value #196

Open
jfree-man opened this issue Apr 15, 2024 · 0 comments
Open

Update time_var to incorporate default value #196

jfree-man opened this issue Apr 15, 2024 · 0 comments
Assignees

Comments

@jfree-man
Copy link
Collaborator

Update time_var to incorporate the default value of the parameter when change_points[1] > 0. After this change has been made, update the 'Specifying Time-Varying Parameters' vignette here.

> # defaults
> beta_default = 0.2
> beta_changepoints = c(0, 5, 10)
> beta_values = c(0.7, 0.01, 0.4)
> expr = list(
+   beta ~ time_var(beta_values, beta_changepoints)
+ )
> # this works as expected
> simple_sims(
+     iteration_exprs = expr
+   , time_steps = 10
+   , int_vecs = list(beta_changepoints = beta_changepoints)
+   , mats = list(
+       beta = beta_default
+     , beta_values = beta_values)
+   
+ ) |> filter(matrix == "beta")
   matrix time row col value
1    beta    1   0   0  0.70
2    beta    2   0   0  0.70
3    beta    3   0   0  0.70
4    beta    4   0   0  0.70
5    beta    5   0   0  0.01
6    beta    6   0   0  0.01
7    beta    7   0   0  0.01
8    beta    8   0   0  0.01
9    beta    9   0   0  0.01
10   beta   10   0   0  0.40
> # if change_points[1] != 0, we get nonsensical behaviour
> beta_changepoints = c(2, 5, 10)
> simple_sims(
+     iteration_exprs = expr
+   , time_steps = 10
+   , int_vecs = list(beta_changepoints = beta_changepoints)
+   , mats = list(
+       beta = beta_default
+     , beta_values = beta_values)
+   
+ ) |> filter(matrix == "beta")
   matrix time row col value
1    beta    1   0   0   0.4
2    beta    2   0   0   0.4
3    beta    3   0   0   0.4
4    beta    4   0   0   0.4
5    beta    5   0   0   0.4
6    beta    6   0   0   0.4
7    beta    7   0   0   0.4
8    beta    8   0   0   0.4
9    beta    9   0   0   0.4
10   beta   10   0   0   0.4
> # what we want to happen automatically
> simple_sims(
+     iteration_exprs = expr
+   , time_steps = 10
+   , int_vecs = list(beta_changepoints = c(0,beta_changepoints))
+   , mats = list(
+       beta = beta_default
+     , beta_values = c(beta_default,beta_values))
+   
+ ) |> filter(matrix == "beta")
   matrix time row col value
1    beta    1   0   0  0.20
2    beta    2   0   0  0.70
3    beta    3   0   0  0.70
4    beta    4   0   0  0.70
5    beta    5   0   0  0.01
6    beta    6   0   0  0.01
7    beta    7   0   0  0.01
8    beta    8   0   0  0.01
9    beta    9   0   0  0.01
10   beta   10   0   0  0.40
@stevencarlislewalker stevencarlislewalker self-assigned this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔖 Ready
Development

No branches or pull requests

2 participants