predict.op: Obtain predicted values for a given operator matrix and data...

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

Description

Returns fitted values, optionally with standard errors.

Usage

1
2
3
4
5
## S3 method for class 'op'
predict(op, y, se = FALSE, newdata = op$at, interval = c("none", 
   "confidence", "prediction"), level = 0.95)
## S3 method for class 'stlop'
predict(stlop, y, ...)

Arguments

op

object of class "op" or "opblend".

stlop

object of class "stlop".

y

data vector with same length as the number of columns of the operator matrix in op or the fit operator matrix in stlop.

se

should standard errors be computed?

newdata

at which values should fits be computed? Valid values are 1 to n.ahead.

interval

should confidence or prediction intervals be computed?

level

level for the confidence or prediction intervals.

...

Details

If se=TRUE or interval is "confidence" or "prediction", and the argument op does not have a stats element, the auxiliary statistics will be computed. Also, if interval="prediction" and newdata was not specified, it will by default be all values beyond the length of the original series, up to n.ahead.

Value

If se = FALSE and interval="none", a vector giving the prediction for each point in the design space. If se = TRUE or interval is "confidence" or "prediction", a list containing a data frame data with components

x

the time values.

y

the observed series values.

at

the time values at which the fit was computed.

fit

the fitted/predicted values.

se.fit

an estimated standard error for each predicted value.

lower

lower confidence/prediction limit, if requested.

upper

upper confidence/prediction limit, if requested and additional elements.

residual.scale

the estimated scale of the residuals used in computing the standard errors.

df

an estimate of the effective degrees of freedom used in estimating the residual scale, intended for use with t-based confidence intervals.

Note

All of this can be done for loess fitting easily using loess() and predict.loess(). More important is predict.stlop() for obtaining predicted values and standard errors for the STL decomposition.

Author(s)

Ryan Hafen

References

R. B. Cleveland, W. S. Cleveland, J. E. McRae, and I. Terpenning (1990) STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6, 3-73.

W. S. Cleveland, E. Grosse and W. M. Shyu (1992) Local regression models. Chapter 8 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

See Also

stlOp, loessOp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
co2op <- stlOp(468, n.p = 12, l.window = 13, t.window = 19, 
   s.window = 35, s.degree = 1, n.ahead = 36)

co2pi <- predict(co2op, co2, interval="prediction") 

plot(co2pi, start=400, xlab="Time", ylab="CO2Concentration(ppm)") 

# a simulated example
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 <- 1:n 
set.seed(8765) 
ysim <- rf(x)

sop <- stlOp(200, n.p=7, t.window=105, t.degree=2, s.window="periodic") 
ysimCI <- predict(sop, ysim, interval="confidence", level=0.99) 
plot(ysimCI, fcol="gray", CIalpha=0.75) 

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