There is any R packages for calculation period of some function? I am looking for r-function like this:
x <- seq(0, 50, by = 0.05)
y <- sin(x)
p <- calcPeriod(x, y) # result = 2pi
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you are looking for something along the lines of a Fast Fourier Transform. I’m no expert, but I think you can do something along the lines of the following:
The function
spectrumis actually a wrapper function forspec.pgramandspec.ar. Use with caution since thecalcPeriodfunction is actually only identifying the maximum periodicity. For unevenly sampled series, a least-squares specrtal analysis would also identify the dominant periodicity (example link).