Re: [R] Simple spectral analysis

From: Petr Pikal <>
Date: Tue 09 Jan 2007 - 07:46:49 GMT


without beeing specific in spectrum analysis you will get frequencies and spectral densities fro spectrum()

>From help page

An object of class "spec", which is a list containing at least the following components:

freq vector of frequencies at which the spectral density is estimated. (Possibly approximate Fourier frequencies.) The units are the reciprocal of cycles per unit time (and not per observation spacing): see Details below.
spec Vector (for univariate series) or matrix (for multivariate series) of estimates of the spectral density at frequencies corresponding to freq.


This is the important part:

**The result is returned invisibly if plot is true.**

So if you call

spectrum(data) you will get plot but in case

sp <- spectrum(data)

you will get also object sp which has above mentioned components. Actual periods are obtainable by



On 8 Jan 2007 at 17:12, Georg Hoermann wrote:

Date sent:      	Mon, 08 Jan 2007 17:12:34 +0100
From:           	Georg Hoermann <>
Subject:        	[R] Simple spectral analysis

> Hello world,
> I am actually trying to transfer a lecture from Statistica to
> R and I ran into problems with spectral analysis, I think I
> just don't get it 8-(
> (The posting from "FFT, frequs, magnitudes, phases" from 2005
> did not enlighten me)
> As a starter for the students I have a 10year data set of air
> temperature with daily values and I try to
> get a periodogram where the annual period (365 days) should be clearly
> visible (in statistica I can get the frequencies and the period). I
> tried the spectrum() and pgram() functions, but did not find a way
> through... The final aim would be to get the periodogram (and the
> residuals from the reassembled data set...)
> Thanks and greetings,
> Georg
> The data set:
> air =
> read.csv("")
> airtemp = ts(T_air, start=c(1989,1), freq = 365) plot(airtemp)
> --
> Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany
> +49/431/23761412, mo: +49/171/4995884, icq:348340729, skype: ghoermann
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented,
> minimal, self-contained, reproducible code.

Petr Pikal mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed Jan 10 14:53:14 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 04:30:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.