Skip to content

Is Stan's affine transform type <offset, multiplier> restricted to scalars? #870

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
mitzimorris opened this issue Apr 2, 2025 · 1 comment · May be fixed by #872
Open

Is Stan's affine transform type <offset, multiplier> restricted to scalars? #870

mitzimorris opened this issue Apr 2, 2025 · 1 comment · May be fixed by #872
Labels
question Further information is requested

Comments

@mitzimorris
Copy link
Member

mitzimorris commented Apr 2, 2025

The Stan Reference Manual has sections: "Affinely Transformed Scalar" - https://mc-stan.org/docs/reference-manual/transforms.html#affinely-transformed-scalar and https://mc-stan.org/docs/reference-manual/types.html#affine-transform.section

The following program compiles:

parameters {
  real<multiplier=3> y;
  vector<multiplier=exp(y/2)>[9] x;
}
model {
  y ~ std_normal();
  x ~ std_normal();
}

here x is a vector, not a scalar. scatter plots of x[1] vs x[2] etc look pretty normal...

Image

@mitzimorris mitzimorris added the question Further information is requested label Apr 2, 2025
@bob-carpenter
Copy link
Member

Yes, the transform is at the scalar level---it's just $\alpha + \beta \cdot x$ for scalar offset $\alpha$, scalar multiplier $\beta$, and scalar value $x$. This is in contrast to the multivariate affine transform, which we do not support. That is also $\alpha + \beta \cdot x$, but now $\alpha$ is a vector, $\beta$ is a matrix, and $x$ is a vector. We'd want to do the multivariate form to do a non-centered multivariate prior where we'd take the offset to the be a location and the multiplier to be a Cholesky factor of covariance.

Feel free to rewrite to make it clearer that it's a scalar operation that can be applied elementwise to a container of any shape.

@WardBrian WardBrian linked a pull request Apr 9, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants