Chapter 3: Single Hypothesis

library(readr)
df <- read_csv("volatility.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   VIX.Close = col_double(),
##   AAPL.Close = col_double(),
##   VXAPLCLS = col_double(),
##   VXAZNCLS = col_double(),
##   VXGOGCLS = col_double(),
##   GOOG.Close = col_double(),
##   AMZN.Close = col_double(),
##   GSPC.Close = col_double(),
##   Date = col_double(),
##   AAPL.Ret = col_double(),
##   AMZN.Ret = col_double(),
##   GOOG.Ret = col_double(),
##   GSPC.Ret = col_double(),
##   AAPL.Vol = col_double(),
##   AAPL.PVol = col_double(),
##   AMZN.PVol = col_double(),
##   GOOG.PVol = col_double(),
##   GSPC.PVol = col_double()
## )
head(df)
attach(df)

Beta1 hypothesis tests for linearity

Null Hypothesis: Beta1 = 0; no relation between X and Y

Construct a 95% Confidence Interval for the value of Beta1

If the interval contains zero, then there is no linear relation

mod <- lm(AAPL.Vol ~ AAPL.PVol)
CI_b11 = confint(mod)[2,]
CI_b11
##     2.5 %    97.5 % 
## 0.2830332 0.4454848
mod <- lm(AAPL.Vol ~ AMZN.PVol)
CI_b12 = confint(mod)[2,]
CI_b12
##     2.5 %    97.5 % 
## 0.3295250 0.4377032
mod <- lm(AAPL.Vol ~ GOOG.PVol)
CI_b13 = confint(mod)[2,]
CI_b13
##     2.5 %    97.5 % 
## 0.3373554 0.5163088
mod <- lm(AAPL.Vol ~ GSPC.PVol)
CI_b14 = confint(mod)[2,]
CI_b14
##     2.5 %    97.5 % 
## 0.4453690 0.6912425
mod <- lm(AAPL.Vol ~ AAPL.Close)
CI_b15 = confint(mod)[2,]
CI_b15
##         2.5 %        97.5 % 
## -0.0002754410 -0.0001322303
mod <- lm(AAPL.Vol ~ AMZN.Close)
CI_b16 = confint(mod)[2,]
CI_b16
##         2.5 %        97.5 % 
## -7.829995e-06 -1.486254e-06
mod <- lm(AAPL.Vol ~ GOOG.Close)
CI_b17 = confint(mod)[2,]
CI_b17
##         2.5 %        97.5 % 
## -3.414044e-05 -2.186995e-05
mod <- lm(AAPL.Vol ~ GSPC.Close)
CI_b18 = confint(mod)[2,]
CI_b18
##         2.5 %        97.5 % 
## -1.742576e-05 -1.061455e-05
mod <- lm(AAPL.Vol ~ VXAPLCLS)
CI_b19 = confint(mod)[2,]
CI_b19
##        2.5 %       97.5 % 
## 0.0006454469 0.0007882949
mod <- lm(AAPL.Vol ~ VXAZNCLS)
CI_b110 = confint(mod)[2,]
CI_b110
##        2.5 %       97.5 % 
## 0.0005032842 0.0006014044
mod <- lm(AAPL.Vol ~ VXGOGCLS)
CI_b111 = confint(mod)[2,]
CI_b111
##        2.5 %       97.5 % 
## 0.0007002769 0.0008519949
mod <- lm(AAPL.Vol ~ VIX.Close)
CI_b112 = confint(mod)[2,]
CI_b112
##        2.5 %       97.5 % 
## 0.0006023719 0.0008418008
mod <- lm(AAPL.Vol ~ AAPL.Ret)
CI_b113 = confint(mod)[2,]
CI_b113
##       2.5 %      97.5 % 
## -0.10211976 -0.03977091
mod <- lm(AAPL.Vol ~ AMZN.Ret)
CI_b114 = confint(mod)[2,]
CI_b114
##         2.5 %        97.5 % 
## -0.0583337486 -0.0004114984
mod <- lm(AAPL.Vol ~ GOOG.Ret)
CI_b115 = confint(mod)[2,]
CI_b115
##        2.5 %       97.5 % 
## -0.060172750  0.006721432
mod <- lm(AAPL.Vol ~ GSPC.Ret)
CI_b116 = confint(mod)[2,]
CI_b116
##      2.5 %     97.5 % 
## -0.1510560 -0.0349265

Although the beta1 value for several of the linear regressions was very close to zero, the only variable for which we can be statistically certain has NO linear relation with AAPL.Vol is GOOG.Ret.

Pvol predictors have positive linear relation. Close predictors have negative linear relation with slope very close to zero. VIX predictors have a positive linear relation with slope very close to zero. Return variables have mostly negative relations, but GOOG.Ret has no linear relation with AAPL.Vol.

Chapter 9

rm(list=ls())
library(corrplot)
## corrplot 0.84 loaded
df <- read.csv(file="./volatility.csv")
head(df)
AAPL.PVol = df$AAPL.PVol
GOOG.PVol = df$GOOG.PVol
AMZN.PVol = df$AMZN.PVol
GSPC.PVol = df$GSPC.PVol
VIX.Close = df$VIX.Close
AAPL.Close = df$AAPL.Close
VXAPLCLS = df$VXAPLCLS
VXAZNCLS = df$VXAZNCLS
VXGOGCLS = df$VXGOGCLS 
GOOG.Close = df$GOOG.Close
AMZN.Close = df$AMZN.Close
GSPC.Close = df$GSPC.Close 
Date = df$Date
AAPL.Ret = df$AAPL.Ret
AMZN.Ret = df$AMZN.Ret
GOOG.Ret = df$GOOG.Ret
GSPC.Ret = df$GSPC.Ret
AAPL.Vol = df$AAPL.Vol
#install.packages("olsrr")
library("olsrr")
## 
## Attaching package: 'olsrr'
## The following object is masked from 'package:datasets':
## 
##     rivers
mod <- lm(AAPL.Vol ~ VXAPLCLS+VXAZNCLS+VXGOGCLS+VIX.Close+AMZN.PVol+AAPL.PVol+AMZN.PVol+GOOG.PVol+GSPC.PVol, data=df)
k <- ols_step_all_possible(mod)
plot(k)

k
sub <- ols_step_best_subset(mod)
sub
plot(sub)

Forward Regression:

ols_step_forward_p(mod, details = TRUE)
## Forward Selection Method    
## ---------------------------
## 
## Candidate Terms: 
## 
## 1. VXAPLCLS 
## 2. VXAZNCLS 
## 3. VXGOGCLS 
## 4. VIX.Close 
## 5. AMZN.PVol 
## 6. AAPL.PVol 
## 7. GOOG.PVol 
## 8. GSPC.PVol 
## 
## We are selecting variables based on p value...
## 
## 
## Forward Selection: Step 1 
## 
## - VXAZNCLS 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.703       RMSE                0.004 
## R-Squared               0.494       Coef. Var          27.681 
## Adj. R-Squared          0.493       MSE                 0.000 
## Pred R-Squared          0.490       MAE                 0.004 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          1          0.010    489.282    0.0000 
## Residual        0.010        501          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                   
## ---------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
## ---------------------------------------------------------------------------------------
## (Intercept)    -0.001         0.001                 -0.695    0.487    -0.002    0.001 
##    VXAZNCLS     0.001         0.000        0.703    22.120    0.000     0.001    0.001 
## ---------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 2 
## 
## - VXAPLCLS 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.724       RMSE                0.004 
## R-Squared               0.524       Coef. Var          26.877 
## Adj. R-Squared          0.522       MSE                 0.000 
## Pred R-Squared          0.518       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          2          0.005    275.235    0.0000 
## Residual        0.010        500          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.889    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.480     9.562    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.282     5.608    0.000     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 3 
## 
## - GSPC.PVol 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.733       RMSE                0.004 
## R-Squared               0.537       Coef. Var          26.543 
## Adj. R-Squared          0.534       MSE                 0.000 
## Pred R-Squared          0.530       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004     192.67    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.539    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.549    10.362    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.311     6.188    0.000     0.000     0.000 
##   GSPC.PVol    -0.221         0.060       -0.146    -3.692    0.000    -0.339    -0.104 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 4 
## 
## - GOOG.PVol 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.743       RMSE                0.004 
## R-Squared               0.552       Coef. Var          26.114 
## Adj. R-Squared          0.549       MSE                 0.000 
## Pred R-Squared          0.544       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          4          0.003    153.684    0.0000 
## Residual        0.009        498          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.006         0.001                 -5.729    0.000    -0.008    -0.004 
##    VXAZNCLS     0.000         0.000        0.556    10.650    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.301     6.075    0.000     0.000     0.000 
##   GSPC.PVol    -0.485         0.086       -0.321    -5.623    0.000    -0.654    -0.315 
##   GOOG.PVol     0.239         0.057        0.217     4.190    0.000     0.127     0.351 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 5 
## 
## - VIX.Close 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.748       RMSE                0.004 
## R-Squared               0.560       Coef. Var          25.916 
## Adj. R-Squared          0.556       MSE                 0.000 
## Pred R-Squared          0.550       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          5          0.002    126.556    0.0000 
## Residual        0.009        497          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.005         0.001                 -4.946    0.000    -0.007    -0.003 
##    VXAZNCLS     0.000         0.000        0.591    11.117    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.342     6.691    0.000     0.000     0.000 
##   GSPC.PVol    -0.420         0.088       -0.278    -4.754    0.000    -0.594    -0.246 
##   GOOG.PVol     0.278         0.058        0.252     4.781    0.000     0.164     0.393 
##   VIX.Close     0.000         0.000       -0.158    -2.937    0.003     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 6 
## 
## - AMZN.PVol 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.751       RMSE                0.004 
## R-Squared               0.564       Coef. Var          25.835 
## Adj. R-Squared          0.558       MSE                 0.000 
## Pred R-Squared          0.551       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          6          0.002    106.815    0.0000 
## Residual        0.009        496          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.322    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.527     8.541    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.350     6.859    0.000     0.000     0.000 
##   GSPC.PVol    -0.495         0.095       -0.327    -5.184    0.000    -0.682    -0.307 
##   GOOG.PVol     0.233         0.062        0.210     3.734    0.000     0.110     0.355 
##   VIX.Close     0.000         0.000       -0.136    -2.481    0.013     0.000     0.000 
##   AMZN.PVol     0.092         0.045        0.127     2.032    0.043     0.003     0.181 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Forward Selection: Step 7 
## 
## - AAPL.PVol 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## No more variables to be added.
## 
## Variables Entered: 
## 
## + VXAZNCLS 
## + VXAPLCLS 
## + GSPC.PVol 
## + GOOG.PVol 
## + VIX.Close 
## + AMZN.PVol 
## + AAPL.PVol 
## 
## 
## Final Model Output 
## ------------------
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
## ----------------------------------------------------------------------------------------
## 
##                              Selection Summary                               
## ----------------------------------------------------------------------------
##         Variable                   Adj.                                         
## Step     Entered     R-Square    R-Square     C(p)         AIC         RMSE     
## ----------------------------------------------------------------------------
##    1    VXAZNCLS       0.4941      0.4931    81.2384    -4006.8538    0.0045    
##    2    VXAPLCLS       0.5240      0.5221    48.9014    -4035.5372    0.0044    
##    3    GSPC.PVol      0.5367      0.5339    36.3838    -4047.0950    0.0043    
##    4    GOOG.PVol      0.5525      0.5489    20.2916    -4062.5191    0.0042    
##    5    VIX.Close      0.5601      0.5557    13.5341    -4069.1750    0.0042    
##    6    AMZN.PVol      0.5637      0.5584    11.3705    -4071.3432    0.0042    
##    7    AAPL.PVol      0.5693      0.5632     7.0234    -4075.7645    0.0042    
## ----------------------------------------------------------------------------

Stepwise Backward Regression

k <- ols_step_backward_p(mod, details=TRUE)
## Backward Elimination Method 
## ---------------------------
## 
## Candidate Terms: 
## 
## 1 . VXAPLCLS 
## 2 . VXAZNCLS 
## 3 . VXGOGCLS 
## 4 . VIX.Close 
## 5 . AMZN.PVol 
## 6 . AAPL.PVol 
## 7 . GOOG.PVol 
## 8 . GSPC.PVol 
## 
## We are eliminating variables based on p value...
## 
## - VXGOGCLS 
## 
## Backward Elimination: Step 1 
## 
##  Variable VXGOGCLS Removed 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## No more variables satisfy the condition of p value = 0.3
## 
## 
## Variables Removed: 
## 
## - VXGOGCLS 
## 
## 
## Final Model Output 
## ------------------
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
## ----------------------------------------------------------------------------------------
k
## 
## 
##                            Elimination Summary                             
## --------------------------------------------------------------------------
##         Variable                  Adj.                                        
## Step    Removed     R-Square    R-Square     C(p)        AIC         RMSE     
## --------------------------------------------------------------------------
##    1    VXGOGCLS      0.5693      0.5632    7.0234    -4075.7645    0.0042    
## --------------------------------------------------------------------------

Stepwise Regression

Build regression model from a set of candidate predictor variables by entering and removing predictors based on p values, in a stepwise manner until there is no variable left to enter or remove any more. The model should include all the candidate predictor variables. If details is set to TRUE, each step is displayed.

ols_step_both_p(mod, details = TRUE)
## Stepwise Selection Method   
## ---------------------------
## 
## Candidate Terms: 
## 
## 1. VXAPLCLS 
## 2. VXAZNCLS 
## 3. VXGOGCLS 
## 4. VIX.Close 
## 5. AMZN.PVol 
## 6. AAPL.PVol 
## 7. GOOG.PVol 
## 8. GSPC.PVol 
## 
## We are selecting variables based on p value...
## 
## 
## Stepwise Selection: Step 1 
## 
## - VXAZNCLS added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.703       RMSE                0.004 
## R-Squared               0.494       Coef. Var          27.681 
## Adj. R-Squared          0.493       MSE                 0.000 
## Pred R-Squared          0.490       MAE                 0.004 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          1          0.010    489.282    0.0000 
## Residual        0.010        501          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                   
## ---------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
## ---------------------------------------------------------------------------------------
## (Intercept)    -0.001         0.001                 -0.695    0.487    -0.002    0.001 
##    VXAZNCLS     0.001         0.000        0.703    22.120    0.000     0.001    0.001 
## ---------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 2 
## 
## - VXAPLCLS added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.724       RMSE                0.004 
## R-Squared               0.524       Coef. Var          26.877 
## Adj. R-Squared          0.522       MSE                 0.000 
## Pred R-Squared          0.518       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          2          0.005    275.235    0.0000 
## Residual        0.010        500          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.889    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.480     9.562    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.282     5.608    0.000     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.724       RMSE                0.004 
## R-Squared               0.524       Coef. Var          26.877 
## Adj. R-Squared          0.522       MSE                 0.000 
## Pred R-Squared          0.518       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          2          0.005    275.235    0.0000 
## Residual        0.010        500          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.889    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.480     9.562    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.282     5.608    0.000     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 3 
## 
## - GSPC.PVol added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.733       RMSE                0.004 
## R-Squared               0.537       Coef. Var          26.543 
## Adj. R-Squared          0.534       MSE                 0.000 
## Pred R-Squared          0.530       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004     192.67    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.539    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.549    10.362    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.311     6.188    0.000     0.000     0.000 
##   GSPC.PVol    -0.221         0.060       -0.146    -3.692    0.000    -0.339    -0.104 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.733       RMSE                0.004 
## R-Squared               0.537       Coef. Var          26.543 
## Adj. R-Squared          0.534       MSE                 0.000 
## Pred R-Squared          0.530       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004     192.67    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.539    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.549    10.362    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.311     6.188    0.000     0.000     0.000 
##   GSPC.PVol    -0.221         0.060       -0.146    -3.692    0.000    -0.339    -0.104 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 4 
## 
## - GOOG.PVol added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.743       RMSE                0.004 
## R-Squared               0.552       Coef. Var          26.114 
## Adj. R-Squared          0.549       MSE                 0.000 
## Pred R-Squared          0.544       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          4          0.003    153.684    0.0000 
## Residual        0.009        498          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.006         0.001                 -5.729    0.000    -0.008    -0.004 
##    VXAZNCLS     0.000         0.000        0.556    10.650    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.301     6.075    0.000     0.000     0.000 
##   GSPC.PVol    -0.485         0.086       -0.321    -5.623    0.000    -0.654    -0.315 
##   GOOG.PVol     0.239         0.057        0.217     4.190    0.000     0.127     0.351 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.743       RMSE                0.004 
## R-Squared               0.552       Coef. Var          26.114 
## Adj. R-Squared          0.549       MSE                 0.000 
## Pred R-Squared          0.544       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          4          0.003    153.684    0.0000 
## Residual        0.009        498          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.006         0.001                 -5.729    0.000    -0.008    -0.004 
##    VXAZNCLS     0.000         0.000        0.556    10.650    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.301     6.075    0.000     0.000     0.000 
##   GSPC.PVol    -0.485         0.086       -0.321    -5.623    0.000    -0.654    -0.315 
##   GOOG.PVol     0.239         0.057        0.217     4.190    0.000     0.127     0.351 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 5 
## 
## - VIX.Close added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.748       RMSE                0.004 
## R-Squared               0.560       Coef. Var          25.916 
## Adj. R-Squared          0.556       MSE                 0.000 
## Pred R-Squared          0.550       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          5          0.002    126.556    0.0000 
## Residual        0.009        497          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.005         0.001                 -4.946    0.000    -0.007    -0.003 
##    VXAZNCLS     0.000         0.000        0.591    11.117    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.342     6.691    0.000     0.000     0.000 
##   GSPC.PVol    -0.420         0.088       -0.278    -4.754    0.000    -0.594    -0.246 
##   GOOG.PVol     0.278         0.058        0.252     4.781    0.000     0.164     0.393 
##   VIX.Close     0.000         0.000       -0.158    -2.937    0.003     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.748       RMSE                0.004 
## R-Squared               0.560       Coef. Var          25.916 
## Adj. R-Squared          0.556       MSE                 0.000 
## Pred R-Squared          0.550       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          5          0.002    126.556    0.0000 
## Residual        0.009        497          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.005         0.001                 -4.946    0.000    -0.007    -0.003 
##    VXAZNCLS     0.000         0.000        0.591    11.117    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.342     6.691    0.000     0.000     0.000 
##   GSPC.PVol    -0.420         0.088       -0.278    -4.754    0.000    -0.594    -0.246 
##   GOOG.PVol     0.278         0.058        0.252     4.781    0.000     0.164     0.393 
##   VIX.Close     0.000         0.000       -0.158    -2.937    0.003     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 6 
## 
## - AMZN.PVol added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.751       RMSE                0.004 
## R-Squared               0.564       Coef. Var          25.835 
## Adj. R-Squared          0.558       MSE                 0.000 
## Pred R-Squared          0.551       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          6          0.002    106.815    0.0000 
## Residual        0.009        496          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.322    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.527     8.541    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.350     6.859    0.000     0.000     0.000 
##   GSPC.PVol    -0.495         0.095       -0.327    -5.184    0.000    -0.682    -0.307 
##   GOOG.PVol     0.233         0.062        0.210     3.734    0.000     0.110     0.355 
##   VIX.Close     0.000         0.000       -0.136    -2.481    0.013     0.000     0.000 
##   AMZN.PVol     0.092         0.045        0.127     2.032    0.043     0.003     0.181 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.751       RMSE                0.004 
## R-Squared               0.564       Coef. Var          25.835 
## Adj. R-Squared          0.558       MSE                 0.000 
## Pred R-Squared          0.551       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          6          0.002    106.815    0.0000 
## Residual        0.009        496          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -4.322    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.527     8.541    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.350     6.859    0.000     0.000     0.000 
##   GSPC.PVol    -0.495         0.095       -0.327    -5.184    0.000    -0.682    -0.307 
##   GOOG.PVol     0.233         0.062        0.210     3.734    0.000     0.110     0.355 
##   VIX.Close     0.000         0.000       -0.136    -2.481    0.013     0.000     0.000 
##   AMZN.PVol     0.092         0.045        0.127     2.032    0.043     0.003     0.181 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 7 
## 
## - AAPL.PVol added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## No more variables to be added/removed.
## 
## 
## Final Model Output 
## ------------------
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.754       RMSE                0.004 
## R-Squared               0.569       Coef. Var          25.696 
## Adj. R-Squared          0.563       MSE                 0.000 
## Pred R-Squared          0.555       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                ANOVA                                 
## --------------------------------------------------------------------
##                Sum of                                               
##               Squares         DF    Mean Square      F         Sig. 
## --------------------------------------------------------------------
## Regression      0.011          7          0.002    93.453    0.0000 
## Residual        0.009        495          0.000                     
## Total           0.020        502                                    
## --------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.406    0.001    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.488     7.705    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.379     7.282    0.000     0.000     0.001 
##   GSPC.PVol    -0.398         0.102       -0.264    -3.893    0.000    -0.599    -0.197 
##   GOOG.PVol     0.258         0.063        0.234     4.112    0.000     0.135     0.381 
##   VIX.Close     0.000         0.000       -0.154    -2.807    0.005     0.000     0.000 
##   AMZN.PVol     0.162         0.053        0.223     3.059    0.002     0.058     0.266 
##   AAPL.PVol    -0.166         0.066       -0.167    -2.522    0.012    -0.296    -0.037 
## ----------------------------------------------------------------------------------------
## 
##                                Stepwise Selection Summary                                
## ----------------------------------------------------------------------------------------
##                       Added/                   Adj.                                         
## Step    Variable     Removed     R-Square    R-Square     C(p)         AIC         RMSE     
## ----------------------------------------------------------------------------------------
##    1    VXAZNCLS     addition       0.494       0.493    81.2380    -4006.8538    0.0045    
##    2    VXAPLCLS     addition       0.524       0.522    48.9010    -4035.5372    0.0044    
##    3    GSPC.PVol    addition       0.537       0.534    36.3840    -4047.0950    0.0043    
##    4    GOOG.PVol    addition       0.552       0.549    20.2920    -4062.5191    0.0042    
##    5    VIX.Close    addition       0.560       0.556    13.5340    -4069.1750    0.0042    
##    6    AMZN.PVol    addition       0.564       0.558    11.3700    -4071.3432    0.0042    
##    7    AAPL.PVol    addition       0.569       0.563     7.0230    -4075.7645    0.0042    
## ----------------------------------------------------------------------------------------
new_mod <- lm(AAPL.Vol ~ VXAPLCLS+VXAZNCLS+VXGOGCLS+VIX.Close+AMZN.PVol, data=df)
k <- ols_step_both_p(new_mod, details = TRUE)
## Stepwise Selection Method   
## ---------------------------
## 
## Candidate Terms: 
## 
## 1. VXAPLCLS 
## 2. VXAZNCLS 
## 3. VXGOGCLS 
## 4. VIX.Close 
## 5. AMZN.PVol 
## 
## We are selecting variables based on p value...
## 
## 
## Stepwise Selection: Step 1 
## 
## - VXAZNCLS added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.703       RMSE                0.004 
## R-Squared               0.494       Coef. Var          27.681 
## Adj. R-Squared          0.493       MSE                 0.000 
## Pred R-Squared          0.490       MAE                 0.004 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          1          0.010    489.282    0.0000 
## Residual        0.010        501          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                   
## ---------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
## ---------------------------------------------------------------------------------------
## (Intercept)    -0.001         0.001                 -0.695    0.487    -0.002    0.001 
##    VXAZNCLS     0.001         0.000        0.703    22.120    0.000     0.001    0.001 
## ---------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 2 
## 
## - VXAPLCLS added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.724       RMSE                0.004 
## R-Squared               0.524       Coef. Var          26.877 
## Adj. R-Squared          0.522       MSE                 0.000 
## Pred R-Squared          0.518       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          2          0.005    275.235    0.0000 
## Residual        0.010        500          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.889    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.480     9.562    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.282     5.608    0.000     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.724       RMSE                0.004 
## R-Squared               0.524       Coef. Var          26.877 
## Adj. R-Squared          0.522       MSE                 0.000 
## Pred R-Squared          0.518       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.010          2          0.005    275.235    0.0000 
## Residual        0.010        500          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.004         0.001                 -3.889    0.000    -0.006    -0.002 
##    VXAZNCLS     0.000         0.000        0.480     9.562    0.000     0.000     0.000 
##    VXAPLCLS     0.000         0.000        0.282     5.608    0.000     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## Stepwise Selection: Step 3 
## 
## - VIX.Close added 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.732       RMSE                0.004 
## R-Squared               0.535       Coef. Var          26.579 
## Adj. R-Squared          0.533       MSE                 0.000 
## Pred R-Squared          0.528       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004    191.694    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.003         0.001                 -3.237    0.001    -0.005    -0.001 
##    VXAZNCLS     0.000         0.000        0.549    10.278    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.339     6.483    0.000     0.000     0.000 
##   VIX.Close     0.000         0.000       -0.160    -3.498    0.001     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.732       RMSE                0.004 
## R-Squared               0.535       Coef. Var          26.579 
## Adj. R-Squared          0.533       MSE                 0.000 
## Pred R-Squared          0.528       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004    191.694    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.003         0.001                 -3.237    0.001    -0.005    -0.001 
##    VXAZNCLS     0.000         0.000        0.549    10.278    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.339     6.483    0.000     0.000     0.000 
##   VIX.Close     0.000         0.000       -0.160    -3.498    0.001     0.000     0.000 
## ----------------------------------------------------------------------------------------
## 
## 
## 
## No more variables to be added/removed.
## 
## 
## Final Model Output 
## ------------------
## 
##                         Model Summary                          
## --------------------------------------------------------------
## R                       0.732       RMSE                0.004 
## R-Squared               0.535       Coef. Var          26.579 
## Adj. R-Squared          0.533       MSE                 0.000 
## Pred R-Squared          0.528       MAE                 0.003 
## --------------------------------------------------------------
##  RMSE: Root Mean Square Error 
##  MSE: Mean Square Error 
##  MAE: Mean Absolute Error 
## 
##                                 ANOVA                                 
## ---------------------------------------------------------------------
##                Sum of                                                
##               Squares         DF    Mean Square       F         Sig. 
## ---------------------------------------------------------------------
## Regression      0.011          3          0.004    191.694    0.0000 
## Residual        0.009        499          0.000                      
## Total           0.020        502                                     
## ---------------------------------------------------------------------
## 
##                                   Parameter Estimates                                    
## ----------------------------------------------------------------------------------------
##       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
## ----------------------------------------------------------------------------------------
## (Intercept)    -0.003         0.001                 -3.237    0.001    -0.005    -0.001 
##    VXAZNCLS     0.000         0.000        0.549    10.278    0.000     0.000     0.001 
##    VXAPLCLS     0.000         0.000        0.339     6.483    0.000     0.000     0.000 
##   VIX.Close     0.000         0.000       -0.160    -3.498    0.001     0.000     0.000 
## ----------------------------------------------------------------------------------------
plot(k)

k
## 
##                                Stepwise Selection Summary                                
## ----------------------------------------------------------------------------------------
##                       Added/                   Adj.                                         
## Step    Variable     Removed     R-Square    R-Square     C(p)         AIC         RMSE     
## ----------------------------------------------------------------------------------------
##    1    VXAZNCLS     addition       0.494       0.493    44.5640    -4006.8538    0.0045    
##    2    VXAPLCLS     addition       0.524       0.522    14.3970    -4035.5372    0.0044    
##    3    VIX.Close    addition       0.535       0.533     4.1540    -4045.7258    0.0043    
## ----------------------------------------------------------------------------------------
m <- new_mod
inf_df <- data.frame(
  "dffits" = dffits(m),
  "cooks" = cooks.distance(m),
  "dfb1" = dfbetas(m)[,1],
  "dfb2" = dfbetas(m)[,2],
  "dfb3" = dfbetas(m)[,3],
  "dfb4" = dfbetas(m)[,4],
  "dfb5" = dfbetas(m)[,5]
)
plot(inf_df$cooks, type = "l",col="red")

Chapter 8:

For the full regression,the adjusted R-squared of the full regression was 0.5836, the p-value of variables VIX.Close,AAPL.Close,VXGOGCLS,GOOG.Close,AAPL.Ret,GOOG.Ret and GSPC.Ret are all less than 0.05, so we may wish to know whether these variables can be dropped from the full model. For level of significance alpha = 0.05, we require F(0.95; 486, 493) = 1.1604. Since F* = 1.5935 >= 1.1604and the p-value of F is 0.1349 > 0.05, we conclude H0 , that variables VIX.Close, AAPL.Close, VXGOGCLS, GOOG.Close, AAPL.Ret, GOOG.Ret and GSPC.Ret should be dropped from the full regression model.

volatility_df <- read.csv("volatility.csv")
volatility_df$Date<-NULL
fit1<-lm(AAPL.Vol~.,volatility_df)
summary(fit1)
## 
## Call:
## lm(formula = AAPL.Vol ~ ., data = volatility_df)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0088397 -0.0028762 -0.0002416  0.0022632  0.0165948 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -3.744e-02  9.141e-03  -4.096 4.93e-05 ***
## VIX.Close   -1.497e-04  9.404e-05  -1.592 0.112078    
## AAPL.Close  -6.918e-05  6.127e-05  -1.129 0.259388    
## VXAPLCLS     2.560e-04  6.928e-05   3.695 0.000245 ***
## VXAZNCLS     4.842e-04  8.190e-05   5.912 6.38e-09 ***
## VXGOGCLS     6.316e-05  1.129e-04   0.560 0.576046    
## GOOG.Close   5.568e-06  5.328e-06   1.045 0.296552    
## AMZN.Close   3.077e-06  1.506e-06   2.043 0.041623 *  
## GSPC.Close   8.004e-06  3.878e-06   2.064 0.039535 *  
## AAPL.Ret    -1.439e-02  1.656e-02  -0.869 0.385400    
## AMZN.Ret     3.271e-02  1.531e-02   2.137 0.033104 *  
## GOOG.Ret     2.615e-02  1.818e-02   1.439 0.150882    
## GSPC.Ret    -6.291e-02  4.008e-02  -1.570 0.117152    
## AAPL.PVol   -2.104e-01  6.722e-02  -3.130 0.001851 ** 
## AMZN.PVol    2.110e-01  5.787e-02   3.645 0.000296 ***
## GOOG.PVol    2.831e-01  6.789e-02   4.169 3.62e-05 ***
## GSPC.PVol   -3.270e-01  1.129e-01  -2.896 0.003949 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.00407 on 486 degrees of freedom
## Multiple R-squared:  0.5968, Adjusted R-squared:  0.5836 
## F-statistic: 44.97 on 16 and 486 DF,  p-value: < 2.2e-16
fit2<-lm(AAPL.Vol~VXAPLCLS+VXAZNCLS+AMZN.Close+GSPC.Close+AMZN.Ret+AAPL.PVol+AMZN.PVol+GOOG.PVol+GSPC.PVol,volatility_df)
summary(fit2)
## 
## Call:
## lm(formula = AAPL.Vol ~ VXAPLCLS + VXAZNCLS + AMZN.Close + GSPC.Close + 
##     AMZN.Ret + AAPL.PVol + AMZN.PVol + GOOG.PVol + GSPC.PVol, 
##     data = volatility_df)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0083519 -0.0026370 -0.0004731  0.0023915  0.0164127 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -3.092e-02  6.389e-03  -4.840 1.74e-06 ***
## VXAPLCLS     2.454e-04  6.220e-05   3.946 9.11e-05 ***
## VXAZNCLS     5.043e-04  5.766e-05   8.746  < 2e-16 ***
## AMZN.Close   3.328e-06  1.463e-06   2.275 0.023343 *  
## GSPC.Close   6.559e-06  2.262e-06   2.900 0.003901 ** 
## AMZN.Ret     2.376e-02  1.006e-02   2.361 0.018618 *  
## AAPL.PVol   -1.893e-01  6.550e-02  -2.890 0.004027 ** 
## AMZN.PVol    1.875e-01  5.209e-02   3.599 0.000352 ***
## GOOG.PVol    2.480e-01  6.195e-02   4.002 7.24e-05 ***
## GSPC.PVol   -3.798e-01  1.033e-01  -3.678 0.000261 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.004087 on 493 degrees of freedom
## Multiple R-squared:  0.5876, Adjusted R-squared:  0.5801 
## F-statistic: 78.05 on 9 and 493 DF,  p-value: < 2.2e-16
anova(fit1,fit2)
par(mfrow=c(1,2))
plot(fit1,which=1)
plot(fit2,which=1)

Lekha - Chapter 8 (Transformation Part)

Importing required data:

rm(list=ls())
library(corrplot)
df <- read.csv(file="volatility.csv")
head(df)
AAPL.PVol = df$AAPL.PVol
GOOG.PVol = df$GOOG.PVol
AMZN.PVol = df$AMZN.PVol
GSPC.PVol = df$GSPC.PVol
VIX.Close = df$VIX.Close
AAPL.Close = df$AAPL.Close
VXAPLCLS = df$VXAPLCLS
VXAZNCLS = df$VXAZNCLS
VXGOGCLS = df$VXGOGCLS 
GOOG.Close = df$GOOG.Close
AMZN.Close = df$AMZN.Close
GSPC.Close = df$GSPC.Close 
Date = df$Date
AAPL.Ret = df$AAPL.Ret
AMZN.Ret = df$AMZN.Ret
GOOG.Ret = df$GOOG.Ret
GSPC.Ret = df$GSPC.Ret
AAPL.Vol = df$AAPL.Vol
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)

