I was trying to use the following code to seasonally adjusted quarterly frequency data,
in the excel file "Q.xlsx", in the first column, i have the "Date", i have them format like
3/1/1992
6/1/1992
9/1/1992
12/1/1992
3/1/1993
6/1/1993
9/1/1993
12/1/1993
however, i got the following error message
"Error in x13_prepare(list = list, na.action = na.action, iofile = iofile) :
xreg and x must be of the same frequency."
what format of Date i should use in the excelsheet to read quarterly data into R ? thanks!
#read excel to data frame
df <- read_excel("Q.xlsx")
df
#read time series and SA
ts <- read.zoo(df)
ts <- as.ts(aggregate(ts, as.yearqtr, sum)) #aggregate to monthly, use as.yearqtr if quarterly
sa <- seas(
x = ts,
xreg = genhol(cny, start = 0, end = 0, center = "calendar"),
regression.aictest = "td",
regression.usertype = "holiday"
)
sad <- final(sa)
sad
You should not need to specify a format when reading in the data set, thought I believe you can.
If I am understanding you correctly ``df <- read_excel("Q.xlsx")` is working.
If so, you can change data types in df.
Use
str(df)
or
glimpse(df)
to see what R thinks are your data types. They do basically the same thing but the formatting is slightly different.
It would be very helpful if you supplied us with some sample data.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.