Home > Software engineering >  Converting to time series data (using daily/weekly data)
Converting to time series data (using daily/weekly data)

Time:08-17

I have data from a 4 week period where I now want to use it to predict for the 5th week. I'm initially trying to convert my data into a time series but as I'm now dealing with days and weeks rather than years i am unable to do so. My issue is when i use the following code

data

dat = c(14.2, 16.0, 13.0, 11.5, 14.8, 15.5, 16.7, 17.1, 14.4, 14.7, 14.8, 12.4, 12.8, 15.1, 13.4, 13.5, 13.6, 12.6, 15.2, 17.2, 16.5, 14.1, 14.0, 15.5, 13.9, 13.3, 15.9, 13.6, 15.1, 17.3, 15.3)

#converting to a ts
dat_ts = ts(dat, start = c(2020, 10))

My issue is here it now sees each data point as a month rather than a day so thinks my time series should run from 2020 to 2059

CodePudding user response:

As you want daily time series, you need to specify your frequency as 365:

weekly_ts <- ts(dat, 
                freq=365, 
                start= c(2020,245))
  • Related