Another entry in my ongoing mission to model some physiological data in which the heart beat induces quasi-regular changes in the data. I’ve managed to get a version working where I assume a known rate and do inference on the magnitude of noise and the heart beat amplitude, but when I try to do inference on the rate as well, I get very high rhat and very low neff for the rate parameter even with `iter=1e5`

. I’ve tried a couple different forms of the response function (symmetric half-sine, asymmetric half-sine, & `beta(2,2)`

), and get the same behaviour with all forms. I’ve also tried the scenario with known noise & pulse amplitudes, doing inference only on the rate parameter, but still get very poor sampling.

As per the warning at the beginning of section 41.7 in the manual, I suspect that this is an issue with my use of `fmod()`

to impose periodicity, but am out of ideas for fixing this. Help?

Here’s the model that attempts inference on rate, amplitude, & noise:

```
functions{
// pulse: function to generate pulse-like curve (half-sine); oversimplified in shape for initial model building/testing
vector pulse(vector time, real amplitude, real rate){
vector[num_elements(time)] position ;
real period = 1/rate ;
//need to loop because fmod isn't vectorized
for(i in 1:num_elements(time)){
position[i] = fmod(time[i],period)/period ;
}
return amplitude * sin( position*pi() ) ;
}
}
data{
int n;
vector[n] y;
vector[n] time;
}
parameters{
real<lower=0> amplitude;
real<lower=0,upper=1> rate; //needs upper bound else chains will gravitate towards higher frequencies whose aliased samples "fit" the data well
real<lower=0> noise;
}
model{
rate ~ uniform(0,1) ;
amplitude ~ weibull(2,2) ;
noise ~ normal(0,1) ;
y ~ normal( pulse(time,amplitude,rate) , noise ) ;
}
```