| comp.slopes {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.
comp.slopes(mdl,
control=c("fdr","BH","BY","bonferroni","holm","hochberg","hommel"),
alpha = 0.05)
## S3 method for class 'CompSlopes':
print(x,...)
mdl |
a lm object. |
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 CompSlopes object (i.e., returns from comp.slopes). |
... |
Other arguments sent to print. |
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 dQuote{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. |
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. |
print function prints the results nicely.
This function only works for models with one factor variable.
Derek H. Ogle, dogle@northland.edu; relies heavily on the p.adjust function.
fit.plot, p.adjust.
data(Mirex) Mirex$year <- factor(Mirex$year) attach(Mirex) lm1 <- lm(mirex~weight*year) fit.plot(lm1) comp.slopes(lm1) comp.slopes(lm1,control="holm") detach(Mirex)