Polynomial Regression for Modeling Stock Prices with Lagged Features
Summary
This tutorial introduces polynomial regression as a way to let a linear regression model represent nonlinear relationships. Using Punjab National Bank price data, it creates lagged closing-price features and binary indicators based on higher highs and lower lows. It fits a baseline linear model, reviews coefficients and residuals, and evaluates predictions with explained variance and error measures.
The polynomial step squares the second lag feature, refits the model, and compares its test-set metrics with the baseline. The presented result indicates strong explained variance for the expanded model, but the tutorial does not establish that this approach would generalize to live trading. Its random train-test split does not preserve time order, and filling missing lag values with zero can distort the data. The code and reported outputs also contain inconsistencies, so the numerical comparison should be treated cautiously rather than as robust evidence of predictive value.
Key ideas
- Adding a squared lag feature lets a linear regression model represent a nonlinear relationship with that input.
- Lagged prices and simple high-low indicators can be used as predictors in a stock-price model.
- Model evaluation can include explained variance, mean squared error, mean absolute error, and residual plots.
- Random splitting and zero-filling missing lag values can make time-series results unreliable.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.