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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.