Issue in replicating stan model in Numpyro

How can we implement such stan models in Numpyro where the parameter is contained to have a lower value of 0 and the prior that we are using for it is a Normal centered around 0. For example:

parameters {
  real<lower=0> sigma_y;
  real<lower=0> sigma_alpha;
  real<lower=0> sigma_beta;

model {
  vector[N] mu;
  // Prior
  sigma_y ~ normal(0,1);
  sigma_beta ~ normal(0,1);
  sigma_alpha ~ normal(0,1);
  mu_alpha ~ normal(0,10);
  mu_beta ~ normal(0,10);

  alpha ~ normal(mu_alpha, sigma_alpha);
  beta ~ normal(mu_beta, sigma_beta);
  for(n in 1:N){
    mu[n] = alpha[county_idx[n]] + floor_measure[n] * beta[county_idx[n]];
    target += normal_lpdf(log_radon[n] | mu[n], sigma_y);

Is the closest possible solution for implementing it in Numpyro using HalfNormal, or is there some way to put constraints on the parameters in Numpyro similar to Stan?

in this case you can use the TruncatedNormal distribution. also see this tutorial

1 Like