[R] If I have 3 parameters, is optim() doing the same thing as Gibbs sampling?
C W
tmrsg11 at gmail.com
Thu Dec 10 16:17:47 CET 2015
Hi R list,
I am using optim() to optimize a function with 3 parameters.
#My 1-d toy example: loglikelihood of normal with x=c(2,5,3,7,-3,-2,0),
find MLE of mean.
p1 <- function(theta){
sum(log(dnorm(c(2,5,3,7,-3,-2,0), mean = theta, sd = 1))) +log(dnorm(
theta, mean = 0.8, sd = 2))
}
optimize(p1, c(-3, 5), maximum = TRUE)
My question:
If function p1 has 3 parameters, is it doing the same thing as Gibbs
sampling?
In Gibbs, we optimize parameter 1 while fixing parameter 2 and 3. Then
optimize 2, fixing 1 and 3. Repeat until convergence.
How does optim() choose random numbers? I am using the default,
Nelder-Mead.
Is optim() drawing numbers from uniform distribution? Is it picking from
[-Inf, Inf]? What if I want draw from a prior N(3, 1) instead?
Thanks so much!
Mike
[[alternative HTML version deleted]]
More information about the R-help
mailing list