Loading time series data with weekly seasonality - r

I have a data set for couple of years for prices wherein the prices are very low over the weekends as compared to weekdays.I want to load this as time series object in R. What could be the best approach so that I can capture the weekly seasonality (weekends price dips) of the data.
Thanks!

Use the ts function with frequency=7.

Related

Aggregating XTS by Week Commencing Sunday in R

I have a multivariate xts object containing daily time series for different marketing channels (about 4 years worth), and want to aggregate this into weekly data starting on Sunday.
I know I can use the following to get aggregate by weekly
sp_weekly_input <-apply.weekly(sp_xts, function(x){ c(ppc= sum(x$ppc_brand),
tv= sum(x$tv),
radio= sum(x$radio),
display= sum(x$display),
social= sum(x$social))})
But this will default to a Monday start, how can I override this and get a new multivariate xts for weekly channel spends starting on Sundays?

Time Series & Forecast - Daily Data for 7.5 months

I have daily sales data between 1/1/2017 and 10/15/2017. My first question is that I was trying to set the time series with the following command:
marketing = ts(df$Total_Sales_Spend, start=c(2017,1,1), frequency = 365)
However, when I try to decompose the TS, I am getting the following error:
time-series has no or less than 2 periods
I understand that it's because I don't have at least two years of data. So in this case what can I do?
Also, I'd like to forecast the daily sales numbers for the second half of October (16 days). How may I do that in this case? I wasn't able to set it up with zoo and arima.
Thank you.

Check Seasonality in time series

I have 2 years of hourly data.I want to check seasonality .
1.Decomposing the series shows seasonality.But since Decomposition is not enough
what else can i use to check seasonality in R?
2.I tried hourly seasonality , I am not sure on the period of seasonality.How to determine the frequency in R?
Frequency is the number of observations per unit of time. But, in my short experience, the unit of time depends on the event you are studying. For example, if you have monthly data of a yearly seasonal event (like the flowering of some plants) and you sampled 5 times each month, frequency will be 5*12. I suggest you decompose your time series and and check for seasonality there. You can use ts, stl and plot.stl. Try to adjust the parameters as best as you can but also try to check what happens when you change them.
Please read through below link, if you feel to keep multiple seasonal periods in data, you can also paste sample of your data here for further suggestions
https://robjhyndman.com/hyndsight/seasonal-periods/

weekly time series in r, arima

I have a data frame with the following column names.
"week" "demand" "product-id"
The problem is to convert it into a time series object.
week is a number like 3,4,5,6,7,8,9 etc., and demand is in units and product-id is unique.
I want to convert the week column into time series, so as to prepare for modeling.
I want to predict weeks 10 and 11 demand by using an ARIMA model. How do I do that?
myTS <- ts(mydataframe[-1], frequency = 52)
will convert your demand and productId to a timeseries of 52 observations per year. For more elaborate timeseries, check package xts. Also compare this post on weekly data with ts.

Time Series for Periods Over One Year

I'm having trouble doing time series for my data set. Most examples have quarterly or monthly frequencies but my issue comes with data that is collect annually or every two years. Consider my code:
data<-data.frame(year=seq(1978,2012,2), number=runif(18,100,500))
time<-ts(data$number, start=1978, frequency=.5)
decomp<-decompose(time)
Error in decompose(time) : time series has no or less than 2 periods
How do I make R recognize time series values from data that is collected over an annual basis? Thanks!
Seasonal decomposition only makes sense with intra-yearly data, because you have seasons within years. So, trying to calculate seasonal effects with decompose on data collected every two years you get the error.

Resources