I have a function of four variables, (c,l,t,a)
I only want to optimize this function over c and l, because a and t are inputs and are used inside the function, sometimes for indexing and stuff. (Which is why I cannot just take the 1st order condition, set equal to zero, etc...).
Any ideas?
Thank you for your help.
EDIT:
Ok so I think the problem might be the way I am using optim sort of. I am going to try something and reframe my q.
You have a function of four parameters:
You only want to optimise over two, so make a function of two parameters and call the four-parameter function with the other parameters set:
Now whatever you were doing with
foo
you do withf2
.If you want you can create a function-generating function that returns functions with the fixed parameters you want you can do this:
Then you can create a two-parameter function with t and a set to 8 and 9 as before:
And this one gives us a function with them set to 8 and 6:
Now you've got
f3
with the values oft
anda
wrapped up and fixed.However I thought
optim
always worked with a single argument vector of parameters, which means, since you've not given us a reproducible example, I've wasted my time explaining this to you.