We will check for higher-order terms and whether they’re necessary to add or not by centering the predictor variables for each case, and performing required tests on these centered predictor variables and Y. For each one, we considered \(\alpha = 0.05\).

Y = AAPL.Vol

Starting with:

AAPL.Vol vs AAPL.PVol:

currX = AAPL.PVol
n = length(AAPL.Vol)
Xbar = sum(AAPL.PVol)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.013281 -0.004299 -0.001671  0.003755  0.015198 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.0158368  0.0003359  47.150  < 2e-16 ***
## smallx      0.3092554  0.0511319   6.048 2.87e-09 ***
## xsquare     9.5705312  5.2578866   1.820   0.0693 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005861 on 500 degrees of freedom
## Multiple R-squared:  0.1399, Adjusted R-squared:  0.1364 
## F-statistic: 40.65 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AAPL.PVol and AAPL.Vol, but now doing the same when AAPL.PVol is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3
## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = 0.00011380 / (0.0171732/dfsse)

#or could be taken from ANOVA table
Fobs = curranova[2,4]
Fobs
## [1] 3.313215

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, in the case of predictor variable AAPL.Vol, we can use linear model of order 1, and not add its square.

Now, to de-center our function, we replace x by \(X - \bar{X}\). Since we anyway will not consider the quadratic term, we can just state the linear regression equation as it is for Y and X:

