terasvirta.test.RdGenerically computes Teraesvirta's neural network test for neglected
nonlinearity either for the time series x or the regression
y~x.
a numeric vector, matrix, or time series.
a numeric vector.
an integer which specifies the model order in terms of lags.
a string indicating whether the Chi-Squared test or the
F-test is computed. Valid types are "Chisq" and "F".
a logical indicating whether the data should be scaled
before computing the test statistic. The default arguments to
scale are used.
further arguments to be passed from or to methods.
The null is the hypotheses of linearity in
“mean”. This test uses a Taylor series expansion of the activation
function to arrive at a suitable test statistic. If type equals
"F", then the F-statistic instead of the Chi-Squared statistic
is used in analogy to the classical linear regression.
Missing values are not allowed.
A list with class "htest" containing the following components:
the value of the test statistic.
the p-value of the test.
a character string indicating what type of test was performed.
a list containing the additional parameters used to compute the test statistic.
a character string giving the name of the data.
additional arguments used to compute the test statistic.
T. Teraesvirta, C. F. Lin, and C. W. J. Granger (1993): Power of the Neural Network Linearity Test. Journal of Time Series Analysis 14, 209-220.
n <- 1000
x <- runif(1000, -1, 1) # Non-linear in ``mean'' regression
y <- x^2 - x^3 + 0.1*rnorm(x)
terasvirta.test(x, y)
#>
#> Teraesvirta Neural Network Test
#>
#> data: x and y
#> X-squared = 2539.9, df = 2, p-value < 2.2e-16
#>
## Is the polynomial of order 2 misspecified?
terasvirta.test(cbind(x,x^2,x^3), y)
#>
#> Teraesvirta Neural Network Test
#>
#> data: cbind(x, x^2, x^3) and y
#> X-squared = 3.8829, df = 16, p-value = 0.9991
#>
## Generate time series which is nonlinear in ``mean''
x[1] <- 0.0
for(i in (2:n)) {
x[i] <- 0.4*x[i-1] + tanh(x[i-1]) + rnorm(1, sd=0.5)
}
x <- as.ts(x)
plot(x)
terasvirta.test(x)
#>
#> Teraesvirta Neural Network Test
#>
#> data: x
#> X-squared = 129.42, df = 2, p-value < 2.2e-16
#>