Does R's Time-Series automatically generate missing data?

175 Views Asked by At

I was wondering if anyone with knowledge on R's time-series from the stats package could help me out.

I'm currently generating a Time-Series using stat's ts function.

I'm passing the ts function a data set (with 3 years worth of dates and numeric values for each day), the start and end date that have been parsed as a decimal date, and the frequency of 365. However, there are certain ranges of dates missing (for example, dates and values from April 30th, 2016 to January 2nd, 2017 are missing).

However, when I view or plot the time series, I noticed that the missing data is automatically filled with values.

I'm not sure how these values have been generated.

Does the time series function automatically fill in missing dates with their data?

Thanks for any help,
Jay

Edit: Example of part of my original data frame:
(you can see that there are missing data from 2016-04-30 to 2017-01-02)

 Dataframe:
             date          pieceVolume
 ...   |      ...       |     ...  
 615   |   2016-04-29   |    250.5  
 616   |   2016-04-30   |    1230.4  
 617   |   2017-01-02   |    273.2  
 618   |   2017-01-01   |    26150.5  
 619   |   2017-01-02   |    232550.7  

My original data frame has 655 rows, but my time series has a length of 1079.
This is how I'm generating my timeseries from the data frame:

sts <- ts(test_data$pieceVolume, start=decimal_date(min(as.Date(test_data$date))), end=decimal_date(max(as.Date(test_data$date))), frequency=365)

My Original Code:

original_data <- readRDS("original_data.rds")
library(plyr)
## Using ddply to average all the pieceVolumes that have the same dates.
test_data <- plyr::ddply(original_data, .(date), function(x) c(pieceVolume=mean(x$pieceVolume)))
library("forecast")
## Generate time-series using test_data
sts <- ts(test_data$pieceVolume, start=decimal_date(min(as.Date(test_data$date))), end=decimal_date(max(as.Date(test_data$date))), frequency=365)
1

There are 1 best solutions below

2
On

Try

sts<- ts(test_data$pieceVolume)