test_equality | R Documentation |
This function tests whether smoothed correlation values at two time points are equal (H0) or not. The test is described page 341 in Choi & Shin (2021).
test_equality(
tcor_obj,
t1 = 1,
t2 = nrow(tcor_obj),
test = c("student", "chi2")
)
tcor_obj |
the output of a call to |
t1 |
the first time point used by the test (by default, the first time point in the time series). |
t2 |
the second time point used by the test (by default, the last time point in the time series). |
test |
a character string indicating which test to use ("student", the default; or "chi2"). |
Two different test statistics can be used, one is asymptotically Student-t distributed under H0 and one is chi-square distributed. In practice, it seems to give very similar results.
a data.frame with the result of the test, including the effect size (delta_r = r[t2] - r[t1]
).
test_ref()
, tcor()
## Simple example
res <- with(stockprice, tcor(x = SP500, y = FTSE100, t = DateID, h = 50, CI = TRUE))
test_equality(res)
## Chi2 instead of Student's t-test
test_equality(res, test = "chi2")
## Time point can be dates or indices (mixing possible) but output as in input data
test_equality(res, t1 = "2000-04-04", t2 = 1000)
res[1000, "t"] ## t2 matches with date in `res`
stockprice[1000, "DateID"] ## t2 does not match with date `stockprice` due to missing values
## It could be useful to use `keep.missing = TRUE` for index to match original data despite NAs
res2 <- with(stockprice, tcor(x = SP500, y = FTSE100, t = DateID,
h = 50, CI = TRUE, keep.missing = TRUE))
test_equality(res2, t1 = "2000-04-04", t2 = 1000)
res[1000, "t"] ## t2 matches with date in `res`
stockprice[1000, "DateID"] ## t2 does match with date `stockprice` despite missing values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.