17. Regression Basics and the CAPM Regression analysis is the backbone of most data analysis work. Let’s use the CAPM to understand how OLS (ordinary least squares) regressions are done in Python with pandas. 17.1 Ordinary Least Squares 1. Before you run OLS on Python, you need to install the package statsmodels. 2. Syntax for ols function is pd.ols(y=y,x=x, arguments) 3. Look at a quick example to recall some OLS basics. 4. Here is the list of things the pd.ols function can produce. 5. Let’s get all the betas of in the PKW list. 44 17. Regression Basics and the CAPM 17.2 Assignment 6 Let’s build a model to predict SPY’s monthly return. Speci…cally, I’d like you to run the following regression: RSP Y;t = + Pr(Recession)t + "t ; where RSP Y is SPY’s monthly return and Pr(Recession) is the probability of having a recession in the U.S. 1. Use technique we learned in L16 to fetch SPY from Yahoo! Finance and RECPROUSM156N from Fred2. We use the latter to proxy for Pr(Recession): 2. Run the regression in Python. Report the coe¢ cients and t-statistics. Copy your output chart and attach your script in an email. Send me the email by March 25 (Tuesday.) a) Note that SPY obtained from Yahoo! is a daily price series. You need to resample it (’M’,how=’last’) and convert it to a monthly return series. b) Due to some oddities, you need to covert your SPY series to an array before running ols in pandas. c) Start is set to be 1993/1/1; end is 2013/12/31. 3. Challenge: can you …nd the regression result for this? RSP Y;t = + Pr(Recession)t 1 + "t :