Rolling Granger Causality TestHow to get df2 in causality() Granger test in RHow to find parameters for Granger causality(VAR)?Granger causality test using VECM in RRolling Granger CausalityGranger causality ordering variableFunction to find starting month of a quarter (custom) in RPlot multiple time series in different panels using RHow to find rolling sd over several months with daily data in RToda-Yamamoto Granger Causality Test in PythonHow to import the MVGC Multivariate Granger Causality Matlab® Toolbox and use it?

Did the first version of Linux developed by Linus Torvalds have a GUI?

How to translate “Me doing X” like in online posts?

How is it possible that Gollum speaks Westron?

Strange symbol for two functions

Movie about a boy who was born old and grew young

Notation of last measure of a song with a pickup measure

What are the peak hours for public transportation in Paris?

Implement Homestuck's Catenative Doomsday Dice Cascader

How do photons get into the eyes?

2.8 is missing the Carve option in the Boolean Modifier

Why does Kathryn say this in 12 Monkeys?

Random Portfolios vs Efficient Frontier

After the loss of Challenger, why weren’t Galileo and Ulysses launched by Centaurs on expendable boosters?

Traffic law UK, pedestrians

SF novella separating the dumb majority from the intelligent part of mankind

How can drunken, homicidal elves successfully conduct a wild hunt?

Is it possible to (7 day) schedule sleep time of a hard drive?

How Can I Tell The Difference Between Unmarked Sugar and Stevia?

Average spam confidence

What do we gain with higher order logics?

How many times can you cast a card exiled by Release to the Wind?

Building a road to escape Earth's gravity by making a pyramid on Antartica

Bent spoke design wheels — feasible?

What can plausibly explain many of my very long and low-tech bridges?



Rolling Granger Causality Test


How to get df2 in causality() Granger test in RHow to find parameters for Granger causality(VAR)?Granger causality test using VECM in RRolling Granger CausalityGranger causality ordering variableFunction to find starting month of a quarter (custom) in RPlot multiple time series in different panels using RHow to find rolling sd over several months with daily data in RToda-Yamamoto Granger Causality Test in PythonHow to import the MVGC Multivariate Granger Causality Matlab® Toolbox and use it?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to use the rollapply function from the zoo package to estimate Granger causality with a rolling window, the grangertest function is from the package lmtest, I have monthly data span over the period 1976-1984.



 y y1
Jan 1970 7.468513 7.672292
Feb 1970 7.475906 7.468513
Mar 1970 7.448334 7.475906
Apr 1970 7.351158 7.448334
May 1970 7.362011 7.351158
Jun 1970 7.326466 7.362011


I used the below-described codes but none of them seems to work



rol.c <- rollapply(mydata, width = 24,
FUN = function(z) coef(grangertest(mydata, order = 6)),
by.column = FALSE, align = "right")

rol.cs <- function(x) c(granger.test(x, p = 6))
rollapplyr(mydata, 24, granger.test, by.column = FALSE )


Any help is deeply appreciated.










