3
$\begingroup$

Could someone explain to me the difference between a periodogram and spectral density diagram?

enter image description here

The first diagram is produced with this block of code:

FF = abs(fft(datalist)/sqrt(128))^2
f = (0:63)/128
plot(f,FF[2:65],type="l",xlab="Frequenz",ylab="Spektrum")

and the second one with this code:

x.spec<-spectrum(datalist,log=c("no"))

In both diagrams I have two peaks, which are clearly higher than the others, but in the first they are almost the same, but in the second (periodogram) the second peak is obviously higher than the first peak. Why are these two diagrams different?

In a periodogram, the first peak shows that we have something periodic in our time series, or second one or both of them? How can I interpret these two peaks?

EDIT

in the first diagram for the second peak:

x=0.109375  y=36657.41193   
x=0.1171875 y=36731.11184

in the second diagram for the second peak:

x=0.128  y=88176.01878 

and My Data:

471 379 484 479 527 548 576 534 443 375 475 514 516 527 445 403 487 382 510 451 562 569 575 528 450 351 467 504 505 520 441 407 460 421 504 475 569 555 575 516 460 359 460 496 492 529 490 465 410 460 475 509 549 564 571 515 375 392 458 450 488 510 459 475 410 514 496 563 550 572 539 396 388 491 447 471 515 454 467 363 499 486 522 583 567 543 459 370 437 500 483 529 451 408 463 395 511 468 559 551 576 527 418 380 471 496 494 515 453 415 454 431 503 490 575 564 571 512 400 371 484

$\endgroup$
8
  • 1
    $\begingroup$ In the second graph it looks like the plotted point for the second peak is very close to the actual peak, while in the first graph the closest points to the second peak are on either side of the actual peak. Redo your calculations on a finer grid and they'll probably look more alike. $\endgroup$
    – Wayne
    Commented Mar 5, 2014 at 14:29
  • $\begingroup$ @Wayne I have read your very nice post here. the First peak in both of diagrams has the value almost 35000 but the value ofthe second peak is total different. the value of the second peak in thefirst diagram is almost 36000 but in the second one 88000. Do zou know why? $\endgroup$
    – TangoStar
    Commented Mar 6, 2014 at 10:38
  • 1
    $\begingroup$ Please list the x and y values for the second peak in each graph. $\endgroup$
    – Wayne
    Commented Mar 6, 2014 at 14:04
  • $\begingroup$ I have edited my post $\endgroup$
    – TangoStar
    Commented Mar 7, 2014 at 10:16
  • 1
    $\begingroup$ Try plotting both things on the same graph (use x.spec\$freq and x.spec\$spec), as points of different colors. I believe one part of your answer has to do with where the x points of the two different outputs lie (they're not the same) and how far apart they are. Then you can begin to address FFT issues that you aren't handling (see en.wikipedia.org/wiki/Periodogram). What you're doing is an FFT in concept, but it's not that simple in practice. $\endgroup$
    – Wayne
    Commented Mar 7, 2014 at 14:36

2 Answers 2

1
$\begingroup$

Periodogram is one way of estimating the spectral density, perhaps, the simplest way:

the basic modulus-squared of the discrete Fourier transform

There are many other ways to estimate the spectral density. In R spectrum call uses the same method that's in your first plot, but I think it additionally smoothes the data to achieve consistency

$\endgroup$
0
$\begingroup$

They're the same. I don't know the exact settings for spectrum, but it looks to me like some sort of smoothing has been applied.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.