Data distribution defined via change of variable

Hello all, I have the following non-standard model that involves change of variables. Any advice/suggested references would be greatly appreciated.

I have a K by 1 real vectors y_i defined as

y_i = f(theta, e_i), i=1,…,n

where

  • theta is a real vector of parameters for which a prior is given
  • e_i is a K by 1 real vector of unobservable whose distribution is known: e_i ~ p(e) e.g. independent normals
  • the known function f is one-to-one between e_i and y_i for all values of theta

Via the change of variable, the density of y_i is implied for a fixed theta. The goal is to simulate from the posterior of theta given y_1,…,y_n.

Q1: What would be the most natural way to code the set-up in Stan?
Q2: Would it be necessary to manually code the Jacobian that shows up in the change of variable formula?

Thanks!