# Adding intercept and multiplicative coefficients to a normal distribution

In the code below I’m trying to add intercept to an autoregressive model. No matter what I do, stan complains about the signatures. All examples I’ve seen are the same as the code below. I get the same message even if I transpose c or y.

``````data {
int<lower=1> T;  // number of time points
int<lower=1> K;  // number of time series
int y[T, K];     // data
}

parameters {
real<lower=0> sigma;
real c[K];
}

model {
sigma ~ cauchy(0, 2.5);
c ~ normal(0, 1);

for (t in 2:T)
y[t] ~ normal(c + y[t-1], sigma);
}
``````

Ill-typed arguments supplied to infix operator +. Available signatures:
(int, int) => int
(real, real) => real
(real, vector) => vector
(vector, real) => vector
(vector, vector) => vector
(complex, complex) => complex
(real, row_vector) => row_vector
(row_vector, real) => row_vector
(row_vector, row_vector) => row_vector
(real, matrix) => matrix
(matrix, real) => matrix
(matrix, matrix) => matrix
(complex, complex_vector) => complex_vector
(complex_vector, complex) => complex_vector
(complex_vector, complex_vector) => complex_vector
(complex, complex_row_vector) => complex_row_vector
(complex_row_vector, complex) => complex_row_vector
(complex_row_vector, complex_row_vector) => complex_row_vector
(complex, complex_matrix) => complex_matrix
(complex_matrix, complex) => complex_matrix
(complex_matrix, complex_matrix) => complex_matrix
Instead supplied arguments of incompatible type: array real, array int.

There are two things highlighted in the error that you should look at. Off the top of my head, I don’t know if one or both are causing the issue, but it will be easy to test.

The first is adding a real to an integer. I would have guessed that this was possible, but I don’t see the signature in the listing. So changing y from integer data to real data might help.

The second is that you’re trying to add two arrays to one another. Scalar, vector, and matrix addition are supported. But I don’t know if array addition is. You can avoid this issue by making y a matrix and c a vector rather than arrays.

One or both of those should resolve your issue.

1 Like

Thank you,