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

Bazman76 h_a_patience at hotmail.com
Sun Apr 8 20:39:24 CEST 2012


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?

code shown below:

 library("waveslim")

vols=read.csv(file="C:/Users/ocuk/My Documents/Abs Vol.csv", header=TRUE,
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.



More information about the R-help mailing list