How to add inequality constraint on the model

sigma
as
para
mu and alpha are parameters.
How to implement this inequaliity constrait in Stan?
so that mu1alpha1>0 and mu2alpha2>0
Thank you very much.
with regards

parameters {
  real mu_1;
  real<lower=0> mu_1_alpha_1;
}
transformed parameters {
  real sigma_1 = mu_1_alpha_1 / mu_1;
}
1 Like

Thank you very much!
what is sigma_1?
should i do something like this?
‘parameters {’
‘vector[4]p;’
‘real<lower=0> mu_1_alpha_1= p[1]*p[2] ;’
‘real<lower=0> mu_2_alpha_2= p[3]*p[4] ;’
‘}’
p is the vector of paramters. p[1]=mu_1,p[2]=alpha_1,p[3]=mu_2,p[4]=alpha_2
Thank you very much!
with best regards

Yeah, by sigma_1 I meant alpha_1.

1 Like

This is brilliant! Thank you very much!

i have this warning, do you know why this happened.
anon_model.stan (578 Bytes)
compile: DIAGNOSTIC(S) FROM PARSER:
compile: Warning (non-fatal):
compile: Left-hand side of sampling statement (~) may contain a non-linear transform of a parameter or local variable.
compile: If it does, you need to include a target += statement with the log absolute determinant of the Jacobian of the transform.
compile: Left-hand-side of sampling statement:
compile: b1 ~ normal(…)
compile: Warning (non-fatal):
compile: Left-hand side of sampling statement (~) may contain a non-linear transform of a parameter or local variable.
compile: If it does, you need to include a target += statement with the log absolute determinant of the Jacobian of the transform.
compile: Left-hand-side of sampling statement:
compile: b2 ~ normal(…)

ogden-2: Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
ogden-2: Exception: multi_normal_lpdf: Location parameter[2] is -inf, but must be finite! (in ‘E://anon_model.stan’ at line 30)
ogden-2: If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
ogden-2: but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

http://mc-stan.org/misc/warnings.html#jacobian-warnings

1 Like

Hello.

I have a similar issue. In my case I would like to set the following restriction:

\beta > 0.

However, I don’t see how your proposed solution impose the restriction. In that implementation, wouldn’t \alpha\mu=0 (which is allowed through the lower constraint) imply that \alpha=0?