'How to adjust p-value for both multi group comparison and multi-variable comparison?

I have a naive statistical question:

Do I need to adjust p-values two times when I perform a multi-group and multi-variable comparasion?

Suppose I have a data frame df

df <- data.frame(technique = rep(c("tech1", "tech2", "tech3"), each = 6),
                 Var1 = c(76, 77, 77, 81, 82, 82, 81, 82, 83, 83, 83, 84, 77, 78, 79, 88, 89, 90),
                 Var2 = c(33, 44, 51, 34, 33, 51, 23, 22, 15, 23, 22, 28, 111, 111, 121, 101, 141, 112),
                 Var3 = c(77, 55, 52, 56, 76, 66, 45, 44, 45, 43, 34, 39, 89, 90, 99, 98, 88, 89),
                 Var3 = c(47, 55, 55, 46, 66, 56, 55, 54, 55, 53, 54, 59, 59, 50, 59, 58, 58, 59)
                 )

I want to compare 3 different techniques (tech1, tech2, tech3) using 4 measured variables (Var1, Var2, Var3, Var4).

My code is as following:

#(1) TukeyHSD test
vars <- names(df)[-1]
aov.out <- lapply(vars, function(x) {
  lm(substitute(i ~ technique, list(i = as.name(x))), data = df)
})
## only get adjusted p-value (according to group: technique)
TukeyHSD.out <- purrr::map_df(aov.out, function(x) TukeyHSD(aov(x))$technique[, 4]) 

#(2) FDR
## Do I need to adjust p-value accoding to variable? like below:
Adjusted2 <- t(apply(TukeyHSD.out, 1, function(x) p.adjust(x, method = "BH")))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source