anova
method for chantrics
objects
# S3 method for chantrics anova(object, ...)
object | Object of class |
---|---|
... | Further objects of class |
An object of class "anova"
inheriting from class "data.frame"
.
The columns are as follows:
The residual number of degrees of freedom in the model.
The increase in residual degrees of freedom with respect to the model in the row above.
The adjusted likelihood ratio statistic.
The p-value of the test that the model above is a "significantly better" model as the one in the current row.
Create an analysis of adjusted deviance table for one object (sequential), or
two or more nested models that have been adjusted using the
adj_loglik()
method. It uses the adjusted likelihood ratio test
statistic (ALRTS), as described in Section 3.5 of
Chandler and Bate (2007).
Each line represents the model as given above the table, with each line (except for the first line) showing the residual degrees of freedom of that model, the change in degrees of freedom, the ALRTS and the associated p-value in comparison to the model in the line above.
When a single model is specified, the function returns a sequential analysis of deviance table, where, iteratively, one term is being removed from the right of the full formula. This process is continued until the "intercept only" model is left. The row names are the names of the dropped term in comparison to the model in the line above.
If more than one model is specified, the function sorts the models by their
number of variables as returned by adj_loglik()
in
attr(x, "p_current")
.
Details of the ALRT can be found in chandwich::compare_models()
and in
Chandler and Bate (2007).
R. E. Chandler and S. Bate, Inference for clustered data using the independence loglikelihood, Biometrika, 94 (2007), pp. 167–183. doi: 10.1093/biomet/asm015 .
chandwich::compare_models: implementation of the comparison mechanism
# from Introducing Chandwich. set.seed(123) x <- rnorm(250) y <- rnbinom(250, mu = exp(1 + x), size = 1) fm_pois <- glm(y ~ x + I(x^2), family = poisson) fm_pois_adj <- adj_loglik(fm_pois) fm_pois_small_adj <- update(fm_pois_adj, formula = . ~ . - I(x^2)) fm_pois_smallest_adj <- update(fm_pois_adj, formula = . ~ 1) anova(fm_pois_adj, fm_pois_small_adj, fm_pois_smallest_adj)#> Analysis of Adjusted Deviance Table #> #> Model 1: y ~ x + I(x^2) #> Model 2: y ~ x #> Model 3: y ~ 1 #> #> Resid.df df ALRTS Pr(>ALRTS) #> 1 247 #> 2 248 1 1.82 0.1773 #> 3 249 1 116.73 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1# use different types of adjustment with type, default is "vertical" anova(fm_pois_adj, fm_pois_small_adj, fm_pois_smallest_adj, type = "cholesky")#> Analysis of Adjusted Deviance Table #> #> Model 1: y ~ x + I(x^2) #> Model 2: y ~ x #> Model 3: y ~ 1 #> #> Resid.df df ALRTS Pr(>ALRTS) #> 1 247 #> 2 248 1 1.89 0.1693 #> 3 249 1 165.99 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1#> Analysis of Adjusted Deviance Table #> #> Model 1: y ~ x + I(x^2) #> Model 2: y ~ x #> Model 3: y ~ 1 #> #> Resid.df df ALRTS Pr(>ALRTS) #> full model 247 #> I(x^2) 248 1 1.82 0.1773 #> x 249 1 116.73 <2e-16 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1