Learn R Programming

FSA (version 0.8.20)

compSlopes: Tests for significant differences among all pairs of slopes in a dummy variable regression (DVR).

Description

Tests for significant differences among all pairs of slopes in a dummy variable regression where the dummy variables all stem from one factor.

Usage

compSlopes(mdl, method = stats::p.adjust.methods, conf.level = 0.95,
  order.slopes = TRUE, digits = getOption("digits"))

# S3 method for compSlopes print(x, ...)

Arguments

mdl

A lm object.

method

A string indicating the method of p-value adjustment to use. See details and p.adjust.methods (documented in p.adjust.

conf.level

A single number that represents the level of confidence to use for constructing confidence intervals.

order.slopes

A logical indicating whether the slopes should be ordered from smallest to largest upon output.

digits

A numeric that controls the number of digits to print.

x

A compSlopes object (i.e., returned from compSlopes).

Other arguments sent to print.

Value

A list with three components. The first component contains the p-value adjustment method in method. The second component, called comparisons, is a data.frame that contains the following:

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.
p.unadj Unadjusted p-value for testing the difference in slopes is zero.
p.adj Adjusted p-value for testing the difference in slopes is zero.

The third component, called slopes, is a data.frame that contains the following:

level A level name.
slope The estimated slope value for the given level.
XX LCI Lower confidence bound for difference in slope values.
XX UCI Upper confidence bound for difference in slope values.
p.unadj Unadjusted p-value for testing the slope is zero.
p.adj Adjusted p-value for testing the slope is zero.

The print function prints the results nicely.

Details

In a dummy variable regression the coefficient for the interaction between the covariate (x) and a dummy variable tests for a difference in slopes between the level of the dummy variable and the reference level. Thus, all dummy variables from a particular linear model fit only compare slopes with the reference level. Other slope comparisons may be found by changing the reference level, which requires refitting 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 and adjusted (for multiple comparisons) p-values for testing that the difference in slopes is equal to zero for each pair of levels. The adjusted p-values may be computed with any of the methods coded in p.adjust (see p.adjust.methods there).

See Also

compIntercepts in FSA.

Examples

Run this code
# NOT RUN {
data(Mirex)
Mirex$year <- factor(Mirex$year)
# fit a dummy variable regression, see that slopes differ
lm1 <- lm(mirex~weight*year,data=Mirex)
anova(lm1)
# compare all pairs of slopes using default Holm control
compSlopes(lm1)
# compare all pairs of slopes using the false discovery rate control
compSlopes(lm1,method="fdr")
# visualize the results
fitPlot(lm1)

# }

Run the code above in your browser using DataLab