Learn R Programming

AutovarCore

AutovarCore finds the best fitting VAR models for a given time series data set that pass the selected set of residual assumptions. AutovarCore will also generate Granger causality networks given a data frame (this functionality is not yet implemented). AutovarCore is a simplified/efficient version of Autovar.

To install, type the following:

install.packages('devtools')
devtools::install_github('roqua/autovarCore')

For more information on Autovar, see autovar.nl. Help documentation for AutovarCore can be found on autovarcore.nl.

Should I use Autovar or AutovarCore?

You should use Autovar if you

  • Prefer a slightly better model fit over a model with less outlier dummies (less outlier dummies means that the model explains more of the measurements).
  • Are okay with Autovar sometimes returning NULL because it could not find any models that passed all residual tests.
  • Need VAR models with more than one lag or with zero lags.
  • Need models with automatically determined restrictions.
  • Need debugging information such as a full list of all evaluated models.
  • Want detailed summary information such as a plot of contemporaneous correlations or Granger causalities.
  • Need named dummy variables for interpretation (e.g., "morning", "afternoon", "Monday", "Tuesday" instead of "day_part_1", "day_part_1", "day_3", "day_4")

You should use AutovarCore if you

  • Prefer a model with less outlier dummies over a model with a slightly better model fit (less outlier dummies means that the model explains more of the measurements).
  • Always want a list of best models even if those do not pass all residual tests at the default p-level (this is indicated by the 'bucket' property, see ?autovar for details).
  • Are not interested in any models except for models with lag 1 and models with lag 2 where the second lag is autoregressive only.
  • May have missing data (i.e., NA values). Autovar also has a function "impute_dataframe" to impute values, but AutovarCore does this automatically (if needed).
  • Need more flexibility as to which residual tests should constitute model validity (e.g., portmanteau, portmanteau_squared, skewness, kurtosis, joint_sktest). Autovar uses a fixed set of residual tests.
  • Deem performance to be an issue and prefer memory-efficient and fast code.

Example use

library('autovarCore')

# AutovarCore requires input data in data.frame format.
# If you have data in a .csv, .dta, or .sav file, use
# the 'foreign' library to load this data into R first.
# (You may need to type:
#    install.packages('foreign')
#  if you do not have the foreign library installed on
#  your system.)
library('foreign')

# This example data set can be downloaded from
# https://autovar.nl/datasets/aug_pp5_da.sav
suppressWarnings(dfile <- read.spss('~/Downloads/aug_pp5_da.sav'))
dframe <- data.frame(Activity = dfile$Activity, Depression = dfile$Depression)

# Call autovar with the given data frame. Type:
#   ?autovar
# (after having typed "library('autovarCore')") to see 
# which other options are available.
models_found <- autovar(dframe, selected_column_names = c('Activity', 'Depression'))

# Show details for the best model found
print(models_found[[1]])

Copy Link

Version

Install

install.packages('autovarCore')

Monthly Downloads

41

Version

1.0-4

License

MIT + file LICENSE

Maintainer

Last Published

June 4th, 2018

Functions in autovarCore (1.0-4)

day_dummies

Calculate weekday dummy variables
selected_columns

Convert an outlier_mask to a vector of column indices
significance_from_pearson_coef

Calculate the significance of a Pearson correlation coefficient
invalid_mask

Calculate a bit mask to identify invalid outlier dummies
print_correlation_matrix

Print the correlation matrix of the residuals of a model annotated with p-values
validate_raw_dataframe

Validates the dataframe given to the autovar function
portmanteau_test_statistics

An implementation of the portmanteau test.
residual_outliers

Calculate dummy variables to mask residual outliers
validate_params

Validates the params given to the autovar function
run_tests

Execute a series of model validity assumptions
select_valid_masks

Select and return valid dummy outlier masks
run_var

Calculate the VAR model and apply restrictions
sktest_joint_p

SK test p-level
trend_columns

Construct linear and quadratic trend columns
assess_portmanteau_squared

Tests the homeskedasticity assumption for a VAR model using a portmanteau test on the squared residuals
apply_ln_transformation

Applies the natural logarithm to the data set
coefficients_of_skewness

Skewness coefficients.
assess_kurtosis

Tests the kurtosis of a VAR model
autovarCore-package

autovarCore
coefficients_of_kurtosis

Kurtosis coefficients.
assess_joint_sktest

Tests the skewness and kurtosis of a VAR model
assess_skewness

Tests the skewness of a VAR model
assess_portmanteau

Tests the white noise assumption for a VAR model using a portmanteau test on the residuals
model_is_stable

Eigenvalue stability condition checking
model_score

Return the model fit for the given varest model
impute_datamatrix

Imputes the missing values in the input data
outliers_column

Determine the outliers column for the given column data
compete

Returns the winning model
autovar

Return the best VAR models found for a time series data set
needs_trend

Determines if a trend is required for the specified VAR model
daypart_dummies

Calculate day-part dummy variables
explode_dummies

Explode dummies columns into separate dummy variables