While trying to compile the example from here with pystan.StanModel
I get the error
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Variable "sho" does not exist.
error in 'unknown file name' at line 23, column 39
-------------------------------------------------
21:
22: generated quantities {
23: vector[2] y_sim[T] = ode_rk45(sho, y0, t0, ts, theta);
^
24: for (t in 1:T) {
-------------------------------------------------
The code I am running:
#!/usr/bin/env python3
import pystan
q_code = '''
functions {
vector sho(real t, vector y, real theta) {
vector[2] dydt;
dydt[1] = y[2];
dydt[2] = -y[1] - theta * y[2];
return dydt;
}
}
data {
int<lower=1> T;
vector[2] y0;
real t0;
real ts[T];
real theta;
}
model {
}
generated quantities {
vector[2] y_sim[T] = ode_rk45(sho, y0, t0, ts, theta);
for (t in 1:T) {
y_sim[t, 1] += normal_rng(0, 0.1);
y_sim[t, 2] += normal_rng(0, 0.1);
}
}
'''
sm = pystan.StanModel(model_code=q_code)
- Python Version: 3.8.3
- PyStan Version: 2.19.1.1
Thank you for your help!