"trying deprecated constructor" error for observation error model

I am having trouble with an observation error model that won’t compile correctly in rstan despite being syntactically correct. The error I keep getting is:

trying deprecated constructor; please alert package maintainer
Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
no valid constructor available for the argument list
failed to create the sampler; sampling not done

It doesn’t even create a .RDS file

Here is the associated stan file (also attached):
data {
//provided data for a sample
int<lower = 1> N; //number of individuals
int<lower = 1> Sites; // number of sites
int<lower = 1> N_Msres; //number of measurements
int<lower = 1> Msre_Types; //number of different measurement types
int<lower = 1, upper = Sites> Site[N]; //what site is the individual from?
real msre_obs[N_Msres];
real<lower = 0> msre_sd[N_Msres];
real ref_obs[Msre_Types]; //reference values for the measurements
real<lower = 0> ref_sd[Msre_Types];
int<lower = 1, upper = Msre_Types> msre_num[N_Msres];
int<lower = 1, upper = N> msre_Indiv[N_Msres];
}
parameters {
vector<lower = 0>[N_Msres] Msre;
vector<lower = 0>[Msre_Types] Ref;
vector[N] LSI;
real<lower = 0> LSI_sd; //variation of LSI values within an individual
//modeling average LSI for a site
real mu_LSI;
vector<lower = 0>[Sites] site_sigma;
}
model {
real LSI_msre;
//measurement error
msre_obs ~ normal(Msre, msre_sd);
ref_obs ~ normal(Ref, ref_sd);
LSI_sd ~ normal(0, 0.05);
for(i in 1:N_Msres) {
LSI_msre = log(Msre[i] / Ref[msre_num[i]]);
LSI_msre ~ normal(LSI[msre_Indiv[i]], LSI_sd);
}
//modeling average LSI for a site
mu_LSI ~ normal(0, 1);
site_sigma ~ normal(0, 1);
for(i in 1:N) {
LSI[i] ~ normal(mu_LSI, site_sigma[Site[i]]);
}
}

Thank you!

Here is the script and an attached R script and associated data file.LSI_observationerror.stan (1.3 KB)
R Script for Error in Observation Model.R (1.2 KB)
Bos Size Dataset.csv (137.3 KB)

rstan 2.17.3 will / does say the right error message:

Exception: mismatch in number dimensions declared and found in context; processing stage=data initialization; variable name=Site; dims declared=(1504); dims found=(1504,2) (in ‘model421f2e2fd998_LSI_observationerror’ at line 7)

since

> str(LSIdata_observationerror$Site)
Classes ‘data.table’ and 'data.frame':	1504 obs. of  2 variables:
 $ V1: int  2 2 2 2 2 2 2 2 2 2 ...
 $ V1: int  1 9 10 11 12 13 30 29 2 15 ...
 - attr(*, ".internal.selfref")=<externalptr> 

Thank you, that is exactly what was wrong and now I feel embarrassed. Is it
safe to say that until 2.17.3 I should consider that error as a
"something’s wrong with my data initialization" or is it more of a general
"something’s wrong" message?

Something’s wrong with your data initialization, and you can now install 2.17.3 to see exactly what is wrong.

just to let you know that this solved my problem also: I was using a scalar as data “hoping” that it would be recycled into the vector I’d declared, but as soon as I provided a vector of the right length, everything worked.