Serving the Quantitative Finance Community

 
User avatar
alexzheng
Topic Author
Posts: 7
Joined: January 23rd, 2024, 10:12 am

why we can't use linear regression to predict share prices?

February 1st, 2024, 6:42 pm

Out of curiosity, I trained a linear regression model using 60% of the past 5 year prices to predict NVDA prices and I got "Adj Close = 0.37 + (1.0 * Adj Close.L1)" for my regression (Adj Close.L1 is one day lag), and I did the same thing for the Nasdaq Index and got 'Adj Close = 31.77 + (1.0 * Adj Close.L1)'. The Test MAE are 6.76 and 150.71 respectively. It seems the model is almost perfectly predicting the prices from the plots. However, in reality, surely that's not the case, so I am just wondering what's happening here, and why the coefficients are both 1? 


Many thanks 
 
User avatar
katastrofa
Posts: 7949
Joined: August 16th, 2007, 5:36 am
Location: Event Horizon

Re: why we can't use linear regression to predict share prices?

February 1st, 2024, 7:49 pm

Do i understand correctly that you see that today's price is similar to yesterday's close price? No way! ;-)
 
User avatar
alexzheng
Topic Author
Posts: 7
Joined: January 23rd, 2024, 10:12 am

Re: why we can't use linear regression to predict share prices?

February 2nd, 2024, 2:45 pm

maybe thats why linear regression wouldnt work irl lol 
 
User avatar
katastrofa
Posts: 7949
Joined: August 16th, 2007, 5:36 am
Location: Event Horizon

Re: why we can't use linear regression to predict share prices?

February 2nd, 2024, 4:48 pm

I’m not a trader but I’m guessing L1 means the same as in my models - a one day lag. So what I’m basically saying, assuming I understood your question, is that it’s a common knowledge and sense that the price on a given day is similar to previous day’s adjusted close price. You’ve essentially shown that the price is a random walk, rather than predicted anything.
 
User avatar
Alan
Posts: 3050
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

Re: why we can't use linear regression to predict share prices?

February 2nd, 2024, 5:15 pm

Of course, kat is correct. 

Since you are just learning regressions, try this. Create some simulated daily price data:
[$] X_t = \mu + \sigma Z_t [$], where [$]X_t = \log P_t/P_{t-1}[$], so [$]P_t = P_{t-1} e^{X_t}[$].

Here [$]P_t[$] are the prices, [$]\mu = 0.10/252[$] is the daily log-return drift, [$]\sigma = 0.40/\sqrt{252}[$] is the daily log-return volatility, and
[$]Z_t \sim N(0,1)[$] is a standard normal random variate. 

This describes a stock whose log-prices follows a classic drifting random walk, with a 10% per year growth rate and 40% annual volatility.

Create 5 years worth of prices [$]\{P_t\}[$] and repeat your original regression on the simulated price series. What do you find?
Try to use regressions or other procedures to recover the annualized parameters [$](\mu_a,\sigma_a)[$] to good accuracy. 
 
User avatar
alexzheng
Topic Author
Posts: 7
Joined: January 23rd, 2024, 10:12 am

Re: why we can't use linear regression to predict share prices?

February 3rd, 2024, 3:40 pm

Thanks so much! 
 
User avatar
bearish
Posts: 5906
Joined: February 3rd, 2011, 2:19 pm

Re: why we can't use linear regression to predict share prices?

February 3rd, 2024, 7:11 pm

And, since nobody has mentioned it yet, while it would seem that regressing the (log) price level on the index level and regressing the price change (or return) on the index change should get you similar answers, that’s not generally the case. There are uses for both, but most of the time you want to work in return space, since the return autocorrelations are usually pretty close to zero. You can look up “unit root” for details.
 
skafetaur
Posts: 42
Joined: June 11th, 2023, 3:31 pm

Re: why we can't use linear regression to predict share prices?

March 10th, 2024, 4:44 pm

Are returns autocorrelations really close to zero? Doesn't momentum in a stock's ascent or descent that we commonly see mean returns could be autocorrelated, albeit for a short while?
 
User avatar
bearish
Posts: 5906
Joined: February 3rd, 2011, 2:19 pm

Re: why we can't use linear regression to predict share prices?

March 10th, 2024, 8:55 pm

If with “for a short while” you mean some small fraction of a second, you may very well be right. For longer periods, you can always hope, but don’t underestimate the efficiency of markets. There are many many cases where historical times series will suggest the presence of some statistically significant tradable pattern (like momentum or mean reversion) which turns out to be not so tradable after all.
 
skafetaur
Posts: 42
Joined: June 11th, 2023, 3:31 pm

Re: why we can't use linear regression to predict share prices?

March 10th, 2024, 10:00 pm

Makes sense. Thanks Bearish. You're right it can happen for fractions of a second and high frequency trading shops presumably take advantage of those autocorrelations in the micro/nano second time duration.
 
User avatar
katastrofa
Posts: 7949
Joined: August 16th, 2007, 5:36 am
Location: Event Horizon

Re: why we can't use linear regression to predict share prices?

March 11th, 2024, 4:52 pm

It's called apophenia (:
 
User avatar
Paul
Posts: 7055
Joined: July 20th, 2001, 3:28 pm

Re: why we can't use linear regression to predict share prices?

March 11th, 2024, 8:16 pm

When people tell you something cannot be done there is a decision to be made between missing an opportunity and looking foolish. It applies to exploiting trading signals and to chatting up supermodels. It’s called life.
 
User avatar
katastrofa
Posts: 7949
Joined: August 16th, 2007, 5:36 am
Location: Event Horizon

Re: why we can't use linear regression to predict share prices?

March 11th, 2024, 8:41 pm

And I'm sure there's some positive correlation (if not causation) between the success rate in the first and the second.
 
User avatar
bearish
Posts: 5906
Joined: February 3rd, 2011, 2:19 pm

Re: why we can't use linear regression to predict share prices?

March 12th, 2024, 12:42 am

To be clear, I never said it couldn’t be done, only suggesting that it’s harder than it looks. Which, by the way, may be a good line to use when chatting with a supermodel.
 
User avatar
katastrofa
Posts: 7949
Joined: August 16th, 2007, 5:36 am
Location: Event Horizon

Re: why we can't use linear regression to predict share prices?

March 12th, 2024, 4:05 pm

Bearish, you're ruining the reputation of charming and romantic Norwegian men. Or maybe it works with supermodels. How would I know? Luckily (or not), my only long legged competition are moose :-)