computePValue: P-value

Description Usage Arguments Details Examples

View source: R/computePValue.R

Description

Function to approximate the p-value for augmented Dickey-Fuller test.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
computePValue(object, ...)

## S3 method for class 'numeric'
computePValue(object, n, type = c("nc", "c", "ct"),
  model = c("gam", "poly"), d = NULL, ...)

## S3 method for class 'fHTEST'
computePValue(object, model = c("gam", "poly"),
  type = c("nc", "c", "ct"), d = NULL, ...)

## S3 method for class 'ur.df'
computePValue(object, model = c("gam", "poly"),
  d = NULL, ...)

## S3 method for class 'htest'
computePValue(object, model = c("gam", "poly"),
  d = NULL, ...)

Arguments

object

Numeric value or an object (fHTEST, ur.df or htest) for which p-value needs to approximated.

...

Further arguments passed to methods.

n

Sample size.

type

The type of unit root test. Currently supports: nc for test without drift and trend, c for test with only drift and ct for test with both drift and trend.

model

The model type to be used for approximation. Available is GAM and polynomial regression. If gam is chosen, then d has no effect.

d

The degree for polynomial. d must be ≥ 3 and ≤ 6. If gam is chosen, then d has no effect.

Details

Based on the chosen model (GAM or polynomial), the function returns the approximated p-value. Default is GAM model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(pvurt)
y <- arima.sim(model = list(order = c(0, 1, 0)), n = 100)

# Test type: with drift and trend
# package: fUnitRoots
library(fUnitRoots)
computePValue(adfTest(y, lags = 3, type = "ct"))
computePValue(unitrootTest(y, lags = 3, type = "ct"))

# package: urca
library(urca)
computePValue(ur.df(y, lags = 3, type = "trend"))
# print summary
summary(computePValue(ur.df(y, lags = 3, type = "trend")))

# package: tseries
library(tseries)
computePValue(adf.test(y, alternative = "stationary", k = 3))

# no packages
tStat <- -2.239
sampleSize <- 100
computePValue(tStat, n = sampleSize, model = "gam", type = "ct")

mlincon/pvurt documentation built on June 8, 2021, 4:14 p.m.