mhart at terrigal.net.au
Sat Sep 23 11:18:54 CEST 2000
Thanks you Professor Ripley for your very fast reply. Well I hope I haven't
done anything wrong in my code. Yes I did mean spec.ar . I hope only the
values plotted are on a log scale and the internal values in the spec object
are not because I pick them out and use them for other things. I had told
the plot function I don't want log scale. Here is the code
tds <- Feed me my Data Please
cat("Number of data points = ",length(tds),"\n")
tds <- na.omit.ts(na.contiguous(tds))
cat("Processing",length(tds) ,"Contiguous Valid points.\n")
spt <- spec.ar(ar.yw(tds,aic=aicv,order.max=orderv), plot = FALSE)
# display the spectra
plot(spt,log=c("no"),main=paste(nser,spt$method,sep = "\n"))
I hope this gives the true linear amplitude of the spectral density and I
also hope the internal values in the spt variable also represent the linear
values at each frequency.
I guess the "detail" is what is confusing to me. It says that "The spectrum
here is defined with scaling 1/frequenxy(x)". Gven that 'x' is a time
series (a sequence of numbers evenly sampled in time - or an array of
numbers) I do not know what 1/frequency(x) means. Further more I do not
know if this scaling refers to the X axis or the Y axis. (I had previously
assumed it was the X axis but your comments suggest if may be the scaling of
the amplitude of the spectra and not the frequency of the spectra) Does
this mean that the amplitude of the power spectra is scaled on the basis of
what frequency that component of signal falls into, given that 'x' is an
array. [i.e. the scaling in any one graph changes across the band]?? I
hope not because this would throw out all my other calculations.
While you may argue that units are not relevant I don't have that luxery as
I have to write a report and the people who want the data (i.e. who are
paying my wages and hence indirectly for my family) want to know the units.
Furthermore the units are dependant on the definition of the spectral
density (and how it is calculated).
From: Prof Brian D Ripley <ripley at stats.ox.ac.uk>
To: Michael Hart <mhart at terrigal.net.au>
Cc: r-help at stat.math.ethz.ch <r-help at stat.math.ethz.ch>
Date: Saturday, 23 September 2000 5:59
Subject: Re: [R] Units
>On Sat, 23 Sep 2000, Michael Hart wrote:
>> I used the AR modelling written for R (S) on blood pressure and heart
>> signals. I used 60 one second samples and a model order of 20. I used
>> "ar" finction in the "ts" package.
>> Given that blood pressure is measured in mmHg would the spectral density
>> the graph displayed be [mmHg]sq/Hz ?
>> And the heart rate is measured in Beats Per Minute (bpm) - so would the
>> displayed spectral density be in (bpm)sq/Hz ?
>Well, ar() does not produce spectral densities! I assume you are using
>spectrum() or its helpers spec.pgram and spec.ar. The y-axis there is by
>default on *log scale*. I don't think the units are relevant (essentially
>they are determined by its being a spectral density), but the different
>definitions of spectral densities in use are pertinent: see the help pages,
>and Venables & Ripley for the exact definitions used by S-PLUS (and
>> I'm sorry if this seems a trivial question, however the resultant values
>> seem inconsistent with published data (although the spectral shape seems
>As ever, read the details! There is no universally accepted definition of
>`spectral density' (nor of `AR process' come to that).
>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