I have a model which takes data from N users, each provides a K dimensional vector per day over T days.
The way I want to write out the data is sequentially for each K dimensional vector, one day at a time per user, then iterate over all users. So it is like
N <- 3
T <- 10
K <- 5
x <- array(1:50, dim = c(K, T, N))
this appears to dump out data in the right order
, , 1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 6 11 16 21 26 31 36 41 46
[2,] 2 7 12 17 22 27 32 37 42 47
[3,] 3 8 13 18 23 28 33 38 43 48
[4,] 4 9 14 19 24 29 34 39 44 49
[5,] 5 10 15 20 25 30 35 40 45 50
, , 2 (same as above)
, , 3 (same as above)
Then I dumped out x using stan_rdump. The x data looks like
x <-
structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50),
.Dim = c(5, 10, 3))
Inside the model, I am quite sure the way to declare the row vector is
row_vector[K] x[N, T]; // where K is the dimension of each row_vector. Less sure about order of N and T.
However, when I run the model, I get
variable name=x; position=0; dims declared=(3,10,5); dims found=(5,10,3)
It thinks I declared x with K as the last dimension. I could modify my x <- definition in r to match, but then I don’t get sequential numbers along K axis any more.
How can this be? Is the problem with the model declaration or with r object declaration?