0

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
JayPeerachai
  • 3,499
  • 3
  • 14
  • 29
Joe
  • 795
  • 1
  • 11
  • It says that is does not work for paired tests e.g. same country at two given time points. However, I do not see the need for paired tests by looking at your data... – danlooo Mar 02 '22 at 12:42
  • Ok, would you suggest a similar test (Pearsons/shapiro wilk) would be ok here? – Joe Mar 02 '22 at 12:45
  • I have no idea about the hypothesis to test so I can not suggests test. Howver, I think you might try unpaired tests e.g. `t.test(paired = FALSE)`. – danlooo Mar 02 '22 at 12:48
  • Ok, not sure i quite follow. So i should add that into my original code? – Joe Mar 02 '22 at 12:54
  • Provide all the code and a description of what difference you want to test (e.g. Life expectancy is different across countries). We can't help you otherwise – danlooo Mar 02 '22 at 12:56
  • Gotcha. So I'm looking to test that PM2.5 reduces life expectancy in deprived areas. What other code do you require? – Joe Mar 02 '22 at 13:00

1 Answers1

0

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.

danlooo
  • 10,067
  • 2
  • 8
  • 22