How to check the periodicity of a series in the R?

Asked

Viewed 35 times

3

I have a database with 5182 series and I need to check if these are daily, monthly or quarterly. Doing this job manually would take a lot of time, so my question is:

It is possible to check whether the series is daily, monthly or quarterly by R? I looked for functions that could help me in the package lubridate, but I was unsuccessful.

I found no content on the internet.

My series can be imported in xts and tried to use the functions apply.monthly and apply.quarterly, but unsuccessfully too.

dput of a daily series:

library(xts)

structure(c(26229, 26260, 26509, 23908, 24630, 25056, 25625, 
26328, 26136, 26758), class = c("xts", "zoo"), index = structure(c(631152000, 
633830400, 636249600, 638928000, 641520000, 644198400, 646790400, 
649468800, 652147200, 654739200), tzone = "UTC", tclass = "Date"), .Dim = c(10L, 
1L), .Dimnames = list(NULL, "ONS"))

dput of a monthly series:


library(xts)

structure(c(100, 97.77, 102.296751, 105.4372612557, 98.6260141785818, 
102.068062073414, 96.1787348917783, 99.5930799804364, 99.3839345124775, 
101.789025727679, 100.587915224093, 136.849858662378, 97.1360296785561, 
92.4540730480497, 111.499612095948), class = c("xts", "zoo"), index = structure(c(978307200, 
980985600, 983404800, 986083200, 988675200, 991353600, 993945600, 
996624000, 999302400, 1001894400, 1004572800, 1007164800, 1009843200, 
1012521600, 1014940800), tzone = "UTC", tclass = "Date"), .Dim = c(15L, 
1L), .Dimnames = list(NULL, "ABRAS"))

dput of a quarterly series:

library(xts)

structure(c(100.02371815779, 100.399271227704, 104.783008026283, 
103.399270148983, 103.826835694183, 104.860634194759, 106.649720841688, 
107.200262930774, 104.366017872757, 106.839050383675, 107.176451393191, 
105.728641139081, 105.507041194439, 105.966611903664, 106.712856743994
), class = c("xts", "zoo"), index = structure(c(825638400, 833587200, 
841536000, 849398400, 857174400, 865123200, 873072000, 880934400, 
888710400, 896659200, 904608000, 912470400, 920246400, 928195200, 
936144000), tzone = "UTC", tclass = "Date"), .Dim = c(15L, 1L
), .Dimnames = list(NULL, "PIB_sa"))

1 answer

3


You can use the package Tsstudio with the function ts_info

ts_info(sua_serie)

Output example:

 The a series is a xts object with 1 variable and 15 observations
 Frequency: quarterly 
 Start time: 1996-03-01 
 End time: 1999-09-01 
  • Thank you very much!

  • Hello Alexandre, good afternoon! For nothing! Big hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.