Sampling uniform distribution on a vector

Hi,

I want to generate a uniform distribution on a vector.
I wrote the following code. For the normal and inverse gamma distributions, they were generated on a three-column vector (and also appear to be uncorrelated).

However, when I try to generate the uniform distribution on “row_vector[3]”, it returns the error “initalization failed”.
Just to be sure, I specified “real” instead of “row_vector[3]”, and the error did not occur and the uniform distribution was returned.

If you know how to generate an uncorrelated uniform distribution on a vector, please let me know.

Thank you.

#sampling only code

sampling_code = “”"
parameters {
row_vector[3] mu;
// real phai;
row_vector[3] phai;
row_vector[3] eta;
}

model {
mu ~ normal(0, 10);
phai ~ uniform(0, 1);
eta ~ inv_gamma(4,1);
print(phai);

}
“”"

1 Like

If you use a uniform prior you need to specify the corresponding lower and upper bounds in the parameter declaration:

row_vector<lower=0,upper=1>[3] phai
2 Likes

Thank you very much for your kindness, the code worked without any errors.