2
votes

I've been struggling to import a timeseries dataset and then, plot the data by date, run decompose & run arima.

The problem seems to be using the ts() method and how I set frequency and the start date. My sample data is:

dates,salesvol
1/07/2011,320
2/07/2011,400
3/07/2011,250
4/07/2011,300
5/07/2011,345

salesvol <- read.csv("salesvol.csv", header=TRUE, sep=",", stringsAsFactors = FALSE)
salesvol[[1]] <- as.Date(salesvol[[1]],format='%d/%m/%Y') 
salesvol_ts <- ts(salesvol$saleesvol, frequency = 365, start=c(2011,7))

I've tried various options for start but am not sure what to set it to? Any help would be appreciated.

Thanks

Try change start=c(2011, 7) to c(2011, 182). But this parameter is only for beauty, it's not very important.Rcoster
I now get Time Series object as: Start = c(2011, 182) End = c(2011, 243) Frequency = 365 [1] 320 400 250 300 345 but when I plot the data I get dates in the x-axis as 2011.50orbital
If the intention is to have annual periods then you can't represent a daily time series as a ts object because there are not the same number of days per year. If you drop one day each leap year so that every year has 365 days then it can be done. zoo and xts packages can represent irregular time series including daily time series.G. Grothendieck