Skip to content

Adds support for passing initial value to transform #2038

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tingiskhan
Copy link

Changes made

Added support for passing a parameter called initial_value to RecursiveLinearTransform to facilitate forecasting when using the transform for latent variables.

Links to related PRs

#2037

Tests

I added one test case to the "general" part, and parameterized test_batched_recursive_linear_transform for testing arbitrary initial values.

Dependencies

No new dependencies introduced.

@tillahoffmann
Copy link
Collaborator

Thank you for the contribution, @tingiskhan! Do you think this could also be achieved using a composition of an AffineTransform and RecursiveLinearTransform?

@tingiskhan
Copy link
Author

Thank you for the contribution, @tingiskhan! Do you think this could also be achieved using a composition of an AffineTransform and RecursiveLinearTransform?

That’s a very good point, I’ll take a look at it next week (if you don’t beat me to it)!

@tingiskhan
Copy link
Author

tingiskhan commented Jun 20, 2025

@tillahoffmann So, I've given it some thought and see three ways forward (there might be more):

  1. Keep as is (i.e. pass initial value to RecursiveLinearTransform).
  2. Use a composition of AffineTransform and original RecursiveLinearTransform (as you suggested). The "issue" I see with this method is that we'll need to pass the length of the "series" on __init__ in order to construct the "loc" variable of AffineTransform correctly: loc * jnp.eye((length, 1)) (where loc corresponds to initial value). This would break the design of transforms a bit I think, since the transform will require the shape of sample on init.
  3. Construct a derived class from AffineTransform that only takes the initial value as input (corresponding to loc and pass 1 to scale) and then in __call__/_inverse handle the building of the offset given the sample (same as in 2.).

Of these three I think either 1. or 3. is the most appropriate. I'm not sure how re-usable the new component of 3. would be, but I'm open to either suggestions.

I'm not sure this PR is even needed to be honest, but the current way of passing initial values other than 0 is not so clear (might just require an entry to the docs?).

@fehiepsi
Copy link
Member

If initial value is 0, we have y_1=x_1, so we can just prepend the initial value to x and y?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants