R-squared is calculated as the ratio of the explained variance (sum of squared differences between the predicted and the mean of the dependent variable) to the total variance (sum of squared differences between the actual values and the mean of the dependent variable).
Formula: R-squared = 1 - (SSR / SST), where SSR is the sum of squared residuals and SST is the total sum of squares.