Skip to main content
. 2021 Apr 16;18(8):4245. doi: 10.3390/ijerph18084245
Algorithm A2. Cross-Validation in the Selection of Linear Models
Input: Dependent variables data y and independent variables data id, deterministic variables DV and uncertain variables UV, the lowest goodness-of-fit (GOF) that can do cross-validation G.
IN = None
while GOF < G:
        RV = UV except IN
        DV = add IN to DV
        for i in RV:
Linear regression of the DV and i on the dependent variable.
Calculate the goodness-of-fit (GOF)
        Select the i with the highest GOF.
        IN = i
UV = UV except DV
for i in 0 to the number of UV:
CV = Combine i variables from UV
for i2 in CV:
add i2 to DV.
Separate data by 8:2 as training and validation sets.
Train set train model (liner regression).
Calculate the validation set error (GOF) using the trained model.
Select the model with the highest GOF in the validation set.
Select the model with the highest GOF in the validation set.
Output: The best model with the highest GOF in the validation set.