Hi All,
I have some data that I'm performing a time series analysis on where I'd like to get the positions of the peaks from the Periodogram (Time Series > Save Spectral Density). You can for example do this with the Air.jmp sample data table, putting in only a Y column variable. You can put the X, Time ID variable in, but it's not necessary.
Anyway, once you save the Spectral Density, there are several columns, :Spectral Density, :Periodogram, and :Frequency that are of interest, see screenshot below.

What I'm trying to do is find the row numbers of maybe the top 3 or 4 peaks in the :Periodogram column -- it's a bit easier to work with than the :Spectral Density column (see yellow highlighted areas). Once I have those row numbers, then I can find the corresponding values in the :Period and :Frequency columns to report back as a result.
The problem I have is being able to get those other values that aren't the Col Max(:Periodogram) result. I can get that just fine, but it's harder to pick out the other columns of interest. I'd like to do this with JSL so that the task is automated rather than having to use the lasso tool or something like that.
Any ideas or suggestions are much appreciated.
Thanks!,
DS
Here is an example of one way of finding the peaks.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dt << select where(
Try( :bp 8m[Row() - 1], 999 ) < :bp 8m[Row()] & :bp 8m[Row()] > Try( :bp 8m[Row() + 1], 0 )
);
Here is other option using Dif()
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Time Series/Air.jmp");
ts = dt << Time Series(Y(:Ozone Concentration));
dt1 = ts << Save Spectral Density;
ts << Close Window;
Close(dt, no save);
dt1 << Sort(By(:Period), Replace Table, Order(Ascending));
dt1 << New Column("PeriodogramPeaks", Numeric, Nominal, Formula(
Dif(:Periodogram) > 0 & Dif(:Periodogram, -1) > 0
));
dt1 << New Column("PeakRank", Numeric, Ordinal, Formula(
Col Number(:Periodogram, :PeriodogramPeaks) - Col Rank(:Periodogram, :PeriodogramPeaks) + 1
));
peak_rows = dt1 << Get Rows Where(:PeakRank <= 4 & :PeriodogramPeaks == 1);
dt1 << Select Rows(peak_rows);
dt1 << Markers(16);
gb = dt1 << Graph Builder(
Size(534, 456),
Show Control Panel(0),
Variables(X(:Period), X(:Frequency), Y(:Spectral Density), Y(:Periodogram)),
Elements(Position(1, 1), Line(X, Y, Legend(7)), Points(X, Y, Legend(8))),
Elements(Position(1, 2), Line(X, Y, Legend(5)), Points(X, Y, Legend(6))),
Elements(Position(2, 1), Line(X, Y, Legend(9)), Points(X, Y, Legend(10))),
Elements(Position(2, 2), Line(X, Y, Legend(11)), Points(X, Y, Legend(12)))
);Hi @jthi and @txnelson ,
Thank you both for your input. I ended up going with @jthi 's solution because it seemed to work better for the kind of data I am dealing with, using the spectral density graphs/data tables. I really appreciate both of your input on this, thanks again for another helpful solution!
DS