I'm trying to run a 12 linear regression and want to correct for multiple testing problems.
The significance level in my field is usually p = 0.05 With the Bonferroni correction it would be p = 0.05 / 12 = 0.0041
If I run the regression as
fit <- lm(y ~ x1 + x2, data = mydata)
I get the significance levels 0.0001
, 0.001
, 0.05
, and 0.1
and the related signifcance codes ***
, **
, *
, and .
.
Is there a way to define a new significance level (p_sig = 0.05/12
) and then assign a new code (e.g. *.*
) to that? So that when I re-run the regression this will be used as a new significance level?
Thanks in advance for any help on this!
I know how to do this after running the regression.
fit <- lm(y ~ x1 + x2, data = mydata)
results <- summary(fit)
significant <- results$p.value < 0.004
But I'd want to have the "nice" table output.
This is produced by symnum
so modify that using trace
. Change the trace
line as needed.
set.seed(123)
x <- 1:10
y <- 1 + 2*x + rnorm(10)
trace(symnum, quote({ cutpoints=c(0, 0.05/12, 0.1, 1); symbols=c("*", ".", "") }),
print = FALSE)
summary(lm(y ~ x))
## ...
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.5255 0.6673 2.286 0.0516 .
## x 1.9180 0.1075 17.835 1e-07 *
## ---
## Signif. codes: 0 ‘*’ 0.004166667 ‘.’ 0.1 ‘’ 1
## ...
untrace(symnum)