smooth.spline(): fitted model does not match user-specified degree of freedom
<p>Here is the code I ran</p>

<pre><code>fun &lt;- function(x) {1 + 3*sin(4*pi*x-pi)}
set.seed(1)
num.samples &lt;- 1000
x &lt;- runif(num.samples)
y &lt;- fun(x) + rnorm(num.samples) * 1.5
fit &lt;- smooth.spline(x, y, all.knots=TRUE, df=3)
</code></pre>

<p>Despite <code>df=3</code>, when I checked the fitted model, the output was</p>

<pre><code>Call:
smooth.spline(x = x, y = y, df = 3, all.knots = TRUE)
Smoothing Parameter  spar= 1.499954  lambda= 0.002508571 (26 iterations)
Equivalent Degrees of Freedom (Df): 9.86422
</code></pre>

<p>Could someone please help? Thanks!</p>