stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.04k stars 264 forks source link

log density and gradient without fit object #231

Open bob-carpenter opened 8 years ago

bob-carpenter commented 8 years ago

There should be a way to take a Stan program (path to file or string) and a data specification (list of values or names of variables from environment or just an environemnt) and produce an object with which to evaluate log densities and gradients and Hessians without having to create an empty fit object.

Then, whatever this (model + data) object is, it can be a component of the fit object.

Is this already in the works for RStan 3?

bgoodri commented 8 years ago

Yeah, we'll do this for rstan3. The fundamental issue is that log_prob(), etc. are S4 methods for the stanfit class rather than the stanmodel class. It doesn't really make sense to create a stanfit object with no MCMC stuff in it just so that you can call log_prob. But the stanmodel class currently does not have data associated with it, so in order to define a log_prob method for the stanmodel class, you would have to pass the data too.