Linear Regression Example
Linear Regression Example
(AAPL)
Objective: Analyze the relationship between the market return and the stock return
for Apple Inc. by calculating the coefficients of the linear regression model manually
and verifying the results using R.
Data:
1 5% 7%
2 10% 12%
3 15% 14%
4 20% 19%
5 25% 22%
Instructions:
o Calculate x (mean market return) and y (mean stock return) for Apple
Inc.
ˆ =
xt yt − Txy
x 2
t − Tx 2
ˆ = y − ˆ x
Prediction:
• If the market return X is predicted to increase by 10% in t+1 (from the last
observation), what would the predicted stock return Y be for t+1? Show your
calculations based on the linear regression model you derived.
Mean_Market_Return = mean(the_name_of_your_database$X),
SD_Market_Return = sd(the_name_of_your_database$X),
Mean_Stock_Return = mean(the_name_of_your_database$Y),
SD_Stock_Return = sd(the_name_of_your_database$Y) )
print(descriptive_stats)
o Load the data and run the regression model for Apple Inc. using the
following commands:
summary(apple_model)
4. Interpreting the results of the linear regression model
Objective: Analyze the relationship between the market return and the stock return for
Microsoft Corporation by calculating the coefficients of the linear regression model
manually and verifying the results using R.
Data:
1 3% 5%
2 8% 10%
3 12% 11%
4 15% 16%
5 20% 18%
6 5% 7%
7 10% 13%
8 18% 17%
9 22% 20%
10 25% 23%
11 30% 28%
12 35% 30%