First of all, let's see if Splus 5.0 will give us help when we are not sure of what we are looking for:
> help(periodogram,window=T) No documentation for topic "periodogram"The answer is, ``NO.'' I think this sucks. So I'll just go back to the old version of Splus. Remember on the owlnet machines that you can get that by typing
/net/owlnet-d/splus-3.4/sunos5/SplusAnyway, in the old version
S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc. S : Copyright AT&T. Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996 Working data will be in .Data > help.start() > #Ah, my old friend the help window. I type "periodogram" in "Topic" entry > #gives me "spec.pgram". I click on this and get a little window. > #boy there's a lot of options for this guy. Luckily, I know what > # most of them are. To get the raw periodogram > dldj.pg_spec.pgram(dldj,taper=0,detrend=F) > dldj.pg.f_dldj.pg$freq > dldj.pg.I_10^(.1*dldj.pg$spec) > #I'm still not sure I have the periodogram. > #Let's start with a plot. > X11() #have to popup a graphics window in old Splus > plot(dldj.pg.f,dldj.pg.I,xlab="freq",ylab="Periodogram", + main="Plot of Periodogram (?) for dldl") > #I meant "dldj" in the last word; oh well. > #Not that great, try again with a line plot > plot(dldj.pg.f,dldj.pg.I,xlab="freq",ylab="Periodogram", + main="Plot of Periodogram (?) for dldj",type="l") > #OK. Well, looks like a lot of noise. > #Let's see how many freqs there are > length(dldj.pg.f) [1] 148 > length(dldj) [1] 291 > 291/2 [1] 145.5 > #Damn. It padded on me even though I told it not to!!! > #Basically, it added some zeroes at the end to get a sample size > # easy for the FFT to use. I'll try again. > dldj.pg2_spec.pgram(dldj,taper=0,detrend=F,pad=0) > length(dldj.pg2$freq) [1] 148 > #I guess I'm stuck with it. That makes all the ANOVA that Box-Jenkins > # talks about basically not valid. But we'll try it anyway. > > 1/dldj.pg.f[2] [1] 294 > #So it padded 3 zeroes on the end to artificially make the series have > # 294 values. Remember that the index for the Fourier frequencies of > # a series with an even number N of observations is 0 to N/2, so there > # are a total of 1+N/2 Fourier frequencies. > #Let's see what the I(f) values > # look like for f > 0 with a histogram: > length(dldj.pg.I) [1] 148 > hist(dldj.pg.I[2:148]) > #Could be an exponential distribution -- looks like it > title(main="Histogram of Periodogram Values") > #the last check is with the variance: them expected value of the > # periodogram ordinates is 2 sigma^2 if it is a white noise (very > # good approximation here, I'm sure). > mean(dldj.pg.I) [1] 6.688483e-06 > var(dldj) [1] 6.741311e-06 > #Slight difference is due to padding, I'm sure. But we are getting > # the average of the "periodogram" equal to the variance (basically). > #So what we must have is 1/2 the periodogram. > #But this won't affect the ANOVA, because it is a ratio of values. > #So let's pretend we have the real periodogram (and not one with > # padding) and compute the ANOVA table. We want to look for > # a sinusoid of period 5 -- frequency 1/5 = .2. This isn't going > # to be exactly a Fourier frequency. See the paragraph beginning > # at the bottom of p. 36. So let's test the 3 frequencies closest > # to .2 > .4*147 [1] 58.8 > dldj.pg.f[59:61] [1] 0.1972789 0.2006803 0.2040816 > fstat.num_sum(dldj.pg.f[59:61])/6 > # 6 d.f. in the numerator of the F-statistic (2 per periodogram ordinate) > fstat.den_sum(dldj.pg.f[-(59:61)])/284 > # 1 d.f. lost from 291 for estimating the mean; 291-1-6 remain > #Note the negative subscripts gives everything but > fstat_fstat.num/fstat.den > fstat [1] 0.7829175 > #Clearly no evidence of a period 5 effect as F-statistics have to be > # somewhat larger than 1 to be significant. Just to get a p-value: > 1-pf(0.7829175,6,284) [1] 0.5839091 > #p-value of 0.58 not significant. Need a p-value less than 0.05 to > # be significant.The periodogram line plot and the histogram of the periodogram ordinate values are shown below.