anova.op: ANOVA for objects of class '"op"'

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

ANOVA table calculation for objects of class "op"

Usage

1
2
## S3 method for class 'op'
anova(mod1, mod2, y)

Arguments

mod1

null model operator matrix of class "op".

mod2

alternative model operator matrix of class "op".

y

data that the models are applied to

Details

Calculates ANOVA as described in the reference below.

Value

An object of class "anova".

Note

This function treats the model with the larger residual sum of squares as the null model and carries out the test accordingly. With loess anova, the calculations typically are approximate since exact calculations would involve matrix products, but in this implementation, the calculations are exact since operator already operates at this level of time complexity.

Author(s)

Ryan Hafen

References

W. S. Cleveland and S. J. Devlin. Locally weighted regression: An approach to regression analysis by local fitting. Journal of the American Statistical Association, 83(403):596–610, 1988.

See Also

loessOp, loessOp.

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
# a simulated example with periodic component
rf <- function(x) { 
  n <- length(x) 
  sin(x * 2 * pi/200) + rnorm(n, sd = 0.5) + rep(c(0.5, 0.25, 
  0, -0.25, -0.5, -0.25, 0), ceiling(n/7))[1:n] 
}
n <- 200
x <- c(1:n) 
set.seed(8765) 
ysim <- rf(x)

# null model: no seasonality
lop <- loessOp(n, span=105, degree=2)

# alternative model: seasonality
sop <- stlOp(n, n.p=7, t.window=105, t.degree=2, 
   s.window="periodic") 

anova(sop$fit, lop, ysim)
# result:
# [1] Null model: loess with degree=2, span=105
# [2]  Alt model: stl with n.p=7
#                   seasonal smoothing: periodic
#                   trend smoothing: deg=2, span=105
#                   l.degree=2, l.window=7, inner=2
# 
# Analysis of Variance: numerator df 6, denominator df 187.09
# 
#        ENP    RSS F-value    Pr(>F)    
# [1,]  6.05 68.884                      
# [2,] 12.05 52.751  9.5281 3.903e-09 ***
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

hafen/operator documentation built on May 17, 2019, 2:23 p.m.