anova.asterOrReaster: Analysis of Deviance for Reaster Model Fits

Description Usage Arguments Details Value Warning See Also Examples

View source: R/anova.R

Description

Compute an analysis of deviance table for two or more aster model fits with or without random effects.

Usage

1
2
3
4
## S3 method for class 'asterOrReaster'
anova(object, ...,
    tolerance = .Machine$double.eps ^ 0.75)
anovaAsterOrReasterList(objectlist, tolerance = .Machine$double.eps ^ 0.75)

Arguments

object, ...

objects of class "asterOrReaster", typically the result of a call to aster or reaster.

objectlist

list of objects of class "asterOrReaster".

tolerance

tolerance for comparing nesting of model matrices.

Details

Constructs a table having a row for the degrees of freedom and deviance for each model. For all but the first model, the change in degrees of freedom and deviance is also given, as is the corresponding asymptotic P-value.

For objects of class "reaster", the quantity called deviance is only approximate. See references on help for reaster.

When objects of class "reaster" are among those supplied, degrees of freedom for fixed effects and degrees of freedom for variance components are reported separately, because tests for fixed effects are effectively two-tailed and tests for variance components are effectively one-tailed.

In case models being compared differ by one variance component, the reference distribution is half a chi-square with the fixed effect degrees of freedom (difference of number of fixed effects in the two models) and half a chi-square with one more degrees of freedom.

In case models being compared differ by two or more variance components, we do not know how to how to do the test. The reference distribution is a mixture of chi-squares but the mixing weights are difficult to calculate. An error is given in this case.

Value

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

Warning

The comparison between two or more models by anova or anovaAsterOrReasterList will only be valid if they are (1) fitted to the same dataset, (2) models are nested, (3) have the same dependence graph and exponential families. Some of this is currently checked. Some warnings are given.

See Also

aster, reaster, anova.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
### see package vignette for explanation ###
library(aster)
data(echinacea)
vars <- c("ld02", "ld03", "ld04", "fl02", "fl03", "fl04",
    "hdct02", "hdct03", "hdct04")
redata <- reshape(echinacea, varying = list(vars), direction = "long",
    timevar = "varb", times = as.factor(vars), v.names = "resp")
redata <- data.frame(redata, root = 1)
pred <- c(0, 1, 2, 1, 2, 3, 4, 5, 6)
fam <- c(1, 1, 1, 1, 1, 1, 3, 3, 3)
hdct <- grepl("hdct", as.character(redata$varb))
redata <- data.frame(redata, hdct = as.integer(hdct))
level <- gsub("[0-9]", "", as.character(redata$varb))
redata <- data.frame(redata, level = as.factor(level))
aout1 <- aster(resp ~ varb + hdct : (nsloc + ewloc + pop),
    pred, fam, varb, id, root, data = redata)
aout2 <- aster(resp ~ varb + level : (nsloc + ewloc) + hdct : pop,
    pred, fam, varb, id, root, data = redata)
aout3 <- aster(resp ~ varb + level : (nsloc + ewloc + pop),
    pred, fam, varb, id, root, data = redata)
anova(aout1, aout2, aout3)

# now random effects models and models without random effects mixed
## Not run: 
### CRAN policy says examples must take < 5 sec.
### This doesn't (on their computers).
data(radish)
pred <- c(0,1,2)
fam <- c(1,3,2)
rout2 <- reaster(resp ~ varb + fit : (Site * Region),
    list(block = ~ 0 + fit : Block, pop = ~ 0 + fit : Pop),
    pred, fam, varb, id, root, data = radish)
rout1 <- reaster(resp ~ varb + fit : (Site * Region),
    list(block = ~ 0 + fit : Block),
    pred, fam, varb, id, root, data = radish)
rout0 <- aster(resp ~ varb + fit : (Site * Region),
    pred, fam, varb, id, root, data = radish)
anova(rout0, rout1, rout2)

## End(Not run)

Example output

Loading required package: trust
Analysis of Deviance Table

Model 1: resp ~ varb + hdct:(nsloc + ewloc + pop)
Model 2: resp ~ varb + level:(nsloc + ewloc) + hdct:pop
Model 3: resp ~ varb + level:(nsloc + ewloc + pop)
  Model Df Model Dev Df Deviance P(>|Chi|)    
1       17   -2746.7                          
2       21   -2712.5  4   34.203 6.772e-07 ***
3       33   -2674.7 12   37.838 0.0001632 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Deviance Table

Model 1: resp ~ varb + fit:(Site * Region)
Model 2: resp ~ varb + fit:(Site * Region), ~0 + fit:Block
Model 3: resp ~ varb + fit:(Site * Region), ~0 + fit:Block, ~0 + fit:Pop
  Mod Df Fix Mod Df Rand Mod Dev Df Fix Df Rand Deviance   P-value
1          6           0 1167586                                  
2          6           1 1175913      0       1   8327.4  0.00e+00
3          6           2 1176704      0       1    791.5 1.94e-174

aster documentation built on June 13, 2021, 9:06 a.m.