How would you use R or Python to run regression and analyze results?
Using PostgreSQL tables, prepare the monthly observations that would be passed to R or Python and calculate the core regression statistics directly in SQL. Exclude incomplete observations and funds with fewer than three valid observations.
Output
- One row per qualifying fund with
fund_id, fund_name, observations, alpha_monthly, beta, r_squared, and r_squared_rank.
- Use excess fund returns and excess benchmark returns, and rank funds by descending
r_squared, breaking ties by fund_id.