# [R] Difference between spec.pgram & spec.ar

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Apr 9 16:55:58 CEST 2012

```
On 08.04.2012 20:39, Bazman76 wrote:
> Hi there,
>
> Can someone explain what the difference between spec.pgram and spec.ar is?
>
> I understand that they attempt to do the same thing one using an AR
> estimation of the underlying series to estimate teh sensity the other using
> the FFT. However when applied to teh same data set they seem to be giving
> quite different results?
>
> http://r.789695.n4.nabble.com/file/n4541358/R_example.jpg
>
>
> Clearly the spec.ar() result seems to be smoothed but the results are also
> generally very different only really sharing the peak as the frequencies go
> towards zero.
>
> Can someone please explain why these two functions produce such different
> results on the same data set?

Because they really measure different things? Why do you expect to get
the same output in time as well as in frequency domain?

Uwe Ligges

>
> code shown below:
>
>   library("waveslim")
>
> sep=",")
> x<-ts(vols[,1])
> #x
>
> ## LA(8)
> vol.la8<- mra(x, "la8", 4, "modwt")
> names(vol.la8)<- c("d1", "d2", "d3", "d4", "s4")
> ## plot multiresolution analysis of IBM data
> #par(mfcol=c(6,1), pty="m", mar=c(5-2,4,4-2,2))
> par(mfcol=c(3,1), pty="m", mar=c(5-2,4,4-2,2))
> plot.ts(x, axes=F, ylab="", main="(abs rtns)")
> #for(i in 1:5)
> #	plot.ts(vol.la8[[i]], axes=F, ylab=names(vol.la8)[i])
> #axis(side=1, at=seq(0,1600,by=100),
> #		labels=c(0,"",200,"",400,"",600,"",800,"",1000,"",1200,"",1400,"",1600))
>
> spectrum(vol.la8[[1]])
> specx<- spec.ar(x)
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4541358.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help