Skip to content
Prev 138617 / 398503 Next

Asking, are simple effects different from 0

On 3/5/2008 10:09 AM, jebyrnes wrote:
Each column corresponds to one of the coefficients in the model, and 
each row specifies a particular contrast.  The numbers in the matrix 
indicate how the model coefficients are combined to indicate a 
particular difference in means.
   For example, the first row indicates that the third coefficient 
(woolB) is multiplied by -1.  The baseline categories are A and L for 
the wool and tension factors, so the woolB effect in fm is the simple 
effect of B vs. A in the baseline category of the tension factor. 
Multiplying this coefficient by -1 produces an A vs. B comparison in the 
baseline category of the tension factor.
   When I want to check that contrasts are as intended, I use contrast() 
in the contrast package (by Steve Weston, Jed Wing, & Max Kuhn).  That 
function allows you to specify factor levels by name to construct the 
contrast.  For example:

library(contrast)

# M vs. H at B

contrast(fm, a=list(tension = "M", wool = "B"),
              b=list(tension = "H", wool = "B"))

lm model parameter contrast

  Contrast     S.E.      Lower    Upper    t df Pr(>|t|)
        10 5.157299 -0.3694453 20.36945 1.94 48   0.0584

   It also allows you to print the design matrix for a contrast:

contrast(fm, a=list(tension = "M", wool = "B"),
              b=list(tension = "H", wool = "B"))$X

   (Intercept) tensionM tensionH woolB tensionM:woolB tensionH:woolB
1           0        1       -1     0              1             -1