Suppose that the following in stan file.
transformed parameters {
real <lower=0,upper=1>p[C];
}
where C
is a positive integer specified by the data block.
Then by p[1]
we can extract the first component. p[C]
also extract the C
-th componet ? Or p[C]
is indicate the set of p[1],p[2],....p[C]
?
For example, Which does the code p[C] = 1
means ?
1)ONLY the C-th component of p
is one
or
2)ALL components of p (i.e., p[1],p[2],....p[C]
) is one.
In your example,
transformed parameters {
real<lower = 0, upper = 1> p[C]; // multivalued
p[C] = 1; // scalar
}
The first C-1
elements of p
are undefined, which is probably not good, although it is valid syntax.
Alternatively,
transformed parameters {
real<lower = 0, upper = 1> p[C] = rep_array(1, C);
}
defines all the elements of p
to be 1.