Hello everybody,
I am working with time series of daily counts of hospital admissions.
Time-series plots of these data reveal distinct seasonal cycles. One
approach is to use harmonic wave terms to smooth these patterns. The
frequency
or period of the harmonic wave (cosine or sine) is determined by term
2*pi*k/365.25.
For an annual cycle, k=1, for a 2-month cycle k=6 etc.
Here comes my question:
I would like to perform a "harmonic analysis" with integer and
noninteger
values of k, returning which k-values are significant. How can I do
this
in S-Plus?
I have written the followin function (for some fixed integer values
of k) .... this will give me the model deviances. I am sure that this
is
not the way to go, since I want the model to tell me which k's are
significant.......
As you can see I don't know very much of spectral analysis, but could
not
find the right documentation either.
sin.cos.fcn <- function(k, time) {
X <- matrix(0, length(time), 2*k)
for(i in 1:k) {
X[,i] <- sin(i*2*pi*time/365)
X[,k+i] <- cos(i*2*pi*time/365)
}
X
}
m0 <- glm(cvd ~ time ,
family=quasi(link="log",var="mu"),
na.action=na.omit, data=d.cardio.yr)
m1 <- glm(cvd ~ sin.cos.fcn(1,time),
family=quasi(link="log",var="mu"),
na.action=na.omit, data=d.cardio.yr)
m2 <- glm(cvd ~ sin.cos.fcn(2,time),
family=quasi(link="log",var="mu"),
na.action=na.omit, data=d.cardio.yr)
m3 <- glm(cvd ~ sin.cos.fcn(3,time),
family=quasi(link="log",var="mu"),
na.action=na.omit, data=d.cardio.yr)
anova(m0,m1,m2,m3, test="Cp")
I would appreciate any kind of help or information.
Thanks a lot in advance!
Regards,
Petra Koken
NIEHS
tel: 919 541 2271
|