mod = lm(Y ~ currX)
mod$coefficients
## (Intercept)       currX 
##   0.0103326   0.3642590

\[\hat{Y} = 0.01033 + 0.3643X_1\]

AAPL.Vol vs AMZN.PVol higher order:

currX = AMZN.PVol
n = length(AAPL.Vol)
Xbar = sum(AMZN.PVol)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0101734 -0.0039287 -0.0008275  0.0034527  0.0135901 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.486e-02  3.151e-04  47.155  < 2e-16 ***
## smallx      1.970e-01  3.965e-02   4.969 9.25e-07 ***
## xsquare     1.808e+01  2.857e+00   6.330 5.46e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005162 on 500 degrees of freedom
## Multiple R-squared:  0.3328, Adjusted R-squared:  0.3301 
## F-statistic: 124.7 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AMZN.PVol and AAPL.Vol, but now doing the same when AMZN.PVol is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 40.06772
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 40.06772

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term of AMZN.PVol is significant.

AAPL.Vol vs GOOG.PVol higher order:

currX = GOOG.PVol
n = length(AAPL.Vol)
Xbar = sum(GOOG.PVol)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.013832 -0.004297 -0.000841  0.003069  0.018441 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.434e-02  3.818e-04  37.554  < 2e-16 ***
## smallx      3.085e-01  4.739e-02   6.508 1.85e-10 ***
## xsquare     5.792e+01  8.892e+00   6.513 1.79e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005596 on 500 degrees of freedom
## Multiple R-squared:  0.2157, Adjusted R-squared:  0.2126 
## F-statistic: 68.76 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between GOOG.PVol and AAPL.Vol, but now doing the same when GOOG.PVol is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 42.42305
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 42.42305

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term \(X^2\) in the case of GOOG.PVol is significant.

