-
-
Notifications
You must be signed in to change notification settings - Fork 66
Add num_steps_per_season parameter in TimeSeasonality #509
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome start! You have exactly the right idea. I think we can be a bit more clever with the math is all.
For the actual implementation, I don't think we can do anything clever -- we'll need to expand the transition matrix to s * d
and repeat the rows (and also repeat the starting values). The replicates should all be from the same symbolic value, so the user still just provides s
inputs.
.. math:: | ||
\underbrace{\gamma_0, \gamma_0, \ldots, \gamma_0}_{r\ \text{times}}, | ||
\underbrace{\gamma_1, \gamma_1, \ldots, \gamma_1}_{r\ \text{times}}, | ||
\ldots, | ||
\underbrace{\gamma_{s-1}, \gamma_{s-1}, \ldots, \gamma_{s-1}}_{r\ \text{times}}, | ||
\ldots, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, but this can be written more nicely using a floor operator on the index:
$
\gamma_t = -\sum_{i=1}^{s-1} \gamma_{\left\lfloor \frac{t}{d} \right\rfloor - i} + \omega_{\left\lfloor \frac{t}{d} \right\rfloor}, \quad \omega_j \sim \mathcal{N}(0, \sigma_\gamma)
$
I suggest to use d
for "duration" instead of r
for the number of steps, but I'm fine with being overruled if you have a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jessegrabowski Thanks. I used the floor operator, though I preferred to split the definition using gamma and \tilde{gamma}. Anyway, we can discuss about it when i formally open a PR.
More importantly, may I ask you if you would expect this line
k_states = season_length - int(self.remove_first_state)
to change to
k_states = season_length*duration - int(self.remove_first_state)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this needs to be adjusted. I believe it should be (season_length - int(self.remove_first_state)) * duration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the correction.
To give interpretation to the :math:`\gamma` terms, it is helpful to work through the algebra for a simple | ||
example. Let :math:`s=4`, and omit the shock term. Define initial conditions :math:`\gamma_0, \gamma_{-1}, | ||
example. Let :math:`s=4`, :math:`r=1`, and omit the shock term. Define initial conditions :math:`\gamma_0, \gamma_{-1}, | ||
\gamma_{-2}`. The value of the seasonal component for the first 5 timesteps will be: | ||
|
||
.. math:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update this block with a second example that has s=3
and d=2
. Show that the floor math works out and you get the expected pattern.
No description provided.