To conduct an Augmented Dickey-Fuller (ADF) test on a monthly time series dataset in R, you can use the adf.test()
function from the tseries
package. The appropriate specification for the ADF test type depends on the characteristics of your dataset.
The most common types for ADF test in R are:
Type = "c": This is known as the "constant" ADF test type. It assumes a constant trend in the data, meaning that the series is non-stationary with a constant term.
Type = "ct": This is known as the "constant and trend" ADF test type. It assumes a constant trend in the data, meaning that the series is non-stationary with both a constant term and a time trend.
Here's an example of how to perform an ADF test using the adf.test()
function in R with the "ct" type:
474 chars10 lines
Make sure to adjust the 'alternative' parameter based on your hypothesis. If you are testing for stationarity, you can set it to "stationary". The 'k' parameter determines the number of lags to include in the test and can be adjusted as needed.
gistlibby LogSnag