Back to Community
Please help me! How to build regression with code.

I am new here. Please help with the following task

Take the data about JPM and C from 2018-9-1 to 2018-11-1, let PJPM,t be the price of JPM
at time t, and PC,t be the price of C at time t, compute
PJPM,t = ln PJPM
PC,t = ln PC
then regress as
P JPM ~ a + B pc + e
Compute a, b and plot e over the time window. Report R2 of your regression

3 responses

This may help

Loading notebook preview...

Hello, thank you so much. Do you know how to plot the residual over the time window?

Residuals is the difference between Y_hat(Predictions) and Y (Real Observations)

To plot the residuals you have to define "Y_hat" and "Y"
then , define "residuals" as Y_hat - Y

then you can do the following : plt.scatter(index , residuals)

Hope it helps