AAPL.Vol vs GSPC.PVol higher order:

currX = GSPC.PVol
n = length(AAPL.Vol)
Xbar = sum(GSPC.PVol)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.010839 -0.004529 -0.001325  0.003793  0.017576 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.523e-02  3.766e-04  40.434  < 2e-16 ***
## smallx      3.787e-01  8.104e-02   4.673 3.82e-06 ***
## xsquare     5.719e+01  1.580e+01   3.619 0.000326 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.00578 on 500 degrees of freedom
## Multiple R-squared:  0.1633, Adjusted R-squared:  0.1599 
## F-statistic: 48.79 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between GSPC.PVol and AAPL.Vol, but now doing the same when GSPC.PVol is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 13.09402
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 13.09402

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term for GSPC.PVol is significant.

AAPL.Vol vs AAPL.Close higher order:

currX = AAPL.Close
n = length(AAPL.Vol)
Xbar = sum(AAPL.Close)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.010134 -0.003786 -0.001354  0.003274  0.017791 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.623e-02  3.412e-04  47.563  < 2e-16 ***
## smallx      -2.030e-04  4.408e-05  -4.605 5.23e-06 ***
## xsquare     -1.232e-07  3.637e-06  -0.034    0.973    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006131 on 500 degrees of freedom
## Multiple R-squared:  0.05877,    Adjusted R-squared:  0.055 
## F-statistic: 15.61 on 2 and 500 DF,  p-value: 2.656e-07

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AAPL.Close and AAPL.Vol, but now doing the same when AAPL.Close is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 0.001147359
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 0.001147359

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, in the case of AAPL.Close, its quadratic term isn’t significant.

