maximize_log_lh_p {mcmcsae} | R Documentation |
Maximize the log-likelihood or log-posterior as defined by a sampler closure
Description
Maximize the log-likelihood or log-posterior as defined by a sampler closure
Usage
maximize_log_lh_p(
sampler,
type = c("llh", "lpost"),
method = "BFGS",
control = list(fnscale = -1),
...
)
Arguments
sampler |
sampler function closure, i.e. the return value of a call to |
type |
either "llh" (default) or "lpost", for optimization of the log-likelihood, or the log-posterior, respectively. |
method |
optimization method, passed to |
control |
control parameters, passed to |
... |
other parameters passed to |
Value
A list of parameter values that, provided the optimization was successful, maximize the (log-)likelihood or (log-)posterior.
Examples
n <- 1000
dat <- data.frame(
x = rnorm(n),
f = factor(sample(1:50, n, replace=TRUE))
)
df <- generate_data(
~ reg(~x, name="beta", prior=pr_normal(precision=1)) + gen(~x, factor=~f, name="v"),
sigma.fixed=TRUE, data=dat
)
dat$y <- df$y
sampler <- create_sampler(y ~ x + gen(~x, factor=~f, name="v"), data=dat)
opt <- maximize_log_lh_p(sampler)
str(opt)
plot(df$par$v, opt$par$v); abline(0, 1, col="red")
[Package mcmcsae version 0.7.7 Index]