anova.lm                package:stats                R Documentation

_A_N_O_V_A _f_o_r _L_i_n_e_a_r _M_o_d_e_l _F_i_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Compute an analysis of variance table for one or more linear model
     fits.

_U_s_a_g_e:

     ## S3 method for class 'lm':
     anova(object, ...)

     anova.lmlist(object, ..., scale = 0, test = "F")

_A_r_g_u_m_e_n_t_s:

object, ...: objects of class 'lm', usually, a result of a call to
          'lm'.

    test: a character string specifying the test statistic to be used.
          Can be one of '"F"', '"Chisq"' or '"Cp"', with partial
          matching allowed, or 'NULL' for no test.

   scale: numeric. An estimate of the noise variance sigma^2. If zero
          this will be estimated from the largest model considered. 

_D_e_t_a_i_l_s:

     Specifying a single object gives a sequential analysis of variance
     table for that fit.  That is, the reductions in the residual sum
     of squares as each term of the formula is added in turn are given
     in as the rows of a table, plus the residual sum of squares.

     The table will contain F statistics (and P values) comparing the
     mean square for the row to the residual mean square.

     If more than one object is specified, the table has a row for the
     residual degrees of freedom and sum of squares for each model. For
     all but the first model, the change in degrees of freedom and sum
     of squares is also given. (This only make statistical sense if the
     models are nested.)  It is conventional to list the models from
     smallest to largest, but this is up to the user.

     Optionally the table can include test statistics.  Normally the F
     statistic is most appropriate, which compares the mean square for
     a row to the residual sum of squares for the largest model
     considered. If 'scale' is specified chi-squared tests can be used.
     Mallows' Cp statistic is the residual sum of squares plus twice
     the estimate of sigma^2 times the residual degrees of freedom.

_V_a_l_u_e:

     An object of class '"anova"' inheriting from class '"data.frame"'.

_W_a_r_n_i_n_g:

     The comparison between two or more models will only be valid if
     they are fitted to the same dataset. This may be a problem if
     there are missing values and R's default of 'na.action = na.omit'
     is used, and 'anova.lmlist' will detect this with an error.

_N_o_t_e:

     Versions of R prior to 1.2.0 based F tests on pairwise
     comparisons, and this behaviour can still be obtained by a direct
     call to 'anovalist.lm'.

_R_e_f_e_r_e_n_c_e_s:

     Chambers, J. M. (1992) _Linear models._ Chapter 4 of _Statistical
     Models in S_ eds J. M. Chambers and T. J. Hastie, Wadsworth &
     Brooks/Cole.

_S_e_e _A_l_s_o:

     The model fitting function 'lm', 'anova'.

     'drop1' for so-called 'type II' anova where each term is dropped
     one at a time respecting their hierarchy.

_E_x_a_m_p_l_e_s:

     ## sequential table
     data(LifeCycleSavings)
     fit <- lm(sr ~ ., data = LifeCycleSavings)
     anova(fit)

     ## same effect via separate models
     fit0 <- lm(sr ~ 1, data = LifeCycleSavings)
     fit1 <- update(fit0, . ~ . + pop15)
     fit2 <- update(fit1, . ~ . + pop75)
     fit3 <- update(fit2, . ~ . + dpi)
     fit4 <- update(fit3, . ~ . + ddpi)
     anova(fit0, fit1, fit2, fit3, fit4, test="F")

     anova(fit4, fit2, fit0, test="F") # unconventional order

