append_col(a, append_col(b, c))
will append three vectors (or matrices) by column.
The next version of Stan (2.15) will let you construct
vector and matrix literals. It'll look like:
real a;
row_vector[3] x = [ 1, 2, a ];
vector[3] xt = [ 1, 2, a ]'; // note transpose
matrix[3, 3] = [ [ 1, 2, 3],
[4, 5, 6],
[7, 8, 9] ];
Arrays use { 1, 2, 3 } instead of [1, 2, 3].
- Bob
> On Mar 23, 2017, at 1:48 PM, Jaron <
arbe...@umn.edu> wrote:
>
> Total STAN novice here, I need help assigning elements to a vector or matrix within my model statement.
>
> (1) Suppose a define a vector in my model statement as:
>
> real vec[3];
>
> I want to assign elements within the vector, but the following does not work:
>
> vec= (a,b,c);
>
> where a,b, and c may be scalars or random variables. I get a parser error saying it thinks there should be a ")" where the first comma is.
>
> (2) Now suppose I have a matrix:
>
> matrix[3,3] mat;
>
> In base R, I could easily fill in this matrix as follows: mat=cbind(c(a,b,c),c(d,e,f), c(g,h,i)) where the elements may or may not be scalars... In stan, is there any similar way to fill in the columns of a matrix?
>
>
> Thanks
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.