auto_dif: Test and treat non-stationary data

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/auto_dif.R

Description

This function tests for unit roots and applies first differences to treat non-stationary data.

Usage

1
auto_dif(data, type = c("kpss", "adf", "pp"), alpha = 0.05, exclude = NULL)

Arguments

data

A tbl with variables in columns.

type

Vector with tests to perform. Available: list("kpss", "pp, "adf")

alpha

Significance level for the tests.

exclude

Variables to exclude from evaluation.

Details

Tests available are c("kpss", "adf", "pp").

Value

An object of class list with a tibble (series_dif) containing the non-stationary data in first differences; and a tibble (series_ndiffs) containing the results from the unit roots test performed.

Note

Only first differences are taken, even if series are integrated of order > 1. So it is advisable to look at "series_ndiffs" to assess the results from the unit root tests and, if necessary, run the function again until all the series are I(0).

Author(s)

J. Renato Leripio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(tidyverse)
library(tstools)
mu <- list(-2, 0, 2, 4, 6)
sigma <- list(1, 2, 3, 4, 5)
series <- purrr::map2_dfc(mu, sigma, rnorm, n = 100)
series <- dplyr::mutate_at(series, vars(V1,V3), funs(cumsum))
series_dif <- auto_dif(series, type = c("kpss", "pp"))

## End(Not run)

leripio/tstools documentation built on Aug. 1, 2019, 12:52 p.m.