Home > Back-end >  Specifying start date of timeseries data in R as Q2
Specifying start date of timeseries data in R as Q2

Time:11-23

I have time series data that is seasonal by the quarter. However, the data starts in the 2nd quarter of the first year but all other years have all four quarters.

> EquifaxData
         DATE EQFXSUBPRIME013045
1  2014-04-01           42.58513
2  2014-07-01           43.15483
3  2014-10-01           43.55090
4  2015-01-01           42.59218
5  2015-04-01           41.47105
6  2015-07-01           41.53640
7  2015-10-01           41.82020
8  2016-01-01           40.98760
9  2016-04-01           40.51305
10 2016-07-01           39.91170
11 2016-10-01           40.15402

I then converted the Date column to a date as follows:

> EquifaxData$DATE <- as.Date(EquifaxData$DATE)

Now comes the issue. I want to convert this data to a time series. But I need to specify my start date as the beginning of Q2 in 2014. Not the beginning of 2014. As you can see below from what I have tried, the resulting time series shown by head has all the values shifted one quarter back because it is starting from the beginning of 2014.

> EquifaxTs <- ts(EquifaxData$EQFXSUBPRIME013045, start=2014, frequency = 4)
> head(EquifaxTs)
         Qtr1     Qtr2     Qtr3     Qtr4
2014 42.58513 43.15483 43.55090 42.59218
2015 41.47105 41.53640                  
> 

How can I define EquifaxTs to correctly start in Q2 2014 and still remain seasonal with a frequency of 4 per year?

CodePudding user response:

I think that's it solves:

EquifaxTs <- ts(EquifaxData$EQFXSUBPRIME013045, start = c(2014, 2), frequency = 4)
  • Related