I’ve found that sometimes I have simple errors in my code that can be hard to debug from the error thrown in the `sampling`

command. Additionally, it can be hard to profile the code using sampling since there is a lot going on with the HMC sampler.

It’s not really clear how to get the log prob value from the stan model, but I was able to come up with this. I was following the rstan thread, and wanted to share this here in case anyone wants to use it, and also in hopes that this sort of thing would be easier in the new rstan version.

```
checkStanModel <- function(stan.model){
x <- new(stan.model@mk_cppmodule(stan.model),out.data,rstan:::grab_cxxfun(stan.model@dso))
x$log_prob(rep(.1,x$num_pars_unconstrained()),adjust_transform=TRUE,gradient=FALSE)
}
profileStanModel <- function(stan.model,n=1000){
x <- new(stan.model@mk_cppmodule(stan.model),out.data,rstan:::grab_cxxfun(stan.model@dso))
return(system.time(replicate(n,x$log_prob(runif(x$num_pars_unconstrained(),-2,2),
adjust_transform=TRUE,gradient=TRUE))))
}
```