AAPL.Vol vs AMZN.Close higher order:

currX = AMZN.Close
n = length(AAPL.Vol)
Xbar = sum(AMZN.Close)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.014740 -0.004550 -0.001449  0.003090  0.019341 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.539e-02  3.507e-04  43.901  < 2e-16 ***
## smallx      -1.827e-06  1.758e-06  -1.039 0.299267    
## xsquare      2.764e-08  7.256e-09   3.809 0.000157 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006178 on 500 degrees of freedom
## Multiple R-squared:  0.04409,    Adjusted R-squared:  0.04026 
## F-statistic: 11.53 on 2 and 500 DF,  p-value: 1.272e-05

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AMZN.Close and AAPL.Vol, but now doing the same when AMZN.Close is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 14.51073
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 14.51073

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for AMZN.Close is significant

AAPL.Vol vs GOOG.Close higher order:

currX = GOOG.Close
n = length(AAPL.Vol)
Xbar = sum(GOOG.Close)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0121719 -0.0033757 -0.0008007  0.0032752  0.0174526 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.583e-02  3.388e-04  46.705   <2e-16 ***
## smallx      -2.995e-05  3.292e-06  -9.098   <2e-16 ***
## xsquare      5.653e-08  3.092e-08   1.828   0.0681 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005846 on 500 degrees of freedom
## Multiple R-squared:  0.1441, Adjusted R-squared:  0.1406 
## F-statistic: 42.07 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between GOOG.Close and AAPL.Vol, but now doing the same when GOOG.Close is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 3.343177
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 3.343177

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for GOOG.Close is not significant.

