add1 package:stats R Documentation _A_d_d _o_r _D_r_o_p _A_l_l _P_o_s_s_i_b_l_e _S_i_n_g_l_e _T_e_r_m_s _t_o _a _M_o_d_e_l _D_e_s_c_r_i_p_t_i_o_n: Compute all the single terms in the 'scope' argument that can be added to or dropped from the model, fit those models and compute a table of the changes in fit. _U_s_a_g_e: add1(object, scope, ...) ## Default S3 method: add1(object, scope, scale = 0, test = c("none", "Chisq"), k = 2, trace = FALSE, ...) ## S3 method for class 'lm': add1(object, scope, scale = 0, test = c("none", "Chisq", "F"), x = NULL, k = 2, ...) ## S3 method for class 'glm': add1(object, scope, scale = 0, test = c("none", "Chisq", "F"), x = NULL, k = 2, ...) drop1(object, scope, ...) ## Default S3 method: drop1(object, scope, scale = 0, test = c("none", "Chisq"), k = 2, trace = FALSE, ...) ## S3 method for class 'lm': drop1(object, scope, scale = 0, all.cols = TRUE, test = c("none", "Chisq", "F"), k = 2, ...) ## S3 method for class 'glm': drop1(object, scope, scale = 0, test = c("none", "Chisq", "F"), k = 2, ...) _A_r_g_u_m_e_n_t_s: object: a fitted model object. scope: a formula giving the terms to be considered for adding or dropping. scale: an estimate of the residual mean square to be used in computing Cp. Ignored if '0' or 'NULL'. test: should the results include a test statistic relative to the original model? The F test is only appropriate for 'lm' and 'aov' models or perhaps for 'glm' fits with estimated dispersion. The Chisq test can be an exact test ('lm' models with known scale) or a likelihood-ratio test or a test of the reduction in scaled deviance depending on the method. k: the penalty constant in AIC / Cp. trace: if 'TRUE', print out progress reports. x: a model matrix containing columns for the fitted model and all terms in the upper scope. Useful if 'add1' is to be called repeatedly. *Warning:* no checks are done on its validity. all.cols: (Provided for compatibility with S.) Logical to specify whether all columns of the design matrix should be used. If 'FALSE' then non-estimable columns are dropped, but the result is not usually statistically meaningful. ...: further arguments passed to or from other methods. _D_e_t_a_i_l_s: For 'drop1' methods, a missing 'scope' is taken to be all terms in the model. The hierarchy is respected when considering terms to be added or dropped: all main effects contained in a second-order interaction must remain, and so on. In a 'scope' formula '.' means 'what is already there'. The methods for 'lm' and 'glm' are more efficient in that they do not recompute the model matrix and call the 'fit' methods directly. The default output table gives AIC, defined as minus twice log likelihood plus 2p where p is the rank of the model (the number of effective parameters). This is only defined up to an additive constant (like log-likelihoods). For linear Gaussian models with fixed scale, the constant is chosen to give Mallows' Cp, RSS/scale + 2p - n. Where Cp is used, the column is labelled as 'Cp' rather than 'AIC'. The F tests for the '"glm"' methods are based on analysis of deviance tests, so if the dispersion is estimated it is based on the residual deviance, unlike the F tests of 'anova.glm'. _V_a_l_u_e: An object of class '"anova"' summarizing the differences in fit between the models. _W_a_r_n_i_n_g: The model fitting must apply the models to the same dataset. Most methods will attempt to use a subset of the data with no missing values for any of the variables if 'na.action=na.omit', but this may give biased results. Only use these functions with data containing missing values with great care. _N_o_t_e: These are not fully equivalent to the functions in S. There is no 'keep' argument, and the methods used are not quite so computationally efficient. Their authors' definitions of Mallows' Cp and Akaike's AIC are used, not those of the authors of the models chapter of S. _A_u_t_h_o_r(_s): The design was inspired by the S functions of the same names described in Chambers (1992). _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: 'step', 'aov', 'lm', 'extractAIC', 'anova' _E_x_a_m_p_l_e_s: require(graphics); require(utils) example(step)#-> swiss add1(lm1, ~ I(Education^2) + .^2) drop1(lm1, test="F") # So called 'type II' anova example(glm) drop1(glm.D93, test="Chisq") drop1(glm.D93, test="F")