se.contrast              package:stats              R Documentation

_S_t_a_n_d_a_r_d _E_r_r_o_r_s _f_o_r _C_o_n_t_r_a_s_t_s _i_n _M_o_d_e_l _T_e_r_m_s

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the standard errors for one or more contrasts in an 'aov'
     object.

_U_s_a_g_e:

     se.contrast(object, ...)
     ## S3 method for class 'aov':
     se.contrast(object, contrast.obj,
                coef = contr.helmert(ncol(contrast))[, 1],
                data = NULL, ...)

_A_r_g_u_m_e_n_t_s:

  object: A suitable fit, usually from 'aov'.

contrast.obj: The contrasts for which standard errors are requested. 
          This can be specified via a list or via a matrix.  A single
          contrast can be specified by a list of logical vectors giving
          the cells to be contrasted.  Multiple contrasts should be
          specified by a matrix, each column of which is a numerical
          contrast vector (summing to zero). 

    coef: used when 'contrast.obj' is a list; it should be a vector of
          the same length as the list with zero sum.  The default value
          is the first Helmert contrast, which contrasts the first and
          second cell means specified by the list.

    data: The data frame used to evaluate 'contrast.obj'.

     ...: further arguments passed to or from other methods.

_D_e_t_a_i_l_s:

     Contrasts are usually used to test if certain means are
     significantly different; it can be easier to use 'se.contrast'
     than compute them directly from the coefficients.

     In multistratum models, the contrasts can appear in more than one
     stratum; the contrast and standard error are computed in the
     lowest stratum and adjusted for efficiencies and comparisons
     between strata.

     Suitable matrices for use with 'coef' can be found by calling
     'contrasts' and indexing the columns by a factor.

_V_a_l_u_e:

     A vector giving the standard errors for each contrast.

_S_e_e _A_l_s_o:

     'contrasts', 'model.tables'

_E_x_a_m_p_l_e_s:

     ## From Venables and Ripley (2002) p.165.
     N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
     P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
     K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
     yield <- c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,62.8,55.8,69.5,
     55.0, 62.0,48.8,45.5,44.2,52.0,51.5,49.8,48.8,57.2,59.0,53.2,56.0)

     npk <- data.frame(block = gl(6,4), N = factor(N), P = factor(P),
                       K = factor(K), yield = yield)
     options(contrasts=c("contr.treatment", "contr.poly"))
     npk.aov1 <- aov(yield ~ block + N + K, npk)
     se.contrast(npk.aov1, list(N=="0", N=="1"), data=npk)
     # or via a matrix
     cont <- matrix(c(-1,1), 2, 1, dimnames=list(NULL, "N"))
     se.contrast(npk.aov1, cont[N, , drop=FALSE]/12, data=npk)

     ## test a multi-stratum model
     npk.aov2 <- aov(yield ~ N + K + Error(block/(N + K)), npk)
     se.contrast(npk.aov2, list(N == "0", N == "1"))

