How to add inequality constraint on the model


#1

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


#2
parameters {
  real mu_1;
  real<lower=0> mu_1_alpha_1;
}
transformed parameters {
  real sigma_1 = mu_1_alpha_1 / mu_1;
}

#3

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


#4

Yeah, by sigma_1 I meant alpha_1.


#5

This is brilliant! Thank you very much!


#6

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.


#7

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