Derivation of coefficient of determination

The coefficient of determination (R2) is a measure of how well a regression model fits the data. It is calculated as the ratio of the explained variation to the total variation.

Explained variation: The explained variation is the sum of the squared differences between the predicted values and the mean of the observed values.

Total variation: The total variation is the sum of the squared differences between the observed values and the mean of the observed values.

R2 = Explained Variation / Total Variation

R2 = (Sum of Squared Differences between Predicted Values and Mean of Observed Values) / (Sum of Squared Differences between Observed Values and Mean of Observed Values)