Skip to content
Advertisement

How to calculate the average R square of the company data [closed]

STOCK RETURN

I don’t know how to compute the average r squared with individual stock return and market return

JavaScript

This is what my code looks like now, I’ve tried to separate data of y1,y2 to run the r square with the value append in list1

Advertisement

Answer

Formula of R squared: 1-unexplained_variation/total_variation

Unexplained variation is the sum of difference for each datapoint between the prediction using the line of best fit and the actual values. You can compute the coefficients of the line of best fit with numpy.polyfit().

Total variation is the sum of difference for each datapoint between the average value and the actual values.

EDIT: With dummy values, it would look something like this

JavaScript
Advertisement