title: using R function nls with long list of variables
body: <p>I am trying to estimate a non-linear model with the R function nls. </p>
  
  <p>I will illustrate my problem with an example from the "help" facility for nls.</p>
  
  <pre><code>Treated &lt;- Puromycin[Puromycin$state == "treated", ]
  weighted.MM &lt;- function(resp, conc, Vm, K)
  {
      pred &lt;- (Vm * conc)/(K + conc)
      (resp - pred) / sqrt(pred)
  }
  
  Pur.wt &lt;- nls( ~ weighted.MM(rate, conc, Vm, K), data = Treated,
            start = list(Vm = 200, K = 0.1))
  </code></pre>
  
  <p>In this example, weighted.MM is a function with a very limited number of arguments, and I have no problem implementing analogous approaches for the type of model I am working with.</p>
  
  <p>However, I am trying now to move to a more realistic problem, where I have literally dozens of arguments to pass on to the function. I could of course simply enumerate them,  but I find this a bit unwieldy. </p>
  
  <p>I have considered putting them in a separate list first. For instance, using the example from above, I would first define:</p>
  
  <pre><code>MyArguments &lt;- list(Vm, K)  
  </code></pre>
  
  <p>and then passing MyArguments on as argument to the function (and accessing the individual arguments from within the function). However, that doesn't work, because I get the error message</p>
  
  <pre><code>Error: object 'Vm' not found
  </code></pre>
  
  <p>Alternatively,</p>
  
  <pre><code>    MyArguments &lt;- list("Vm", "K") 
  
  weighted.MM1 &lt;- function(resp, conc1, conc.1, thearguments)
  {
    conc &lt;- c(conc1, conc.1)
    pred &lt;- (thearguments[[1]] * conc)/(thearguments[[2]] + conc)
    (resp - pred) / sqrt(pred)
  }
  
  Pur.wt1 &lt;- nls( ~ weighted.MM1(rate, conc1, conc.1, MyArguments),
                  data = lisTreat, start = list(Vm = 200, K = 0.1))
  </code></pre>
  
  <p>yields:</p>
  
  <pre><code>Error in thearguments[[1]] * conc : 
    non-numeric argument to binary operator
  Called from: weighted.MM1(rate, conc1, conc.1, MyArguments)
  </code></pre>
  
  <p>Is there any work-around for this? </p>