Jen Mer
Jen Mer

Reputation: 101

stan: input data for arrays of vectors

I am fairly new to stan and I am trying to read in some data for my model. I defined an array of vectors as proposed in the corresponding stan manual but I don't know how to write down my input data. The data parameters I need look like this:

data {
   int         K;  // number classes
   int         N;  // number of all data points
   vector[2] y[N];
}

For a normal vector vector[k] my input looks like this:

K <- 5
N <- 2
y <- c(8.90680694580078,5.51890277862549)

But I just don't know how to do this for the sort of vector I have. Something like this doesn't work for N <- 4

y <- c(c(8.90680694580078,5.51890277862549), c(2.00219345092773,10.7796802520752))

Any suggestions?

Upvotes: 0

Views: 2291

Answers (2)

Dirk Nachbar
Dirk Nachbar

Reputation: 522

You can create a matrix

y <- matrix(rnorm(4), ncol = 2)

Upvotes: 1

Ben Goodrich
Ben Goodrich

Reputation: 4990

In R, you need to pass a matrix with N rows and 2 columns or I believe it would work to pass a list with N elements, each of which is a vector of length 2.

Upvotes: 3

Related Questions