Re: [R] kernel in library ts

About this list Date view Thread view Subject view Author view

From: Adrian Trapletti (adrian@olsen.ch)
Date: Thu 08 Mar 2001 - 20:37:17 EST


Message-ID: <3AA760DC.F0EA6DC5@olsen.ch>


> library(ts)
#
# The following works as I expected,
#
> kernel("daniell",m=5)
Daniell(5)
coef[-5] = 0.09091
coef[-4] = 0.09091
coef[-3] = 0.09091
coef[-2] = 0.09091
coef[-1] = 0.09091
coef[ 0] = 0.09091
coef[ 1] = 0.09091
coef[ 2] = 0.09091
coef[ 3] = 0.09091
coef[ 4] = 0.09091
coef[ 5] = 0.09091
#
# but the following does not. The doc says end points have
# weights halved.
#
> kernel("modified.daniell",m=5)
mDaniell(5)
coef[-5] = 0.10
coef[-4] = 0.10
coef[-3] = 0.10
coef[-2] = 0.10
coef[-1] = 0.10
coef[ 0] = 0.05
coef[ 1] = 0.10
coef[ 2] = 0.10
coef[ 3] = 0.10
coef[ 4] = 0.10
coef[ 5] = 0.10
#
# I do not know whether this is legal. Looking at the source I
# got the impression m can be a vector, and the Daniell kernel is
# applied in cascade. The resulting kernel seems to confirm this
# (because of its length) but the weights do not seem right. They
# are not even symmetrical;
#
> kernel("daniell",m=c(3,5,7))
unknown
coef[-15] = 0.0649351
coef[-14] = 0.0640693
coef[-13] = 0.0614719
coef[-12] = 0.0580087
coef[-11] = 0.0536797
coef[-10] = 0.0484848
coef[ -9] = 0.0424242
coef[ -8] = 0.0363636
coef[ -7] = 0.0303030
coef[ -6] = 0.0242424
coef[ -5] = 0.0181818
coef[ -4] = 0.0129870
coef[ -3] = 0.0086580
coef[ -2] = 0.0051948
coef[ -1] = 0.0025974
coef[ 0] = 0.0008658
coef[ 1] = 0.0649351
coef[ 2] = 0.0640693
coef[ 3] = 0.0614719
coef[ 4] = 0.0580087
coef[ 5] = 0.0536797
coef[ 6] = 0.0484848
coef[ 7] = 0.0424242
coef[ 8] = 0.0363636
coef[ 9] = 0.0303030
coef[ 10] = 0.0242424
coef[ 11] = 0.0181818
coef[ 12] = 0.0129870
coef[ 13] = 0.0086580
coef[ 14] = 0.0051948
coef[ 15] = 0.0025974
#
# Can someone clarify me on this?
#

This is an error in print.tskernel. The internal representation of the
kernel seems to be ok. The following print.tskernel does the right job:

print.tskernel<-function(k, digits = max(3, getOption("digits") - 3))
{
y <- c(rev(k$coef[2:(k$m + 1)]), k$coef)
i <- -k$m:k$m
cat(attr(k, "name"), "\n")
cat(paste("coef[", format(i), "] = ", format(y, digits = digits), sep =
""), sep = "\n")
}

You could use this print function until the bug is corrected in the R
source.

Adrian

PS: Brian: I did not fill out a bug report.

--
Dr.  Adrian Trapletti,  Olsen  &  Associates Ltd.
Seefeldstrasse 233, CH-8008  Zürich,  Switzerland
Phone: +41 (1) 386 48 47   Fax: +41 (1) 422 22 82
E-mail: adrian@olsen.ch  WWW: http://www.olsen.ch

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:35 EST