title: " length of 'dimnames' [2] not equal to array extent" error when using nlsLM function
body: <p>I am trying to use the <code>nlsLM</code> function from the <code>minpack.lm</code> package in R.</p>
  <p>I want to estimate parameters <code>kd</code> and <code>mu</code> in this model equation.</p>
  <pre><code>h.mod &lt;- P.cal.norm ~ P0*(1 - exp(-(B/(kd*Time.cal))^mu))
  </code></pre>
  <p>And these are my start values:</p>
  <pre><code>bounds0 &lt;- list(kd = c(1/3000, 1/2000), mu = c(1, 10))
  </code></pre>
  <p>I construct the data frame using these</p>
  <pre><code>Time.cal &lt;-  c(0, 1000, 2000, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 5000)
  P.cal.norm &lt;- c(1.0, 0.99, 0.98, 0.95, 0.795, 0.59, 0.35, 0.295, 0.175, 0.14, 0.095)
  dataset = data.frame(Time.cal,P.cal.norm)
  </code></pre>
  <p>And this is how I structured my <code>nlsLM</code> model</p>
  <pre><code>h.mod0.fit2 &lt;- nlsLM(h.mod, data = dataset, start = bounds0, algorithm = 'LM')
  </code></pre>
  <p>The error I get is</p>
  <blockquote>
  <p>Error in dimnames(x) &lt;- dn :<br />
  length of 'dimnames' [2] not equal to array extent<br />
  In addition: There were 50 or more warnings (use warnings() to see the first 50)</p>
  </blockquote>
  <p>When type <code>warnings()</code> I get 50 lines of this:</p>
  <blockquote>
  <p>Warning messages:<br />
  1: In kd * Time.cal :<br />
  longer object length is not a multiple of shorter object length</p>
  </blockquote>
  <p>What I can do to solve this error? Thanks.</p>
  <p>Here the whole code is given:</p>
  <pre><code>library(rcompanion)
  library(nlstools)
  library(minpack.lm)
  
  P0 &lt;- 1.0 
  B &lt;- 1
  
  Time.cal &lt;-  c(0, 1000, 2000, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 5000)
  P.cal.norm &lt;- c(1.0, 0.99, 0.98, 0.95, 0.795, 0.59, 0.35, 0.295, 0.175, 0.14, 0.095)
  
  phys.mods &lt;- function(Time, Temp) {
    k.h &lt;- A.h*(RH.eff)^n*exp(-Ea.h/((Temp+273.15)*8.62e-5))
    P.Time &lt;- P0*(1 - exp(-(B/(k.h*Time))^mu))
    t.f &lt;- B/(k.h*(abs(log(0.2)))^(1/mu))
    res &lt;- list(&quot;k.h&quot; = k.h, &quot;P.Time&quot; = P.Time, &quot;t.f&quot; = t.f)
    return(res)
  }
  
  h.mod &lt;- P.cal.norm ~ P0*(1 - exp(-(B/(kd*Time.cal))^mu))
  bounds0 &lt;- data.frame(kd = c(1/3000, 1/2000), mu = c(1, 10))
  h.mod0.fit &lt;- nlsLM(h.mod, data = data.frame(Time.cal, P.cal.norm), start = bounds0, algorithm = &quot;LM&quot;)   
  </code></pre>