AAPL.Vol vs GSPC.Close higher order:

currX = GSPC.Close
n = length(AAPL.Vol)
Xbar = sum(GSPC.Close)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0115261 -0.0036555 -0.0009736  0.0040549  0.0184977 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.558e-02  3.199e-04  48.713  < 2e-16 ***
## smallx      -1.507e-05  1.741e-06  -8.654  < 2e-16 ***
## xsquare      2.731e-08  7.880e-09   3.465 0.000575 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005873 on 500 degrees of freedom
## Multiple R-squared:  0.1362, Adjusted R-squared:  0.1328 
## F-statistic: 39.43 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between GSPC.Close and AAPL.Vol, but now doing the same when GSPC.Close is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 12.009
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 12.009

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term \(X^2\) for GSPC.Close is significant.

AAPL.Vol vs VXAPLCLS higher order:

currX = VXAPLCLS
n = length(AAPL.Vol)
Xbar = sum(VXAPLCLS)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0114239 -0.0036964 -0.0007178  0.0033604  0.0190810 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.605e-02  2.497e-04  64.259   <2e-16 ***
## smallx      6.943e-04  4.028e-05  17.236   <2e-16 ***
## xsquare     5.135e-06  3.955e-06   1.298    0.195    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.004734 on 500 degrees of freedom
## Multiple R-squared:  0.4389, Adjusted R-squared:  0.4366 
## F-statistic: 195.5 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between VXAPLCLS and AAPL.Vol, but now doing the same when VXAPLCLS is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 1.685429
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 1.685429

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for VXAPLCLS is not significant.

