2
$\begingroup$

I am new to R so please apolozige if I should use wrong terms etc.

Let's say I investigated married couples as subjects, and (amongst other) tested if their amount of consumed alcohol is correlated to each other. For this, I assed amount of alcohol consumed every day for a year, for both wife and husband in diffrent couples. I then assessed the cross-correlations (ccf function in R) for each couple.

I now have a vector containing cross-correlations coefficient (at lag 0) between the wife's amount of consumed alcohol and the husband's amount of consumed alcohol for each of the tested couples:

[1] 0.15
[2] 0.03
[3] 0.17
[4] -0.33

... and so on (total of 200 subjects).

I now want to test, if these correlations are significantly greater than 0, using a t-test. Does this make sense? If yes, how can I do this in R?

$\endgroup$

migrated from stackoverflow.com Jun 5 at 8:32

This question came from our site for professional and enthusiast programmers.

2
$\begingroup$

Since you run a cross correlation the critical values (at the 5% level) are $± 2/ \sqrt[]{n}$. In your case the critical values are <0.1414214 and >0.1414214. See here.

Also keep in mind that for lag 0 you can simply use the Pearson correlation in cor(). See here:

set.seed(1)
x <- rnorm(200)
y <- x* .2 + rnorm(200)

corcoef <- ccf(x, y, lag.max = 0)[["acf"]]
corcoef
0.1605629
cor(x, y)
0.1605629

This means that if you are interested about lag= 0 you can use cor.test() which shows $p$ value. Here:

cor.test(x, y)
p-value = 0.02313
...
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy