I have daily data that starts from 01-10-2014 to 30-09-2016. I am trying to create a time series using ts. I believe my specifications for ts function is correct but I am still getting wrong Start and End date. I tried both the day of the as the argument to the ts as suggested in different forums :
data=runif(731)
obs_ts_daily <- ts(data, # random data
start=c(2014,274),
frequency =365 )
head(obs_ts_daily)
which returns:
Time Series:
Start = c(2014, 274)
End = c(2014, 279)
Frequency = 365
[1] 0.4841401 0.7060281 0.5763160 0.4285645 0.4626230 0.912378
As you can see the Start and End date of the ts object is wrong. I also the decimal date:
obs_ts_daily <- ts(data, # random data
start=decimal_date(as.Date("2014-10-01")),
frequency =365 )
Which returns exactly the same thing as a day of the year case. My question is what should I do to get the right Start and End date for the ts object?
EDIT:I already saw the post [starting a daily time series in R ] and their solution. I do exactly the same, for example:
myts <- ts(rnorm(length(inds)), # random data
start = c(2014, as.numeric(format(inds[1], "%j"))),
frequency = 365)
is exactly what I've done:
data=runif(731)
obs_ts_daily <- ts(data, # random data
start=c(2014,274),
frequency =365 )
head(obs_ts_daily)
Another solution is to use Zoo package for daily data, that is not my interest as I need ts object for another package. Another answer proposes putting frequency=7, but I have daily data and I believe it should be 365 (or 365.25).