When performing leave-one-out cross-validation, why are my results seed dependent?
<p>For my homework, I am performing leave-one-out cross-validation using the <em>cv.glm</em> package.</p>

<p>Consider the following simplified example where the cross-validation estimates of prediction error are not equal:</p>

<pre><code>set.seed(1)
x = rnorm(100)
y = x - 2 * x^2 + rnorm(100)
df &lt;- data.frame(x, y)

model &lt;- glm(y~poly(x, 2), data = df)

set.seed(1)
error_1 &lt;- cv.glm(df, model)

set.seed(2)
error_2 &lt;- cv.glm(df, model)

error_1$delta == error_2$delta
</code></pre>

<p>I understand that, when performing k-fold validation with <em>K =! number of observations</em>, random partitioning takes place. This would explain different values for <code>error_1</code> and <code>error_2</code>.</p>

<p>However, since I am not specifying <em>K</em>, it should be equal to the number of observations in <em>data</em> which should give the usual leave-one-out cross-validation.</p>

<p>To my understanding, leave-one-out cross-validation should not require a random element. Why are the results different? Where is a random number being used when performing leave-one-out cross-validation?</p>