Recently I am writing a Stan code with the following simplification of the original code:
Here time is known data with length N, and b is a vector of regression coefficient with length 4, when I definied them as:
data {
real time[N];
}
paramters{
vector[4] b;
}
model{
product = b[4]*time;
}
There is error message as:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for:
real * real[ ]
Available argument signatures for operator*:
real * real
vector * real
row_vector * real
matrix * real
row_vector * vector
vector * row_vector
matrix * vector
row_vector * matrix
matrix * matrix
real * vector
real * row_vector
real * matrix
No matches for:
vector + ill-formed
In my understanding that now time is a vector of length 4 and time is an array of length N, but why we cannot multiply them together in this case? Since if itâs in R, it is very natural to write something like :real * real[ ] but now it rertuns an error and makes me so confused.
After trying I found the following code works:
data {
vector[N] time;
}
paramters{
vector[4] b;
}
model{
product = b[4]*time;
}
Could anyone explain the difference between these two Stan codes and why the first one returns some error?
edit by @Max_Mantei: added stan
tags for code formatting