title: Using lm(), nls() (and glm()?) to estimate population growth rate in Malthusian growth model
body: <p>My question is related to estimating the population growth rate in <a href="https://en.wikipedia.org/wiki/Malthusian_growth_model" rel="nofollow">Malthusian growth model</a>. As a toy example, consider a toy dataset <code>df</code>:</p>
  
  <pre><code>structure(list(x= c(0L, 24L, 48L, 72L, 96L, 120L, 144L, 168L
  ), y = c(10000, 18744.0760659189, 35134.0387564953, 65855.509495469, 
  123440.067934292, 231377.002294256, 433694.813090781, 812920.856596808
  )), .Names = c("x", "y"), row.names = c(NA, -8L), class = "data.frame")
  </code></pre>
  
  <p>I am trying to fit this dataset by <strong>exponential model</strong>:</p>
  
  <pre><code>y = 10000 * (e^(r * x))
  </code></pre>
  
  <p>and estimate <code>r</code>. When using <strong>nonlinear</strong> regression <code>nls()</code>:</p>
  
  <pre><code>fit &lt;- nls(y ~ (10000 * exp(r*x)), data=df)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Error in getInitial.default(func, data, mCall = as.list(match.call(func,  : 
    no 'getInitial' method found for "function" objects
  </code></pre>
  
  <p>I also tried <code>lm()</code></p>
  
  <pre><code>fit &lt;- lm(log(y) ~ (10000 * exp(r*x)), data=df) 
  </code></pre>
  
  <p>but get</p>
  
  <pre><code>Error in terms.formula(formula, data = data) : 
    invalid model formula in ExtractVars
  </code></pre>
  
  <p>How can I solve this? How can I fit the data to the exponential model I have?</p>
  
  <p>Also, are there other approaches I could consider for fitting population growth model? Is <code>glm()</code> reasonable?</p>