Home > Blockchain >  How to convert a weekly dataset into a time series in R
How to convert a weekly dataset into a time series in R

Time:10-23

i have a WEEKLY dataset that start on 1986.01.03 and end on 2022-10-07. The problem is when I forecast the time series with Arima garch, because the date in T0 is wrong, i.e. 1975 enter image description here.

The function that I used to convert the dataset into time series is here, but I think that the problem is here, since it doesn't take on the right date.

FutureWeekly= ts(WeeklyFuture$FutureWeekly, start= c(1986,1), end = c(2022,10), frequency = 52)

does anyone know how to convert a weekly dataset to time series other than this?

There are the first rows of my dataset and then I have to transform that into returns (diff(log(FutureWeekly) to do the ARMA GARCH

enter image description here

CodePudding user response:

Try this:

futures<-c(WeeklyFuture$FutureWeekly) #convert to vector
FutureWeekly= ts(futures, start= c(1986,1,10), end = c(1986,3,7), frequency = 52) #add day of week ending on

One of the things ts() demands is a vector of values. I think it might also be easier for ts() to convert the data if it was able to see the 7-day increments.

Assuming you have full un-broken weekly data for the entire period, I think these two things will solve the problem.

  •  Tags:  
  • r
  • Related