x <- 1:10
y <- dgamma(x, shape=alpha, scale=1/beta)
y <- y + rnorm(length(x), 0, sigma_y)data {
int<lower=0> N; // nr samples
real y[N]; // y values
real x[N]; // x values
}
parameters {
real<lower=0> alpha;
real<lower=0> beta;
real<lower=0,upper=100> sigma;
}
transformed parameters {
real y_hat[N];
for(n in 1:N)
y_hat[n] <- gamma_log(x[n], alpha, beta);
}
model {
for(n in 1:N)
y[n] ~ normal(y_hat[n], sigma);
}y <- a + b * y + rnorm(length(x), 0, sigma_y)
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 17:
Error in function boost::math::lgamma<double>(double): numeric overflow
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
model {
y ~ normal(y_hat, sigma);
alpha ~ cauchy(0,10); // stay way below 100 here
beta ~ cauchy(0,10); // dito
sigma ~ cauchy(0,10); // not necessary
}y_hat[n] <- a + b * exp(gamma_log(x[n], alpha, beta)); Modifying step size just reduces numerical errors --- you
shouldn't get a different answer if everything converges without
exceptions during sampling.
We've tended to jump straight from parametric models to Gaussian
processes --- if someone has some nice spline models they want
to share, I'd love to see them (sorry if they've already been
posted and I missed them) --- then I might be able to finally
understand spline models, at which point I can put some examples
in the manual.