| compSlopes {NCStats} | R Documentation |
Tests for significant differences among all pairs of slopes in an indicator variable regression where the indicator variables all stem from one factor.
compSlopes(mdl,
control = c("fdr", "BH", "BY", "bonferroni", "holm", "hochberg", "hommel"),
alpha = 0.05, order.slopes = TRUE,
digits = getOption("digits"))
## S3 method for class 'compSlopes'
print(x, ...)
mdl |
a |
control |
a string indicating the method of control to use. See details. |
alpha |
a decimal numeric indicating the desired level for the experimentwise error rate |
x |
A |
order.slopes |
A logical indicating whether the slopes should be order from smallest to largest upon output. |
digits |
A numeric that controls the number of digits to print. |
... |
Other arguments sent to |
In an indicator variable regression the coefficient for the interaction between the covariate (x) and an indicator variable tests for a difference in slopes between the level of the indicator variable and the reference level. Thus, all indicator variables from a particular linear model fit only compare slopes with the reference level. Other slope comparisons can be found by changing the reference level but this requires re-fitting the model. This function automates this sequential process and produces a data frame that shows the estimated difference, an unadjusted confidence interval for the difference, and the unadjusted p-value for testing that the difference in slopes is equal to zero. In addition, the function provides an adjusted p-value for testing that the difference in slopes is equal to zero and a statement about whether each null hypothesis is signficant or not.
The adjusted p-values can be computed with a wide variety
of methods – FDR, BH, BY, bonferroni, holm, hochberg,
and hommel. This function basically works as a wrapper
function that sends the unadjusted “raw” p-values
to the p.adjust function in the base R program.
These functions should be consulted for further
description of the methods used.
A list with three components. The first component
contains the control method. The second component
is called comparisons and is a data frame that
contains the following components:
comparison | Description of how the difference in levels was computed. |
diff
| The estimated difference in slope values. |
lwr | Lower confidence bound for difference in slope values. |
upr | Upper confidence bound for difference in slope values. |
raw.p | Unadjusted p-value for testing the difference in slopes is zero. |
adj.p | Adjusted p-value for testing the difference in slopes is zero. |
The third component of the list is called slopes
and is a data frame that contains the following
components:
level | A level name. |
slope | The estimated slope value for the given level. |
lwr | Lower confidence bound for difference in slope values. |
upr | Upper confidence bound for difference in slope values. |
raw.p | Unadjusted p-value for testing the slope is zero. |
adj.p | Adjusted p-value for testing the slope is zero. |
The print function prints the results nicely.
This function only works for models with one factor variable.
fitPlot in FSA, p.adjust.
require(FSA) # for fitPlot require(FSAdata) # for Mirex data data(Mirex) Mirex$year <- factor(Mirex$year) # fit an indicator variable regression lm1 <- lm(mirex~weight*year,data=Mirex) # visualize the results fitPlot(lm1) # compare all pairs of slopes using an FDR control compSlopes(lm1) # compare all pairs of slopes using the Holm method of control compSlopes(lm1,control="holm")