R- right procedure VAR fit ? ARCH effects?










0














I am estimating a VAR model to later understand the relationship between my physical prices and financial prices. I work on commodities. I have followed the procedure below but I am not sure it is right. Also, I am not sure what to do since I found that there are ARCH effects.



Can someone please tell me if my methodology is correct? And if the fact that I have ARCH effects is a problem for my VAR and/or my Granger causality test?



##We verify stationarity of the price series:
#if not stationarity, we test co integration. If it is cointegrated, we estimate a VECM.
#If not stationary, we test co integration. If it is not cointegrated,
# I stationnarize the variables and estimate a VAR.
library(tseries)

adf.test(log_close_wk)
kpss.test(log_close_wk, null="Trend")
adf.test(log_price_wk)
kpss.test(log_price_wk, null="Trend")

#the null hypothesis of the existence of a unit root is NOT rejected hence the series
#is NOT stationary (there is a trend)

#Stationarity can come from the trend also, which is why I test with a KPSS test



#Now see if the spot and futures are partially cointegrated:



library(egcm)

egcm_finance <- egcm(log_close_wk, matrix(log_price_wk),include.const = T)
plot(egcm_finance$residuals,type = "l")
library(partialCI)
PCI_Spot_Futures<-fit.pci(log_close_wk, matrix(log_price_wk),
pci_opt_method = c("jp"),
par_model =c("ar1"), lambda = 0,
robust = FALSE, nu = 5)


test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
c( "ar1"),imethod = "wilk",
pci_opt_method = c("jp"))

test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
c( "rw"),imethod = "wilk",
pci_opt_method = c("jp"))


# a time series is classified as partially cointegrated, iif the random
#walk as well as the AR(1)-hypotheses are rejected. The p-value of 0.000 for
#both null model indicates that both are partially cointegrated in the
#considered period of time.WHICH IS THE CASE FOR ME!


##NOw we can run a VECM:
#I create dataframe with the couples of prices :
df_cl<-cbind(log_close_wk,log_price_wk)

library(vars)
#We find the lag order:
VARselect(df_cl) #4 lags / or 2 lags

library(tsDyn)
VECM(df_cl,4)
VECM(df_cl,2)


#Here my ECT coefficient is positive,
#It implies that the process it not converging in the long run.
#!It should be negative!!

#So we stationarize our variables and estimate a VAR model.
log_close_wk<-diff(log_close_wk)
log_price_wk<-diff(log_price_wk)


adf.test(log_close_exp_wk)
adf.test(log_price_wk)
###They are now stationary after one difference.
df_cl<-cbind(log_close_wk,log_price_wk)


#WE NOW ESTIMATE A VAR model:
#Number of lags:
library(vars)
#We find the lag order:
VARselect(df_cl) #5 lags / or1

fit<-VAR(df_cl,5)
fit
fit1<-VAR(df_cl,1)
fit1

#I should now test for serial autocorrelation using the Portmanteau test:


serial.test(fit, lags.pt = 10, type = "PT.asymptotic")
serial.test(fit1, lags.pt = 10, type = "PT.asymptotic")
#WE REJECT the hyp. of no serial correlation
#So we keep the model with no serial correlation :
#fit

#ARCH test (Autoregressive conditional heteroscedasdicity)

arch.test(fit, lags.multi = 10)
#so my data is conditionally heteroskedastic
#IS THAT A PROBLEM?????

summary(fit)
summary(fit2)
summary(fit3)

#Should I get rid of the ARCH effects?

#Granger Causality test
#Does CLOSE granger cause PRICE? ##BETTER?
grangertest(log_price_wk~ log_close_wk, order = 5)

#Does PRICE granger cause CLOSE?
grangertest(log_close_wk~ log_price_wk, order = 5)
#null hypothesis is rejected for both : i reject the hyp of no granger
causality(small pvalue)









