title: How to calculate the optimal quantity of a independent variable to get the minimum model output?
body: <p>In R I made a multiple linear regression model with 10 variables, after I have the model with the coefficients I would like to know how to calculate the miminum value of each independent variable that would give me the global minimum value of the output "y" from the model?</p>
  
  <p>I tried optim package which I read does this but I get an error</p>
  
  <pre><code> Error in fn(par, ...) : could not find function "fn"
  </code></pre>
  
  <pre><code>
  ### calculate model
  fit &lt;- lm(Y ~., data=df2)
  
  ### create equation in function with parameters and coefficients to get ### global mínimum and with which values each value gets to that mínimum
  
  f &lt;- function(X,X1,X2,X3,X4,X5,X6,X7,X8,X9) -210.50200438 - 1.08319034 * X +  0.07467384 * X1  + 0.02106764 * X2 + 0.08280658 * X3 + 2.07585559 * X4 + 5.09223561 * X5 + -7.57592770 * X6 + 1.62970544 * X7 + 0.45169896 * X8  - 0.32157245 * X9
  
  ### Variables
  X &lt;- seq(19,75,by=1)
  X1 &lt;- seq(3780,9183,by=100)
  X2 &lt;- seq(7534,15840,by=100)
  X3 &lt;- seq(2810,5100,by=100)
  X4 &lt;- seq(185,596,by=1)
  X5 &lt;- seq(1.20,48.1,by=0.1)
  X6 &lt;- seq(38,78,by=1)
  X7 &lt;- seq(33,100,by=1)
  X8 &lt;- seq(160,358,by=1)
  X9 &lt;- seq(42,458,by=1)
  z &lt;- outer(X,X1,X2,X3,X4,X5,X6,X7,X8,X9,f) 
  optim(X,X1,X2,X3,X4,X5,X6,X7,X8,X9,f)
  
  </code></pre>
  
  <p>I want to know what is the global minimum of "y" and the values for each independent variables in order to get to that minimum, however I get that mistake with optim, if that is not what I should use please tell me how could I achieve this.</p>
  
  <p>Thanks</p>