If I look in the stats package for the 'R' source code for predict.HoltWinters 
I see the following lines:

    vars <- function(h) {
        psi <- function(j) object$alpha * (1 + j * object$beta) + 
            (j%%f == 0) * object$gamma * (1 - object$alpha)
        var(residuals(object)) * if (object$seasonal == "additive") 
            sum(1, (h > 1) * sapply(1L:(h - 1), function(j) crossprod(psi(j))))

There is more source code but my question is on the call to crossprod(psi(j)). 
Looking at the psi function I could see no elements that are vectors (or 
matrices) or that result in such. In fact if I replace the call to crossprod 
with:

            sum(1, (h > 1) * sapply(1L:(h - 1), function(j) {
                                                              r <- psi(j)
                                                              r*r
                                                            } ))

I get the same results. If I further augment my test by printing out the length 
of the return value from 'psi' I can see no case where 'psi' would return 
anything but a single number. So my question is, why the call to crossprod when 
simply squaring the number will do. Am I missing a case when the members of the 
HoltWinters fit would be vectors and then crossprod would be appropriate or is 
this just an oversight?

Thank you.

Kevin

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to