Can I put closed-form equation to "transformed parameters" block?


#1

Hello Stan professors, I’m Stan rookie.

According to the title, I would like to ask you that can I put closed-form equation to “transformed parameters” block ?
I often see such demonstration.(This is regression model example)

parameters{
  real a;
  real b;
  real<lower=0> sigma;
} 
transformed parameters{
  real y_base[N];
  for(i in 1:N){
    y_base[i] = a + b*x[i];
  }
}
model{
  for(i in 1:N){
    y[i] ~ normal(y_base[i], sigma);
  }
}

Abstractly

parameters{
  real param1;
  real param2;
} 
transformed parameters{
  real new_param1;
  real new_param2;
  new_param1 = some_func1(param1, param2);
  new_param2 = some_func2(param1, param2);
}

I want to write like this↓

parameters{
  real param1;
  real param2;
} 
transformed parameters{
  real new_param1;
  real new_param2;
  some_func1(param1, param2, new_param1) = 0;
  some_func1(param1, param2, new_param2) = 0; //so called closed-form, right?
}

Would you tell me whether this is allowed and/or something solution?
In addition, I would like you to forgive my poor English.

Thank you.


Could you tell me about algebra_solver
#2

I think you mean an implicitly defined function in the neighborhood of zero, and yes, you can do that but have to use the algebra_solver function. See chapter 20 of the Stan User Manual.


#3

I appreciate your reply!

I will see the chapter 20 and look over algebra_solver function at other websites in a minute.

Thank you.