2
votes

I have a series of data for daily sales amount from 1/1/2018 to 10/15/2018, the example is shown as follows. It is already observed there are some monthly cycling patterns on the sales amount, say there is always a sales peak at the end of each month, and slight fluctuations in the amount in the middle of the month. Also, in general the sales in June, July and August is higher than that in other month. Now I need to predict the sales amount for the 10 days after 10/15/2018. I'm new to time series and ARIMA. Here I have two questions:
1. How to create such a daily time series and plot it with the date?
2. How can I set the cycle(or frequency) to show the monthly cycling pattern?

Date             SalesAmount
1/1/2018     31,380.31 
1/2/2018     384,418.10 
1/3/2018     1,268,633.28 
1/4/2018     1,197,742.76 
1/5/2018     417,143.36 
1/6/2018     693,172.65 
1/8/2018     840,384.76 
1/9/2018     1,955,909.69 
1/10/2018    1,619,242.52 
1/11/2018    2,267,017.06 
1/12/2018    2,198,519.36 
1/13/2018    584,448.06 
1/15/2018    1,123,662.63 
1/16/2018    2,010,443.35 
1/17/2018    958,514.85 
1/18/2018    2,190,741.31 
1/19/2018    811,623.08 
1/20/2018    2,016,031.26 
1/21/2018    146,946.29 
1/22/2018    1,946,640.57 
2
If you are new in Time Series please read some good books. This is a good online TS book where you will get simple explanation along with R codes. This is written by 'Rob J Hyndman'. The Author also developed few well known R packages like forecast etc.Raja Saha

2 Answers

0
votes

As there isn't a reproducible example provided in the question, here's one that may help you visualize your data better.

Using the dataset: economics and library ggplot2, you can easily plot a timeseries.

library(ggplot2)
theme_set(theme_minimal())

# Basic line plot
ggplot(data = economics, aes(x = date, y = pop))+
  geom_line(color = "#00AFBB", size = 2)

plot1

For your question, you just need to pass in x=Date and y=SalesAmount to obtain the plot below. To your 2nd question on predicting sales amount with timeseries, you can check out this question over here: Time series prediction using R

0
votes

The first thing that you need before any kind of forecasting is to detect if you have any kind of seasonality. I recommend you to add more data as it is complex to determine if you have a repeated pattern with so few. Anyway you can try to determine the seasonality as follows:

library(readr)
test <- read_table2("C:/Users/Z003WNWH/Desktop/test.txt", 
col_types = cols(Date = col_date(format = "%m/%d/%Y"), 
SalesAmount = col_number()))
p<-periodogram(test$SalesAmount)
topF = data.table(freq=p$freq, spec=p$spec) %>% arrange(desc(spec))
1/topF

When you will add more data you can try to use ggseasonplot to visualize the different seasons.