Optimization: Solve for an input value given a known output value in R

I thought you could do this yourself, easily.

b0 = foo()[5]               # budget: 33279.051347
fn2 = function(x) {
    foo(power = x)["budget"] - b0
}
uniroot(fn2, c(70, 90))
## $root
## [1] 79.99041
## $f.root
## budget 
##      0 

This may not work for all input variables, depending on how much influence they have on the different outputs.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top