I am trying to hypothesis test using the bonferroni method although I get an error message saying I can't pool together SD, does anyone know this problem and how to solve the code?
Code used:
with(final_data, pairwise.t.test, Concentration_of_PM2.5, Life_expectancy,
p.adjust.method = 'bonferroni')
Error message;
function (x, g, p.adjust.method = p.adjust.methods, pool.sd = !paired,
paired = FALSE, alternative = c("two.sided", "less", "greater"),
...)
{
if (paired && pool.sd)
stop("pooling of SD is incompatible with paired tests")
Dataset snipet;
head(final_data, 10)
Country Continent Life_Expectancy Adult_Mortality Concentration_of_PM2.5 GDP GDP_Level
1 Afghanistan Eastern Mediterranean 62.68935 245.22490 55.14 1896.993 Very Low
2 Albania Europe 76.37373 96.40514 18.07 11868.179 Medium
3 Algeria Africa 76.36365 95.02545 35.18 15036.364 Medium
4 Angola Africa 62.63262 237.96940 38.29 6756.935 Low
5 Antigua and Barbuda Americas 74.99754 119.86570 21.03 23670.302 High
6 Argentina Americas 76.94621 111.42880 12.58 20130.408 High
7 Armenia Europe 74.83788 116.43580 33.84 8808.573 Low
8 Australia Western Pacific 82.90018 60.72528 7.14 47305.880 Very High
9 Austria Europe 81.87031 61.88845 12.15 51809.514 Very High
10 Azerbaijan Europe 73.07719 117.64890 20.99 17417.087 High
CodePudding user response:
PM2.5 reduces life expectancy in deprived areas (low GDP), if the correlation between these two continuously scaled variables is negative and significant (p-value < 0.05):
library(tidyverse)
final_data %>%
filter(GDP_Level %in% c("Very Low", "Low")) %>%
cor.test(~ Concentration_of_PM2.5 Life_Expectancy,
data = ., method = "pearson")
This looks for a linear relationship between these two variables. Use method = "spearman
instead if non-linear but monotonous relationships should be studied.
However, this is just one test for one hypothesis, so there is no Bonferroni required.