Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Uwe Ligges



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)

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.

__
R-help@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.


__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Bazman76
OK so I neeed to understan better what it it they are trying to measure.

I understood (incorrectly it seems) that they were simply different methods
to get the same result?

--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4542985.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Uwe Ligges



On 09.04.2012 17:01, Bazman76 wrote:

OK so I neeed to understan better what it it they are trying to measure.

I understood (incorrectly it seems) that they were simply different methods
to get the same result?


Yes. Also note this is a mailing list and you are lucky I was able to 
remember the context. Please always quote the prior thread and do not 
only send to the list.


Uwe Ligges





--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4542985.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread peter dalgaard

On Apr 9, 2012, at 16:55 , Uwe Ligges wrote:

 
 
 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?


That wasn't the question There is a raw series and two spectra, and it is 
the difference between the latter that is remarkable. Offhand, this is of 
course a bit like comparing a model fit to a nonparametric smoother of ordinary 
measurements: Sometimes the data just do something that the model says that 
they can't do and you get huge discrepancies. So the first reaction must be 
that an autoregressive model is just wrong for these data. My second reaction 
would be that the original series look a bit like they might have an asymmetric 
distribution, so perhaps a log or a square root transformation is warranted. 

That being said, I'm still quite stumped trying to explain the pattern in the 
raw periodogram. Notice that what you are seeing is not so much an initial peak 
as a region in which the spectrum drops effectively to zero. Have the data by 
any chance been subject to some sort of preprocessing that removes 
low-frequency components?

At any rate, this isn't really about R, is it?

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Bazman76
oops sorry

n 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? 
« [hide part of quote]

*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) 
 
 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) 
 
 -- 
 [hidden email] 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. 
« [hide part of quote]

 


*OK so I neeed to understan better what it it they are trying to measure. 

I understood (incorrectly it seems) that they were simply different methods
to get the same result?  *

--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4543140.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Bazman76
Yes I agree, there may be something pathalogical in the way at least one of
the models handles the data.  That's why I was trying to get a better handle
on how the two functions spec.prgm() and spec.ar() work.

The data has been processed by a wavelet analysis, so what you are seeing as
the raw data is in fact the level1 details from the wavelet anlaysis.

In theory this should only have high frequency components, that was why I am
so surpirsed to see such strong components at low frequencies.

That is not a R quesiton per se, but surely how spec.prgm() and spec.ar()
work is?



--
View this message in context: 
http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4543191.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Bert Gunter
On Mon, Apr 9, 2012 at 9:27 AM, Bazman76 h_a_patie...@hotmail.com wrote:
 Yes I agree, there may be something pathalogical in the way at least one of
 the models handles the data.  That's why I was trying to get a better handle
 on how the two functions spec.prgm() and spec.ar() work.

 The data has been processed by a wavelet analysis, so what you are seeing as
 the raw data is in fact the level1 details from the wavelet anlaysis.

 In theory this should only have high frequency components, that was why I am
 so surpirsed to see such strong components at low frequencies.

 That is not a R quesiton per se, but surely how spec.prgm() and spec.ar()
 work is?

Not necessarily, if they are e.g. C or Fortran programs merely called
by R. Indeed, even if written in R, if the algorithms are the issue,
then that is essentially a statistics/numerical analysis matter, not
an R programming one.

-- Bert




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Difference-between-spec-pgram-spec-ar-tp4541358p4543191.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
R-help@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.


Re: [R] Difference between spec.pgram spec.ar

2012-04-09 Thread Prof Brian Ripley

On 09/04/2012 18:52, Bert Gunter wrote:

On Mon, Apr 9, 2012 at 9:27 AM, Bazman76h_a_patie...@hotmail.com  wrote:

Yes I agree, there may be something pathalogical in the way at least one of
the models handles the data.  That's why I was trying to get a better handle
on how the two functions spec.prgm() and spec.ar() work.

The data has been processed by a wavelet analysis, so what you are seeing as
the raw data is in fact the level1 details from the wavelet anlaysis.

In theory this should only have high frequency components, that was why I am
so surpirsed to see such strong components at low frequencies.

That is not a R quesiton per se, but surely how spec.prgm() and spec.ar()
work is?


Not necessarily, if they are e.g. C or Fortran programs merely called
by R. Indeed, even if written in R, if the algorithms are the issue,
then that is essentially a statistics/numerical analysis matter, not
an R programming one.


Which is why the help pages often (and do here) have definitive 
references.  So the best course of action is to start following up the 
references.


--
Brian D. Ripley,  rip...@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 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


[R] Difference between spec.pgram spec.ar

2012-04-08 Thread Bazman76
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.

__
R-help@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.