This function uses the Phillips-Perron Unit Root Test to determine whether a trend is required for a VAR model based on the given matrix of endogenous variables and the given lag. All variables are assessed individually. This function returns TRUE
if any of the endogenous variables requires a trend.
needs_trend(endo_matrix, lag)
The matrix of endogenous variables in the model.
An integer specifying the lag length of the model.
A boolean indicating whether a trend is required for the specified VAR model.
# NOT RUN { data_matrix <- matrix(nrow = 40, ncol = 3) data_matrix[, ] <- runif(ncol(data_matrix) * nrow(data_matrix), 1, 10) data_matrix[, 3] <- (1:40) + rnorm(40) colnames(data_matrix) <- c('rumination', 'happiness', 'activity') data_matrix autovarCore:::needs_trend(data_matrix, 1) # }
Run the code above in your browser using DataCamp Workspace