AAPL.Vol vs VXAZNCLS higher order:

currX = VXAZNCLS
n = length(AAPL.Vol)
Xbar = sum(VXAZNCLS)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0110639 -0.0030523 -0.0003204  0.0026780  0.0173869 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.594e-02  2.630e-04  60.616   <2e-16 ***
## smallx      5.234e-04  3.052e-05  17.152   <2e-16 ***
## xsquare     4.367e-06  2.659e-06   1.643    0.101    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.004483 on 500 degrees of freedom
## Multiple R-squared:  0.4968, Adjusted R-squared:  0.4948 
## F-statistic: 246.8 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between VXAZNCLS and AAPL.Vol, but now doing the same when VXAZNCLS is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 2.698467
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 2.698467

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for VXAZNCLS is not significant.

AAPL.Vol vs VXGOGCLS higher order:

currX = VXGOGCLS
n = length(AAPL.Vol)
Xbar = sum(VXGOGCLS)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0116470 -0.0032753 -0.0002388  0.0029779  0.0176801 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.587e-02  2.701e-04  58.739   <2e-16 ***
## smallx      7.340e-04  4.358e-05  16.844   <2e-16 ***
## xsquare     1.202e-05  5.829e-06   2.062   0.0397 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.004682 on 500 degrees of freedom
## Multiple R-squared:  0.4511, Adjusted R-squared:  0.4489 
## F-statistic: 205.5 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between VXGOGCLS and AAPL.Vol, but now doing the same when VXGOGCLS is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 4.25168
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 4.25168

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for VXGOGCLS is significant.

