You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thanks for your work and I'm excited for the second edition!
I have been reproducing some examples in the book with the Julia language and came across something that threw me for a loop in the introduction. This is the first time I'd seen the response variable as a matrix with the lm function. When the regression is done with a matrix as the response variable the lm documentation notes:
If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix.
This all made sense but I was getting different coefficients than in the stocks.R script provided in this repo. It turns out that lm will drop records in the response matrix if any of the variables have missing values. Since the GOOGL ticker has missing values from 2010-01-01 until 2014-03-01 it drops those records for all the other tickers as well before fitting the models.
So the original plot of coefficients was this:
If all the available data is used then the plot becomes:
This changes the interpretation of the plot slightly for most stocks but Facebook (FB) is likely notable.
First off, thanks for your work and I'm excited for the second edition!
I have been reproducing some examples in the book with the Julia language and came across something that threw me for a loop in the introduction. This is the first time I'd seen the response variable as a matrix with the
lm
function. When the regression is done with a matrix as the response variable thelm
documentation notes:This all made sense but I was getting different coefficients than in the
stocks.R
script provided in this repo. It turns out thatlm
will drop records in the response matrix if any of the variables have missing values. Since theGOOGL
ticker has missing values from2010-01-01
until2014-03-01
it drops those records for all the other tickers as well before fitting the models.So the original plot of coefficients was this:
If all the available data is used then the plot becomes:
This changes the interpretation of the plot slightly for most stocks but Facebook (FB) is likely notable.
Here's the code I used to create the plots:
The text was updated successfully, but these errors were encountered: