# ndiffs

From forecast v2.01
by Rob Hyndman

##### Number of differences

Uses a unit root test to determine the number of differences required for time series `x`

. If `test="kpss"`

,
the KPSS test is used with the null hypothesis that `x`

has a stationary root against a unit-root alternative. Then the test returns
the least number of differences required to pass the test at the level `alpha`

. If `test="adf"`

, the Augmented Dickey-Fuller test is used
with the null hypothesis that `x`

has a unit root against a stationary root alternative. Then the test returns the least number of differences
required to fail the test at the level `alpha`

.

- Keywords
- ts

##### Usage

`ndiffs(x, alpha=0.05, test=c("kpss","adf"))`

##### Arguments

- x
- A univariate time series
- alpha
- Level of the test
- test
- Type of unit root test to use

##### Value

- An integer.

##### Examples

`ndiffs(WWWusage)`

*Documentation reproduced from package forecast, version 2.01, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.