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;
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
add a comment |
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
add a comment |
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
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
r rolling-computation causality
edited Mar 24 at 18:27
Ameer
asked Mar 24 at 15:35
AmeerAmeer
245
245
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The function used in rollapply must return a vector or matrix.
rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)
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 yy~y1
and vice-versay1~y
, how can I adjust the code for this purpose?
– Ameer
Mar 25 at 9:59
1
Can usez[, c("abc", "xyz")]
to use the indicated columns orfunction(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))
– G. Grothendieck
Mar 25 at 13:09
I tried to use the same function withrcorr' from
Hmisc` package like this:rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE)
and returned the following linesDec 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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
The function used in rollapply must return a vector or matrix.
rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)
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 yy~y1
and vice-versay1~y
, how can I adjust the code for this purpose?
– Ameer
Mar 25 at 9:59
1
Can usez[, c("abc", "xyz")]
to use the indicated columns orfunction(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))
– G. Grothendieck
Mar 25 at 13:09
I tried to use the same function withrcorr' from
Hmisc` package like this:rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE)
and returned the following linesDec 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
add a comment |
The function used in rollapply must return a vector or matrix.
rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)
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 yy~y1
and vice-versay1~y
, how can I adjust the code for this purpose?
– Ameer
Mar 25 at 9:59
1
Can usez[, c("abc", "xyz")]
to use the indicated columns orfunction(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))
– G. Grothendieck
Mar 25 at 13:09
I tried to use the same function withrcorr' from
Hmisc` package like this:rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE)
and returned the following linesDec 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
add a comment |
The function used in rollapply must return a vector or matrix.
rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)
The function used in rollapply must return a vector or matrix.
rollapplyr(z, 24, function(x) as.matrix(grangertest(x)), by.column = FALSE)
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 yy~y1
and vice-versay1~y
, how can I adjust the code for this purpose?
– Ameer
Mar 25 at 9:59
1
Can usez[, c("abc", "xyz")]
to use the indicated columns orfunction(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))
– G. Grothendieck
Mar 25 at 13:09
I tried to use the same function withrcorr' from
Hmisc` package like this:rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE)
and returned the following linesDec 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
add a comment |
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 yy~y1
and vice-versay1~y
, how can I adjust the code for this purpose?
– Ameer
Mar 25 at 9:59
1
Can usez[, c("abc", "xyz")]
to use the indicated columns orfunction(x) as.matrix(grangertest(x[, "abc"], x[, "xyz"]))
– G. Grothendieck
Mar 25 at 13:09
I tried to use the same function withrcorr' from
Hmisc` package like this:rollapplyr(z, 24, function(x) rcorr(x, type=c("spearman")), by.column = FALSE)
and returned the following linesDec 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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