share|improve this question






























    0















    I'm trying to use the rollapply function from the zoo package to estimate Granger causality with a rolling window, the grangertest function is from the package lmtest, I have monthly data span over the period 1976-1984.



     y y1
    Jan 1970 7.468513 7.672292
    Feb 1970 7.475906 7.468513
    Mar 1970 7.448334 7.475906
    Apr 1970 7.351158 7.448334
    May 1970 7.362011 7.351158
    Jun 1970 7.326466 7.362011


    I used the below-described codes but none of them seems to work



    rol.c <- rollapply(mydata, width = 24,
    FUN = function(z) coef(grangertest(mydata, order = 6)),
    by.column = FALSE, align = "right")

    rol.cs <- function(x) c(granger.test(x, p = 6))
    rollapplyr(mydata, 24, granger.test, by.column = FALSE )


    Any help is deeply appreciated.










    share|improve this question


























      0












      0








      0








      I'm trying to use the rollapply function from the zoo package to estimate Granger causality with a rolling window, the grangertest function is from the package lmtest, I have monthly data span over the period 1976-1984.



       y y1
      Jan 1970 7.468513 7.672292
      Feb 1970 7.475906 7.468513
      Mar 1970 7.448334 7.475906
      Apr 1970 7.351158 7.448334
      May 1970 7.362011 7.351158
      Jun 1970 7.326466 7.362011


      I used the below-described codes but none of them seems to work



      rol.c <- rollapply(mydata, width = 24,
      FUN = function(z) coef(grangertest(mydata, order = 6)),
      by.column = FALSE, align = "right")

      rol.cs <- function(x) c(granger.test(x, p = 6))
      rollapplyr(mydata, 24, granger.test, by.column = FALSE )


      Any help is deeply appreciated.










      share|improve this question
















      I'm trying to use the rollapply function from the zoo package to estimate Granger causality with a rolling window, the grangertest function is from the package lmtest, I have monthly data span over the period 1976-1984.



       y y1
      Jan 1970 7.468513 7.672292
      Feb 1970 7.475906 7.468513
      Mar 1970 7.448334 7.475906
      Apr 1970 7.351158 7.448334
      May 1970 7.362011 7.351158
      Jun 1970 7.326466 7.362011


      I used the below-described codes but none of them seems to work



      rol.c <- rollapply(mydata, width = 24,
      FUN = function(z) coef(grangertest(mydata, order = 6)),
      by.column = FALSE, align = "right")

      rol.cs <- function(x) c(granger.test(x, p = 6))
      rollapplyr(mydata, 24, granger.test, by.column = FALSE )


      Any help is deeply appreciated.







      r rolling-computation causality






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 18:27







      Ameer

















      asked Mar 24 at 15:35









      AmeerAmeer

      245




      245






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The function used in rollapply must return a vector or matrix.



          rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)





          share|improve this answer























          • when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

            – Ameer
            Mar 25 at 9:59






          • 1





            Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

            – G. Grothendieck
            Mar 25 at 13:09











          • I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

            – Ameer
            Mar 29 at 15:01











          • You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

            – G. Grothendieck
            Mar 29 at 18:47












          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%2f55325463%2frolling-granger-causality-test%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The function used in rollapply must return a vector or matrix.



          rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)





          share|improve this answer























          • when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

            – Ameer
            Mar 25 at 9:59






          • 1





            Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

            – G. Grothendieck
            Mar 25 at 13:09











          • I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

            – Ameer
            Mar 29 at 15:01











          • You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

            – G. Grothendieck
            Mar 29 at 18:47
















          1














          The function used in rollapply must return a vector or matrix.



          rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)





          share|improve this answer























          • when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

            – Ameer
            Mar 25 at 9:59






          • 1





            Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

            – G. Grothendieck
            Mar 25 at 13:09











          • I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

            – Ameer
            Mar 29 at 15:01











          • You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

            – G. Grothendieck
            Mar 29 at 18:47














          1












          1








          1







          The function used in rollapply must return a vector or matrix.



          rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)





          share|improve this answer













          The function used in rollapply must return a vector or matrix.



          rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 22:11









          G. GrothendieckG. Grothendieck

          158k11138250




          158k11138250












          • when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

            – Ameer
            Mar 25 at 9:59






          • 1





            Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

            – G. Grothendieck
            Mar 25 at 13:09











          • I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

            – Ameer
            Mar 29 at 15:01











          • You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

            – G. Grothendieck
            Mar 29 at 18:47


















          • when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

            – Ameer
            Mar 25 at 9:59






          • 1





            Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

            – G. Grothendieck
            Mar 25 at 13:09











          • I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

            – Ameer
            Mar 29 at 15:01











          • You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

            – G. Grothendieck
            Mar 29 at 18:47

















          when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

          – Ameer
          Mar 25 at 9:59





          when I refer to the data in the code, by default it takes the first variable as dependent and the second variable as independent, but what if want to specify the causal relationship from y1 to y y~y1 and vice-versa y1~y, how can I adjust the code for this purpose?

          – Ameer
          Mar 25 at 9:59




          1




          1





          Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

          – G. Grothendieck
          Mar 25 at 13:09





          Can use z[, c("abc", "xyz")] to use the indicated columns or function(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))

          – G. Grothendieck
          Mar 25 at 13:09













          I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

          – Ameer
          Mar 29 at 15:01





          I tried to use the same function with rcorr' from Hmisc` package like this: rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE) and returned the following lines Dec 1996 Numeric,4 Integer,4 Numeric,4, all the other lines appear like this, could you help me to fix this problem?

          – Ameer
          Mar 29 at 15:01













          You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

          – G. Grothendieck
          Mar 29 at 18:47






          You must wrap rcorr within a function that converts the output of rcorr to to a vector or matrix and use that function in rollapply.

          – G. Grothendieck
          Mar 29 at 18:47




















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325463%2frolling-granger-causality-test%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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript