Perform 2-sided significance tests at the significance level of 0.05 to test whether the correlations are equal to 0

Hi there! I hope you are all good!
I am asking for help to perform a 2-sided significance tests at the significance level of 0.05 to test whether the correlations are equal to 0.

This is the dataset I have, and these are the following results from the estimates of the Pearson correlation coefficient and the Spearman correlation coefficient of sys12 with whr and of sys12 with bmiB.

dat_link <- url("KiGGS03_06.RData")
load(dat_link)

dat <- KiGGS03_06

whr <- as.numeric(as.character(dat$whr))
bp <- as.numeric(as.character(dat$sys12))

cor.test(whr, bp, method = "pearson")
cor.test(dat$bmiB, bp, method = "pearson")

cor.test(whr, bp, method = "spearman")
cor.test(dat$bmiB, bp, method = "spearman")

However, after this I don't know how to calculate the 2-sided t-test. Could anyone help me please! I would really appreciate it :pray:

Does

t.test(whr, bp)

give you what you want? I you look at the help for the t.test function, you will see that the default is for a two sided test with conf.level set to 0.95.

Thank you very much for yourself. Indeed, this function helps, but also, I can perform the two-sided t-test directly with the correlation function, as follows:

´´´
cor.test(dat$whr, dat$sysBP, method = "pearson", alternative = "two.sided", conf.level = 0.95)

cor.test(dat$BMI, dat$sysBP, method = "pearson", alternative = "two.sided", conf.level = 0.95)

cor.test(dat$whr, dat$sysBP, method = "spearman", alternative = "two.sided", conf.level = 0.95)

cor.test(dat$BMI, dat$sysBP, method = "spearman", alternative = "two.sided", conf.level = 0.95)
´´´

Thanks for your help! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.