How to perform an Augmented Dickey-Fuller Test in R?

To perform an Augmented Dickey-Fuller Test in R, one must first install and load the library called “urca”. After that, one can run the function “ur.df()” on the data set that they wish to test. The function takes in arguments such as the data and the order of integration, which can be specified by the user. After running the function, one can analyze the results to determine if the data set is stationary or not.


A time series is said to be “stationary” if it has no trend, exhibits constant variance over time, and has a constant autocorrelation structure over time.

One way to test whether a time series is stationary is to perform an augmented Dickey-Fuller test, which uses the following null and alternative hypotheses:

H0: The time series is non-stationary. In other words, it has some time-dependent structure and does not have constant variance over time.

HA: The time series is stationary.

If the from the test is less than some significance level (e.g. α = .05), then we can reject the null hypothesis and conclude that the time series is stationary.

The following step-by-step example shows how to perform an augmented Dickey-Fuller test in R for a given time series.

Example: Augmented Dickey-Fuller Test in R

Suppose we have the following time series data in R:

data <- c(3, 4, 4, 5, 6, 7, 6, 6, 7, 8, 9, 12, 10)

Before we perform an augmented Dickey-Fuller test on the data, we can create a quick plot to visualize the data:

plot(data, type='l')

To perform an augmented Dickey-Fuller test, we can use the function from the tseries library. 

The following code shows how to use this function:

library(tseries)

#perform augmented Dickey-Fuller test 
adf.test(data)

	Augmented Dickey-Fuller Test

data:  data
Dickey-Fuller = -2.2048, Lag order = 2, p-value = 0.4943
alternative hypothesis: stationary

Here’s how to interpret the most important values in the output:

  • Test statistic: -2.2048
  • P-value: 0.4943

This means the time series is non-stationary. In other words, it has some time-dependent structure and does not have constant variance over time.

The following tutorials explain how to perform other common tasks in R:

x