compSlopes {NCStats}R Documentation

Tests for significant differences among all pairs of slopes in an IVR.

Description

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

Usage

  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, ...)

Arguments

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 compSlopes).

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 print.

Details

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.

Value

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.

Note

This function only works for models with one factor variable.

See Also

fitPlot in FSA, p.adjust.

Examples

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")

[Package NCStats version 0.3.4 Index]