title: natural cubic spline regression with R
body: <p>I seem to have a problem with the <code>splines::ns()</code> function in R.</p>
  
  <p>I created a simple dummy problem</p>
  
  <pre><code>dat &lt;- data.frame(t &lt;- seq(0, 6, .01),
                    x &lt;- rnorm(length(t), sd = 1),
                    y &lt;- 5 + t - x^2 + rnorm(length(t), sd = .33))
  
  lm(y ~ t + I(x^2), data = dat)
  
  library(splines)
  lm(y ~ t + ns(x, knots = c(0), Boundary.knots = c(-3, 3)), data = dat)
  </code></pre>
  
  <p>While the first model works fine, the second one fails to identify the intercept correctly. What am I missing here?</p>