[R] strange spectrum() plot

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 22 18:47:49 CET 2001


On Mon, 22 Jan 2001, Petr Pikal wrote:

> Dear R-users
> I am a beginner and I use some functions without deep understanding of
> math behind them - sorry :-(
>
> I used a spectrum() function from ts library several times. I learned
> from sunspots dataset, that the result shall be a plot with peak(s). I can
> get also a list object with $freq, $spec values and of course some other.
>
> I can make reciprocal of these $freq values which correspond to
> peak(s) at $spec value(s). In case of sunspots series I get something
> close to 11 and as I know that sun spots occurs at 11 year period I can
> deduct that the peak(s) indicates a periodic nature of time series and I
> can compute the time between periods.
>
> My problem is that with my newest time series I have got a bit
> different plot not with peaks but with "valleys". (See attached picture)

That's too long to answer here.  Look at the references on the help page,
especially Bloomfield (which has a 2000 2nd ed).

In particular, you really should not the using the default setting sof
spectrum.

> My questions are:
>
> Does anybody know if these valeys mean something? Can I deduct
> some facts about my time series from such plot?
>
> The other question:
>
> Can I mimic a peaks() function fro S+ in R?

Yes, most easily by writing some C code, but also via embed.
Say

span <- 3
z <- embed(series, span)
max.col(z) == 1 + span %/% 2

> I am using P133, 32mb memory, W95 and R 1.2.0 but I suppose it is
> irrelevant to my questions.
>
> Thank you.
>
>
> Petr Pikal
> Precheza a.s.
> Nabr.Dr.E.Benese 24
> tel: 00420 641 25 2257
>      +420 (0)724 008 364
>      petr.pikal at precheza.cz
>      p.pik at volny.cz
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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 at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list