Research Question
Is there a significant relationship between various technical
indicators, external factors, and the adjusted closing prices of AAPL
stock? Additionally, does the interaction between the categorical
variables “Signal” and “Trend” have a significant impact on the adjusted
closing prices?
Data Set Description:
The dataset used in this analysis contains information related to
AAPL (Apple Inc.) stock, with observations recorded over a specific time
period.
The dataset is created using YahooFinance API as the primary
resource.
Visualising Stock data with technical indicators
Linear Regression Model
We will fit a linear regression model taking all the technical
indicators - RSI, MACD, Signal.Line, Volume, SPY, MCRSFT
Model: Adj.Close ~ RSI + MACD + Signal.Line +
Volume + SPY + MCRSFT
Model Summary
| (Intercept) |
8.4522732 |
5.7176177 |
1.478286 |
0.1396777 |
| RSI |
-0.2437401 |
0.0505509 |
-4.821677 |
0.0000017 |
| MACD |
2.5900909 |
0.8387766 |
3.087939 |
0.0020767 |
| Signal.Line |
-1.6628910 |
0.7230996 |
-2.299671 |
0.0216927 |
| Volume |
-0.0000001 |
0.0000000 |
-5.610234 |
0.0000000 |
| SPY |
0.0073792 |
0.0018751 |
3.935340 |
0.0000894 |
| MCRSFT |
0.4660238 |
0.0188240 |
24.756916 |
0.0000000 |
Hypothesis Testing
Null Hypothesis (H0):
- Main Effect of Predictors:
- \(H_{0}:\) The predictors are
insignificant to predict Apple’s stock price.
Alternative Hypothesis (H1):
- Main Effect of Predictors:
- \(H_{a}:\) At least one of the
predictors is significant to predict Apple’s stock price.
ANOVA for Linear Regression Model
ANOVA Results
| RSI |
1 |
471.9744 |
471.9744 |
3.958394 |
0.0469375 |
| MACD |
1 |
29157.6463 |
29157.6463 |
244.541767 |
0.0000000 |
| Signal.Line |
1 |
5789.7432 |
5789.7432 |
48.557899 |
0.0000000 |
| Volume |
1 |
309231.7867 |
309231.7867 |
2593.490800 |
0.0000000 |
| SPY |
1 |
302070.7541 |
302070.7541 |
2533.432058 |
0.0000000 |
| MCRSFT |
1 |
73078.9859 |
73078.9859 |
612.904901 |
0.0000000 |
| Residuals |
909 |
108383.5324 |
119.2338 |
NA |
NA |
The model is statistically significant (p-value < 2e-16),
suggesting that at least one of the predictor variables has a
significant effect on the response variable.
The Adjusted R-squared of 0.868 indicates that the model explains
approximately 86.8% of the variability in the adjusted closing
prices.
Each coefficient’s p-value is provided, indicating the
significance of each predictor variable. each variable appears to be
statistically significant in predicting the adjusted closing
price.
Checking the Assumptions of the model
Based on the above plots we are majorly in line with the
assumptions:
The true Relationship is Linear
The Observations are Independent
The Variation is Constant
The Residuals are Normally distributed
Introducing Categorical Elements
Based on the signal line and market conditions i have introduced two
categorical variables:
- Signals: Buy, Sell and Hold
- Trend: Bullish or Bearish
#Hypothesis # Hypotheses Testing
Main Effect of Signal
Null Hypothesis (H0):
- \(H_{0}:\) There is no significant
difference among the different levels of the “Signal” variable after
controlling for the effect of the “Trend” variable.
Alternative Hypothesis (Ha):
- \(H_{1}:\) There is a significant
difference in the mean of the dependent variable among the different
levels of the “Signal” variable after controlling for the effect of the
“Trend” variable.
Main Effect of Trend
Null Hypothesis (H0):
- \(H_{0}:\) There is no significant
relationship between the “Trend” variable and the dependent variable
after accounting for differences in the “Signal” variable.
Alternative Hypothesis (Ha):
- \(H_{1}:\) There is a significant
relationship between the “Trend” variable and the dependent variable
after accounting for differences in the “Signal” variable.
ANCOVA Results
| (Intercept) |
1497.9063 |
1 |
12.249087 |
0.0004881 |
| RSI |
1971.4463 |
1 |
16.121448 |
0.0000643 |
| MACD |
1277.2086 |
1 |
10.444338 |
0.0012745 |
| SPY |
5014.2119 |
1 |
41.003581 |
0.0000000 |
| Signal |
201.0213 |
1 |
1.643846 |
0.2001255 |
| Trend |
1613.1472 |
1 |
13.191467 |
0.0002970 |
| MCRSFT |
72765.1787 |
1 |
595.035255 |
0.0000000 |
| Residuals |
111159.0396 |
909 |
NA |
NA |
Main Effects Analysis
Main Effect of Signal:
The p-value for Signal is 0.2001, which is greater than the
conventional significance level of 0.05. Therefore, we fail to reject
the null hypothesis. This suggests that there is no significant
difference in the mean of the dependent variable among the different
levels of the “Signal” variable.
Main Effect of Trend:
The p-value for Trend is 0.0003, which is less than 0.05. Therefore,
we reject the null hypothesis. This suggests that there is a significant
relationship between the “Trend” variable and the dependent variable
after accounting for differences in the “Signal” variable.
Interaction
Checking whether Buy and Sell signals have some connectivity with
market being Bullish or Bearish
Interaction Plot

The interaction plot further visualizes potential trends in adjusted
closing prices based on the categorical variables “Trend” and
“Signal.”
Conclusion
The analysis indicates that the included technical indicators and
external factors have a significant impact on predicting AAPL stock
prices. However, the main effect of the “Signal” variable is not
statistically significant, suggesting no significant difference in the
mean of adjusted closing prices among different signal levels. On the
other hand, the main effect of the “Trend” variable is found to be
significant, implying a relationship between the trend and adjusted
closing prices after considering differences in the signal
variable.
In conclusion, this study provides insights into the factors
influencing AAPL stock prices, offering valuable information for
researchers and investors. Further refinement of the model and
exploration of additional factors may enhance predictive accuracy and
actionable insights.
Limitations
Limited Time Period:
The analysis covers a specific time period, and the model’s
effectiveness may be influenced by market conditions during that
timeframe. Results might not generalize well to different market
environments.
External Factors:
External factors such as economic events, policy changes, or
unforeseen circumstances that occurred during the study period may not
be fully captured by the model.
Risk of Overfitting:
Including a large number of predictors in the model increases the
risk of overfitting, where the model performs well on the training data
but may not generalize effectively to new data.
Market Volatility:
The stock market is inherently volatile, and the model’s predictions
may be sensitive to market fluctuations, making it challenging to
accurately forecast prices.
Model Updating:
Financial markets evolve over time, and the model might need regular
updating to adapt to changing market dynamics. Failure to update the
model could impact its relevance.