anova method for chantrics objects

# S3 method for chantrics
anova(object, ...)

## Arguments

object Object of class chantrics, as returned by adj_loglik(). Further objects of class chantrics, as returned by adj_loglik(), and named parameters that should be passed to chandwich::compare_models(). The type of adjustment, out of "vertical", "cholesky", "spectral", "none", as specified in the parameter type, can also be specified here.

## Value

An object of class "anova" inheriting from class "data.frame". The columns are as follows:

Resid.df

The residual number of degrees of freedom in the model.

df

The increase in residual degrees of freedom with respect to the model in the row above.

ALRTS

Pr(>ALRTS)

The p-value of the test that the model above is a "significantly better" model as the one in the current row.

## Details

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).

## References

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

## Examples


# 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)

#> 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"
#> 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
# sequential anova
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1