[R] Bayesian question (problem using adapt)
Tamas K Papp
tpapp at Princeton.EDU
Sun Nov 12 05:40:02 CET 2006
On Sat, Nov 11, 2006 at 11:19:46AM -0500, cmdicaso at ncsu.edu wrote:
> kernel1 <- function(theta, param) { exp(loglik(theta, param)) + log(10000)}
>
> kernel2 <- function(theta, param) {( exp(loglik(theta, param)) +
> log(10000)) * gm(theta, param) }
>
> kernel2(theta0, param0)
>
>
>
> adapt(4, lower = c(0, 0, 0, 0), upper = c(1, 1, 1, 1), functn =
> kernel2(theta0, param0))
I could not walk through your code because you failed to create a
simple reproducible example (eg the data is missing), but
kernel2(theta0,param0) is no longer a function --- kernel2 is, you
need to just supply that.
A couple of remarks:
- instead of "function undefined", you might just want to return NA or
NaN as is standard in R.
- why do you multiply by 10000?
- are you just integrating the posterior? why?
- have you considered MCMC? On state spaces bigger than 2 dimension,
it is usually preferable to numerical integration (but since I don't
know your model in detail, there might be something special about
it).
Best,
Tamas
More information about the R-help
mailing list