I have a timeseries for which I need PSD values using R. The data was sampled at non uniform intervals but I did a spline interpolation with the predict command to interpolate readings at exactly 0.01 seconds. I could obtain amplitude values from spec.pgram quite correctly but they are not psd values. However the psd values from the pspectrum command of the psd package are only between 0 and 0.5Hz while my area of interest extends to about 1.2Hz. The time series is: here
I am unable to get the psd range in R package psd to extend to a frequency of 1.5Hz
110 views Asked by user2004198 At
1
Note that your time points are not equidistant. For the sake of this answer, we'll assume a frequency of 12 samples per second.
You have to specify the frequency for
psd::pspectrum
. Assuming your data is loaded as adata.frame
calledx
:The
pspectrum
function also has a more detailed plot:Alternative
You can also use
stats::spectrum
, but it will require you to create ats
object:EDIT: Given new dataset (freq = 100)