Sorry if my question is silly but I am extremely new to Data Science and Time series analysis.
So I have Tv program viewerships for the last 1 year and want to predict for the next 2 weeks. The data is of the form:
Year, Date, Week_day, Channel, Program, start_time, end_time, length, avg_impressions
avg_impressions is the average of all impressions of the program excluding the breaks. For example, if there were 10 impressions until first break, 20 impressions after first break until second and 30 impressions after the third break to the end, avg_impressions will be 20.
I want to do a time series analysis for the prediction. The data has 211,720 entries for 14 different channels. The data is from 10/10/2015 to 9/9/2016.
I am not very sure on how to convert the ``Impressions` into a time series object. I tried:
pts <- ts(train_agg$Impressions, start=c(2015, 10, 10), end=c(2016, 9, 9), frequency=357)
Is this format correct? I want to check for seasonality in the data. (I read I could
tbats on the
ts object for that).
My R code for what all i did till now:
train_data <- head(prog, 207595) test_data <- tail(prog, 4126) colnames(train_data) <- "Impressions" colnames(test_data) <- "Impressions" train_agg <- aggregate(Impressions~date_in_days, data=subset(train_data, Channel=="NBC" & Hour==19), mean) test_agg <- aggregate(Impressions~date_in_days, data=subset(test_data, Channel=="NBC" & Hour==19), mean) pts <- ts(train_agg$Impressions, start=c(2015,10,10), end=c(2016,9,9), frequency=357) plot.ts(pts) pts.msts <- msts(pts,seasonal.periods=c(7,357)) model <- tbats(pts.msts) plot(forecast(model, h=7)) forecast(model, h=7) accuracy(model)
Is this the right way? I am totally lost. Can someone please give me pointers as to what I should do?