Step 1 reads the data.
Step 2 creates two functions for performing LOOCV. Lines 1 to 4 define the first function rdacb.loocv.reg and lines 5 to 9 define the second one, rdacb.loocv.reg.iter:
- Line 2 of the first function rdacb.loocv.reg repeatedly calls the second function rdacb.loocv.reg.iter to build the regression model leaving one case out and compute the squared error
- Line 3 creates a list with the output elements
- Line 6 in the second function rdacb.loocv.reg.iter builds the regression model on the data frame leaving out one case
- Line 7 generates the prediction for the case that was left out
- Line 8 computes the squared error
Step 3 uses the preceding functions to perform LOOCV and displays the results.