I am attempting to use optim() in R to solve for lambda in the following equation:
lambda/sigma^2 – ln(lambda/sigma^2) = 1 + 1/Q
subject to constraint :
lambda > sigma^2.
I am not sure how one goes about setting up this in R.
I am open to alternative optimization routines as well although the equation seems convex and therefore optim should be a fine choice.
Thank you!
You are trying to solve an equation. Whether or not the constraint is met, can only be decided ex post.
You can use
unirootas followsgiving