Can I specify a vector with a lower = 0?

Below, the vector ‘loss_ratio’ has a lower bound of 0. When I change vector to real<lower=0>, the model errors. Is there a way to state a vector with a lower bound?

data {
    int<lower=1> n;           // number of observations
    vector[n] loss_ratio; //target
    vector[n] cancellation;  //monthly cancel rate
    int<lower=1> p;
    vector[p] cancellation_ppc;
}

parameters {
    real alpha;               // intercept
    real beta;                // slope
    real<lower=0> sigma;      // scatter
}

transformed parameters {
    // Any variable declared here is part of the output produced for draws.
    vector[n] mu;
    mu = alpha + beta * cancellation;
}

model {
    // priors
    alpha ~ normal(0,5);  // prior for intercept
    beta ~ normal(0, 5);     // prior for scale
    sigma ~ normal(0, 50);    // prior for scatter
    // likelihood
    loss_ratio ~ normal(mu, sigma);
}

generated quantities {
    vector[p] loss_ratio_ppc;
    for (i in 1:p) {loss_ratio_ppc[i] = normal_rng(mu[i], sigma);}
}

instead of

model{
vector[N] mu = alpha+beta*x;
y~normal(mu,sigma);
}

1 Like

vector<lower=0>[n] loss_ratio;

1 Like

Thank you!

1 Like