# Error with stan model:

I am attempting to build a simple multivariate normal example in stan using the target+= accumulator. I am doing this to learn how to code up a custom likelihood using the same format.
However, I keep getting the same error and I can’t work out where it is coming from or how to resolve it.
No matches for:
Available argument signatures for multi_normal:
Real return type required for probability function

This occurs at line 33 in the stan file below.
After checking for past posts in this forum regarding the issue, I believe that this is occurring due to me not understanding how the target+= vs ~ notation works but I have been unable to resolve it.
Below I have also included my R code to fit the model.

``````data {
int<lower=0> n;
int<lower = 1> p;
vector[p] x[n];
vector[p] beta_0;
matrix[p,p] sigma_0;
matrix[p,p] sigma;
}
parameters {
real mu;
real<lower=0> rho;
}
model {
mu~multi_normal(beta_0,sigma_0);
rho~inv_gamma(2, 2);
target+=multi_normal_lpdf(x[n]|mu,rho*sigma);
//y ~ normal(mu, sigma);
}
``````

The data is embedded in the r code.

``````rm(list=ls())
library(rstan)
library(MASS)
x <- matrix(c( .8, 102,
1.0,  98,
.5, 100,
.9, 105,
.7, 103,
.4, 110,
1.2,  99,
1.4,  87,
.6, 113,
1.1,  89,
1.3,  93), nrow=11, ncol=2, byrow=TRUE)
n<-nrow(x)
sigma_<-diag(c(1,1))
sigma_[1,2]<-.5
sigma_[2,1]<-.5
beta_0_=c(0,0)
sigma_0_=diag(c(.1,.1))
p=2
data_ <- list(x=x,
n=n,
sigma=sigma_,
p=2,
beta_0=beta_0,
sigma_0=sigma_0)
niter_ <- 3000
nchains_ <- 4
full_fit <- stan('/D/Dissertation/Chapter2/R/Multivariate_Normal_Distribution_V01.stan', data = data_,
iter = niter_, chains = nchains_, verbose = FALSE)
``````

Just in case it wasn’t clear in the example the error:
No matches for:
Available argument signatures for multi_normal:
Real return type required for probability function
occurs in the call:
mu~multi_normal(beta_0,sigma_0);

Looks like the problem is that `mu` is declared with type `real`, a scalar. The multinormal distribution applies to vectors, not scalars.
Try changing `mu` to a `vector`.

``````parameters {
vector[p] mu;
real<lower=0> rho;
}
``````

Thank you! That cleared the error.
So when I see this error in the future, does it generally just mean there is a mismatch between input types? Are there any other common cases that will cause it?

`No matches for ... Available matches for ...` always means there’s a type mismatch.

1 Like