share|improve this question




























    0














    I am estimating a VAR model to later understand the relationship between my physical prices and financial prices. I work on commodities. I have followed the procedure below but I am not sure it is right. Also, I am not sure what to do since I found that there are ARCH effects.



    Can someone please tell me if my methodology is correct? And if the fact that I have ARCH effects is a problem for my VAR and/or my Granger causality test?



    ##We verify stationarity of the price series:
    #if not stationarity, we test co integration. If it is cointegrated, we estimate a VECM.
    #If not stationary, we test co integration. If it is not cointegrated,
    # I stationnarize the variables and estimate a VAR.
    library(tseries)

    adf.test(log_close_wk)
    kpss.test(log_close_wk, null="Trend")
    adf.test(log_price_wk)
    kpss.test(log_price_wk, null="Trend")

    #the null hypothesis of the existence of a unit root is NOT rejected hence the series
    #is NOT stationary (there is a trend)

    #Stationarity can come from the trend also, which is why I test with a KPSS test



    #Now see if the spot and futures are partially cointegrated:



    library(egcm)

    egcm_finance <- egcm(log_close_wk, matrix(log_price_wk),include.const = T)
    plot(egcm_finance$residuals,type = "l")
    library(partialCI)
    PCI_Spot_Futures<-fit.pci(log_close_wk, matrix(log_price_wk),
    pci_opt_method = c("jp"),
    par_model =c("ar1"), lambda = 0,
    robust = FALSE, nu = 5)


    test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
    c( "ar1"),imethod = "wilk",
    pci_opt_method = c("jp"))

    test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
    c( "rw"),imethod = "wilk",
    pci_opt_method = c("jp"))


    # a time series is classified as partially cointegrated, iif the random
    #walk as well as the AR(1)-hypotheses are rejected. The p-value of 0.000 for
    #both null model indicates that both are partially cointegrated in the
    #considered period of time.WHICH IS THE CASE FOR ME!


    ##NOw we can run a VECM:
    #I create dataframe with the couples of prices :
    df_cl<-cbind(log_close_wk,log_price_wk)

    library(vars)
    #We find the lag order:
    VARselect(df_cl) #4 lags / or 2 lags

    library(tsDyn)
    VECM(df_cl,4)
    VECM(df_cl,2)


    #Here my ECT coefficient is positive,
    #It implies that the process it not converging in the long run.
    #!It should be negative!!

    #So we stationarize our variables and estimate a VAR model.
    log_close_wk<-diff(log_close_wk)
    log_price_wk<-diff(log_price_wk)


    adf.test(log_close_exp_wk)
    adf.test(log_price_wk)
    ###They are now stationary after one difference.
    df_cl<-cbind(log_close_wk,log_price_wk)


    #WE NOW ESTIMATE A VAR model:
    #Number of lags:
    library(vars)
    #We find the lag order:
    VARselect(df_cl) #5 lags / or1

    fit<-VAR(df_cl,5)
    fit
    fit1<-VAR(df_cl,1)
    fit1

    #I should now test for serial autocorrelation using the Portmanteau test:


    serial.test(fit, lags.pt = 10, type = "PT.asymptotic")
    serial.test(fit1, lags.pt = 10, type = "PT.asymptotic")
    #WE REJECT the hyp. of no serial correlation
    #So we keep the model with no serial correlation :
    #fit

    #ARCH test (Autoregressive conditional heteroscedasdicity)

    arch.test(fit, lags.multi = 10)
    #so my data is conditionally heteroskedastic
    #IS THAT A PROBLEM?????

    summary(fit)
    summary(fit2)
    summary(fit3)

    #Should I get rid of the ARCH effects?

    #Granger Causality test
    #Does CLOSE granger cause PRICE? ##BETTER?
    grangertest(log_price_wk~ log_close_wk, order = 5)

    #Does PRICE granger cause CLOSE?
    grangertest(log_close_wk~ log_price_wk, order = 5)
    #null hypothesis is rejected for both : i reject the hyp of no granger
    causality(small pvalue)









    share|improve this question


























      0












      0








      0







      I am estimating a VAR model to later understand the relationship between my physical prices and financial prices. I work on commodities. I have followed the procedure below but I am not sure it is right. Also, I am not sure what to do since I found that there are ARCH effects.



      Can someone please tell me if my methodology is correct? And if the fact that I have ARCH effects is a problem for my VAR and/or my Granger causality test?



      ##We verify stationarity of the price series:
      #if not stationarity, we test co integration. If it is cointegrated, we estimate a VECM.
      #If not stationary, we test co integration. If it is not cointegrated,
      # I stationnarize the variables and estimate a VAR.
      library(tseries)

      adf.test(log_close_wk)
      kpss.test(log_close_wk, null="Trend")
      adf.test(log_price_wk)
      kpss.test(log_price_wk, null="Trend")

      #the null hypothesis of the existence of a unit root is NOT rejected hence the series
      #is NOT stationary (there is a trend)

      #Stationarity can come from the trend also, which is why I test with a KPSS test



      #Now see if the spot and futures are partially cointegrated:



      library(egcm)

      egcm_finance <- egcm(log_close_wk, matrix(log_price_wk),include.const = T)
      plot(egcm_finance$residuals,type = "l")
      library(partialCI)
      PCI_Spot_Futures<-fit.pci(log_close_wk, matrix(log_price_wk),
      pci_opt_method = c("jp"),
      par_model =c("ar1"), lambda = 0,
      robust = FALSE, nu = 5)


      test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
      c( "ar1"),imethod = "wilk",
      pci_opt_method = c("jp"))

      test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
      c( "rw"),imethod = "wilk",
      pci_opt_method = c("jp"))


      # a time series is classified as partially cointegrated, iif the random
      #walk as well as the AR(1)-hypotheses are rejected. The p-value of 0.000 for
      #both null model indicates that both are partially cointegrated in the
      #considered period of time.WHICH IS THE CASE FOR ME!


      ##NOw we can run a VECM:
      #I create dataframe with the couples of prices :
      df_cl<-cbind(log_close_wk,log_price_wk)

      library(vars)
      #We find the lag order:
      VARselect(df_cl) #4 lags / or 2 lags

      library(tsDyn)
      VECM(df_cl,4)
      VECM(df_cl,2)


      #Here my ECT coefficient is positive,
      #It implies that the process it not converging in the long run.
      #!It should be negative!!

      #So we stationarize our variables and estimate a VAR model.
      log_close_wk<-diff(log_close_wk)
      log_price_wk<-diff(log_price_wk)


      adf.test(log_close_exp_wk)
      adf.test(log_price_wk)
      ###They are now stationary after one difference.
      df_cl<-cbind(log_close_wk,log_price_wk)


      #WE NOW ESTIMATE A VAR model:
      #Number of lags:
      library(vars)
      #We find the lag order:
      VARselect(df_cl) #5 lags / or1

      fit<-VAR(df_cl,5)
      fit
      fit1<-VAR(df_cl,1)
      fit1

      #I should now test for serial autocorrelation using the Portmanteau test:


      serial.test(fit, lags.pt = 10, type = "PT.asymptotic")
      serial.test(fit1, lags.pt = 10, type = "PT.asymptotic")
      #WE REJECT the hyp. of no serial correlation
      #So we keep the model with no serial correlation :
      #fit

      #ARCH test (Autoregressive conditional heteroscedasdicity)

      arch.test(fit, lags.multi = 10)
      #so my data is conditionally heteroskedastic
      #IS THAT A PROBLEM?????

      summary(fit)
      summary(fit2)
      summary(fit3)

      #Should I get rid of the ARCH effects?

      #Granger Causality test
      #Does CLOSE granger cause PRICE? ##BETTER?
      grangertest(log_price_wk~ log_close_wk, order = 5)

      #Does PRICE granger cause CLOSE?
      grangertest(log_close_wk~ log_price_wk, order = 5)
      #null hypothesis is rejected for both : i reject the hyp of no granger
      causality(small pvalue)









      share|improve this question















      I am estimating a VAR model to later understand the relationship between my physical prices and financial prices. I work on commodities. I have followed the procedure below but I am not sure it is right. Also, I am not sure what to do since I found that there are ARCH effects.



      Can someone please tell me if my methodology is correct? And if the fact that I have ARCH effects is a problem for my VAR and/or my Granger causality test?



      ##We verify stationarity of the price series:
      #if not stationarity, we test co integration. If it is cointegrated, we estimate a VECM.
      #If not stationary, we test co integration. If it is not cointegrated,
      # I stationnarize the variables and estimate a VAR.
      library(tseries)

      adf.test(log_close_wk)
      kpss.test(log_close_wk, null="Trend")
      adf.test(log_price_wk)
      kpss.test(log_price_wk, null="Trend")

      #the null hypothesis of the existence of a unit root is NOT rejected hence the series
      #is NOT stationary (there is a trend)

      #Stationarity can come from the trend also, which is why I test with a KPSS test



      #Now see if the spot and futures are partially cointegrated:



      library(egcm)

      egcm_finance <- egcm(log_close_wk, matrix(log_price_wk),include.const = T)
      plot(egcm_finance$residuals,type = "l")
      library(partialCI)
      PCI_Spot_Futures<-fit.pci(log_close_wk, matrix(log_price_wk),
      pci_opt_method = c("jp"),
      par_model =c("ar1"), lambda = 0,
      robust = FALSE, nu = 5)


      test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
      c( "ar1"),imethod = "wilk",
      pci_opt_method = c("jp"))

      test.pci(log_close_wk, matrix(log_price_wk), irobust=TRUE, alpha = 0.05, null_hyp =
      c( "rw"),imethod = "wilk",
      pci_opt_method = c("jp"))


      # a time series is classified as partially cointegrated, iif the random
      #walk as well as the AR(1)-hypotheses are rejected. The p-value of 0.000 for
      #both null model indicates that both are partially cointegrated in the
      #considered period of time.WHICH IS THE CASE FOR ME!


      ##NOw we can run a VECM:
      #I create dataframe with the couples of prices :
      df_cl<-cbind(log_close_wk,log_price_wk)

      library(vars)
      #We find the lag order:
      VARselect(df_cl) #4 lags / or 2 lags

      library(tsDyn)
      VECM(df_cl,4)
      VECM(df_cl,2)


      #Here my ECT coefficient is positive,
      #It implies that the process it not converging in the long run.
      #!It should be negative!!

      #So we stationarize our variables and estimate a VAR model.
      log_close_wk<-diff(log_close_wk)
      log_price_wk<-diff(log_price_wk)


      adf.test(log_close_exp_wk)
      adf.test(log_price_wk)
      ###They are now stationary after one difference.
      df_cl<-cbind(log_close_wk,log_price_wk)


      #WE NOW ESTIMATE A VAR model:
      #Number of lags:
      library(vars)
      #We find the lag order:
      VARselect(df_cl) #5 lags / or1

      fit<-VAR(df_cl,5)
      fit
      fit1<-VAR(df_cl,1)
      fit1

      #I should now test for serial autocorrelation using the Portmanteau test:


      serial.test(fit, lags.pt = 10, type = "PT.asymptotic")
      serial.test(fit1, lags.pt = 10, type = "PT.asymptotic")
      #WE REJECT the hyp. of no serial correlation
      #So we keep the model with no serial correlation :
      #fit

      #ARCH test (Autoregressive conditional heteroscedasdicity)

      arch.test(fit, lags.multi = 10)
      #so my data is conditionally heteroskedastic
      #IS THAT A PROBLEM?????

      summary(fit)
      summary(fit2)
      summary(fit3)

      #Should I get rid of the ARCH effects?

      #Granger Causality test
      #Does CLOSE granger cause PRICE? ##BETTER?
      grangertest(log_price_wk~ log_close_wk, order = 5)

      #Does PRICE granger cause CLOSE?
      grangertest(log_close_wk~ log_price_wk, order = 5)
      #null hypothesis is rejected for both : i reject the hyp of no granger
      causality(small pvalue)






      r time-series






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 1:09









      Daniel Kaparunakis

      2,15191627




      2,15191627










      asked Nov 12 '18 at 15:23









      NarjemsNarjems

      409




      409






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265204%2fr-right-procedure-var-fit-arch-effects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265204%2fr-right-procedure-var-fit-arch-effects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto