Hello and thanks in advance. I'm trying to run a unit root test on a subset of series X
after it has been differenced, X_diff
X_diff <- diff(X, differences = 1)
urdfTest( subset(X_diff, dat[["Year"]] > 2001 ), lags = 4, type = c("c"), doplot = TRUE)
I get the following error: 'Error in na.fail.default(as.ts(x)) : missing values in object'
Now I noticed that if I view the entire X_diff
variable, I get no NA
values. However, if I view the subset of X_diff
variable (code below) I get an NA
value all the way at the end, and this is true for any year I place into the condition.
TBG_diff[which(dat[["Year"]] > 2001)]
Why does the NA
appear and how can I run the subset of the differenced series without getting the NA
error?