Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Greg Snow
If you f function is a likelihood (or better a log likelihood), then you can do profiling. Take the parameter of interest and change it a small amount from the optimal value, rerun optim with this value fixed and let it optimize over everything else. Repeat this for several values and see how

Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Arun.stat
Regrading your second question, I guess somehow you get undefined value like logarithm of zero of your target function for some unfortunate parameter values in the parameter space. Devred, Emmanuel wrote: > > Hi everyone, > > I have two questions: > > I would like to get confidence intervals

Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Ravi Varadhan
Emmanuel, I didn't answer your second question. You can use the `try' function to capture errors and keep proceeding through simulations without crashing out: ?try If `L-BFGS-B' does not work well, you could try the `spg' function in the "BB" package. Ravi. -Original Message- From:

Re: [R] Confidence interval on parameters from optim function

2009-08-19 Thread Ravi Varadhan
Hi Emmanuel, You can obtain standard error estimate from the Hessian matrix evaluated at the optimum as: sqrt(diag(solve(ans$hessian))), where `ans' is the object returned by `optim'. However, `optim' does not return the Hessian matrix by default. So, you need to specify `hessian = TRUE' when you