autovarCore (version 1.0-4)

residual_outliers: Calculate dummy variables to mask residual outliers


This function returns a matrix with columns that have a 1 at indices where the residuals have an outlier, and a 0 everywhere else. Outliers are calculated per variable (column) separately. We consider residual outliers the rows in the column of residuals or in the column of squared residuals that are more than 2.5 times the standard deviation away from the mean (standard deviation and mean are calculated separately per column and for residuals/squared residuals). The dummy columns are prepended with zeros to match the size of the other input variables to the model.


residual_outliers(resid_matrix, number_of_rows)



A matrix of residuals. Column names are copied over to the returned result.


The number of measurements that were input to the model. Since the length of the residual matrix is shorter depending on the amount of lags in the model, we use number_of_rows to specify the number of rows in the returned matrix.


A matrix with dummy variables in columns following the procedure described above.


Run this code
resid_matrix <- matrix(rnorm(39 * 3),
                       nrow = 39,
                       ncol = 3,
                       dimnames = list(NULL, c('rumination', 'happiness', 'activity')))
resid_matrix[13, 2] <- 48
resid_matrix[23, 2] <- -62
resid_matrix[36, 2] <- 33
resid_matrix[27, 3] <- 75
autovarCore:::residual_outliers(resid_matrix, 40)
# }

Run the code above in your browser using DataCamp Workspace