[R] Odp: Help with 'spectrum'
Petr PIKAL
petr.pikal at precheza.cz
Fri Sep 12 15:34:17 CEST 2008
Hi
r-help-bounces at r-project.org napsal dne 09.09.2008 18:44:34:
> For the command 'spectrum' I read:
>
> The spectrum here is defined with scaling 1/frequency(x), following
S-PLUS.
> This makes the spectral density a density over the range
(-frequency(x)/2,
> +frequency(x)/2], whereas a more common scaling is 2π and range (-0.5,
0.5]
> (e.g., Bloomfield) or 1 and range (-π, π].
>
>
> Forgive my ignorance but I am having a hard time interpreting this. Does
this
> mean that in the spectrum output every element of the $spec array is
scaled by
> 1/frequency(x)? I am having a hard time determing what is meant by
> 'frequency'.Say I define a time series for a year with samples for every
day.
> I input a 'frequency' of 365 (which in my mind is the period). On the
output
> of 'spectrum' would this mean that every element of the $spec array is
scaled
> by 1/365? There is a corresponding frequency array on the output from
> 'spectrum'. If the frequency is 365 and an element in the frequency
array
> output from 'spectrum' is .1 am I to assume that the period is 36.5 and
a
> corresponding sin wave would be sin(2 * pi * 36.5/365)?
Well, although I am not an expert in this matter I try to explain my
humble understanding of spectrum results.
sss<-spectrum(sunspots)
sss$freq[which.max(sss$spec)]
[1] 0.09166667
1/sss$freq[which.max(sss$spec)]
[1] 10.90909
you can see that maximum of spec value is for this time series at freq
0.09 and 1/0.09 is almost eleven. Knowing that sunspots have periodicity
11 years I assume that for each series I can get an information about its
periodicity by 1/freq. E.g. if your series is days 1/freq means period in
days.
Regards
Petr
>
> Thank you in advance for helping me clear up some confusion.
>
> Kevin
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list