I’m following this case study on bayes sparase regression.
The data I’m using can approximately be generated by the following cod. \beta s are always positive.
transformed data {
int<lower=0> M = 200;
int<lower=0> N = 100;
real alpha = 3;
real sigma = 1;
real<lower=0, upper=1> sig_prob = 0.05;
}
generated quantities {
matrix[M, N] X;
real y[N];
vector[M] beta;
for (m in 1:M) {
if (bernoulli_rng(sig_prob))
if (bernoulli_rng(0.5))
beta[m] = normal_rng(35, 3);
else
beta[m] = normal_rng(35, 3);
else
beta[m] = normal_rng(45, 2);
}
for (n in 1:N) {
for (m in 1:M)
X[m, n] = normal_rng(0, 1);
y[n] = normal_rng(X[1:M,n]' * beta + alpha, sigma);
}
}
This is the model:
data {
int<lower=1> N; // Number of data
int<lower=1> M; // Number of covariates
matrix[M, N] X;
real y[N];
}
parameters {
vector<lower=0>[M] beta;
vector<lower=0> [M] scale;
real alpha;
real<lower=0> sigma;
}
model {
scale ~ uniform(5,15);
beta ~ double_exponential(45, scale);
alpha ~ normal(0, 2);
sigma ~ normal(0, 2);
y ~ normal(X' * beta + alpha, sigma);
}
How to parameterize this centered model into non-centered one when the \beta are always positive?