title: Leave one out cross validation with lm function in R
body: <p>I have a dataset of 506 rows on which I am performing Leave-one-out Cross Validation, once I get the mean squared errors , I am computing the mean of the mean squared errors I found. This is changing everytime I run it. Is this expected ? If so, Can someone please explain why is it changing everytime I run it ?</p>
  
  <p>To do leave one out CV, I shuffle the rows first , df is the data frame</p>
  
  <pre><code>df &lt;-df[sample.int(nrow(df)),]
  </code></pre>
  
  <p>Then, I split the dataframe into 506 data frames and send it to lm() and get the MSE for each data frame (in this case, each row)</p>
  
  <pre><code>fit &lt;- lm(train[,lastcolumn] ~.,data = train)
  pred &lt;- predict(fit,test)
  pred &lt;- mean((pred - test[,lastcolumn])^2)
  </code></pre>
  
  <p>And then I take the mean of all the MSEs I got.</p>
  
  <p>Everytime I run all this , I get a different mean. Is this expected ?</p>