AAPL.Vol vs VIX.Close higher order:

currX = VIX.Close
n = length(AAPL.Vol)
Xbar = sum(VIX.Close)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.015370 -0.004054 -0.000990  0.003382  0.018212 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.620e-02  2.857e-04  56.717   <2e-16 ***
## smallx      7.153e-04  8.025e-05   8.913   <2e-16 ***
## xsquare     1.095e-06  8.401e-06   0.130    0.896    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005585 on 500 degrees of freedom
## Multiple R-squared:  0.219,  Adjusted R-squared:  0.2158 
## F-statistic: 70.09 on 2 and 500 DF,  p-value: < 2.2e-16

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between VIX.Close and AAPL.Vol, but now doing the same when VIX.Close is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 0.01698776
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 0.01698776

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is less than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for VIX.Close is not significant.

AAPL.Vol vs AAPL.Ret higher order:

currX = AAPL.Ret
n = length(AAPL.Vol)
Xbar = sum(AAPL.Ret)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.014072 -0.004654 -0.001502  0.003897  0.019557 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.0158752  0.0002959  53.646  < 2e-16 ***
## smallx      -0.0593904  0.0161778  -3.671 0.000267 ***
## xsquare      1.1425422  0.3716630   3.074 0.002226 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006139 on 500 degrees of freedom
## Multiple R-squared:  0.05621,    Adjusted R-squared:  0.05244 
## F-statistic: 14.89 on 2 and 500 DF,  p-value: 5.233e-07

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AAPL.Ret and AAPL.Vol, but now doing the same when AAPL.Ret is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 9.450306
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 9.450306

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is greater than critical value, so we conclude that we fail to reject the null hypothesis.

Hence, the quadratic term \(X^2\) for AAPL.Ret is significant

AAPL.Vol vs AMZN.Ret higher order:

currX = AMZN.Ret
n = length(AAPL.Vol)
Xbar = sum(AMZN.Ret)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.014725 -0.004525 -0.001245  0.003449  0.018966 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.015252   0.000289  52.778  < 2e-16 ***
## smallx      -0.016177   0.013952  -1.159    0.247    
## xsquare      2.677416   0.327522   8.175 2.46e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005912 on 500 degrees of freedom
## Multiple R-squared:  0.1248, Adjusted R-squared:  0.1213 
## F-statistic: 35.66 on 2 and 500 DF,  p-value: 3.333e-15

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between AMZN.Ret and AAPL.Vol, but now doing the same when AMZN.Ret is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 66.82684
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 66.82684

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is much greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term \(X^2\) for AMZN.Ret is quite significant.

AAPL.Vol vs GSPC.Ret higher order:

currX = GSPC.Ret
n = length(AAPL.Vol)
Xbar = sum(GSPC.Ret)/n

#centering predictor variable

smallx = currX - Xbar

xsquare = smallx*smallx

currmod = lm(Y ~ smallx+xsquare)
summary(currmod)
## 
## Call:
## lm(formula = Y ~ smallx + xsquare)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.014347 -0.004640 -0.001417  0.003814  0.018906 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.0156042  0.0002964  52.638  < 2e-16 ***
## smallx      -0.0527817  0.0298301  -1.769   0.0774 .  
## xsquare      6.9330205  1.3317649   5.206 2.82e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006095 on 500 degrees of freedom
## Multiple R-squared:  0.0698, Adjusted R-squared:  0.06608 
## F-statistic: 18.76 on 2 and 500 DF,  p-value: 1.394e-08

Now plotting Y against X only:

par(lwd = 3, cex.axis = 1.5, cex.lab = 1.5, mar = c(5,5,2,2))
plot(Y~smallx, pch = 20, bty = "n", lwd = 5)

The graph doesn’t seem to be parabolic, so it doesn’t indicate interaction term at first glance.

We found from Part 2, that there is a relation between GSPC.Ret and AAPL.Vol, but now doing the same when GSPC.Ret is centered, we will test if there is any relation at all: * Null hypothesis \(H_0: \beta_2 = 0\) * Alternate hypothesis \(H_A: \beta_2 \neq 0\)

Test statistic is \(F_{obs} = \frac{MSR}{MSE} = \frac{SSR(x^2|x)/1}{SSE(x,x^2)/n-3}\)

curranova = anova(currmod)
curranova
dfsse = n-3

## SSR is second value in Mean Sq column of the anova table
## SSE is bottom most value in Sum Sq column
Fobs = curranova[2,3] / ((curranova[3,2])/dfsse)
Fobs
## [1] 27.10128
#or could be taken from ANOVA table
Fobs2 = curranova[2,4]
Fobs2
## [1] 27.10128

Our critical value is:

alpha = 0.05

Fstar = qf(1 - alpha, 1, n-3)
Fstar
## [1] 3.860124

Our test statistic value is quite greater than critical value, so we conclude that we reject the null hypothesis.

Hence, the quadratic term \(X^2\) for GSPC.Ret is significant.