Description Usage Arguments Details Value Note Author(s) References See Also Examples
Returns fitted values, optionally with standard errors.
1 2 3 4 5 |
op |
object of class |
stlop |
object of class |
y |
data vector with same length as the number of columns of the operator matrix in |
se |
should standard errors be computed? |
newdata |
at which values should fits be computed? Valid values are 1 to |
interval |
should confidence or prediction intervals be computed? |
level |
level for the confidence or prediction intervals. |
... |
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.
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. |
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.
Ryan Hafen
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.