7.6 Noninteractive Quantlets for Testing


erg = 15334 wavetest (t, y, p{, dis, levels, data, adjust})
component analysis in additive (partially linear) models
erg = 15337 intertest1 (t, y, h, g{, opt, file})
test for interaction
erg = 15340 intertest2 (t, y, h, g{, opt, file})
test for interaction
With the following test procedures it is possible to do either component analysis in additive models, e.g. test for linearity or you can test for interaction and thus for additivity of a model.


7.6.1 Component Analysis in Additive (Partially Linear) Models


erg = 15392 wavetest (t, y, p{, dis, levels, data, adjust})
component analysis in additive (partially linear) models

  library("gam")
  n   = 100
  randomize(1234)
  x   = normal(n,3)
  eps = normal(n,1) * sqrt(0.8)
  y   = sin(2*x[,1]) + x[,2]^2 + 2*x[,3] +eps
  p   = 1
  erg = wavetest(x,y,p)
  erg
15396 XAGgam11.xpl

The quantlet 15401 wavetest provides a test procedure for component analysis in additive separable models. It is based on wavelets using the Haar basis. It consists of two separated tests, the local one is e.g. looking for jumps, the chi-square like one for the $ L_2$ distance. You can test whether the considered additive component is significantly different from a predetermined polynomial.

Input parameters:

x
$ n \times p$ matrix, the observed explanatory variable, where the dis (see list of optional parameters) last columns are expected to be dummy variables
y
$ n \times 1 $ vector, the observed response variable
p
scalar, the degree of the polynomial of the hypothesis

Optionally it is possible to use:

dis
scalar, the number of dummy variables, if you have some included in x
levels
$ (p-dis)\times 1$ vector, the wavelet levels for the components (default: maximal possible)
data
string, the name of the file in which the estimates shall be saved
adjust
$ 2\times 1$ vector, multiplicators to justify the first error probability, see help file

The quantlet returns a table displaying all information about the test results. The example of this quantlet ( 15404 XAGgam11.xpl ) produces the following output:

Contents of erg

[ 1,] " "
[ 2,] "-------------------------------------------------------"
[ 3,] "no output of function estimates"
[ 4,] "-------------------------------------------------------"
[ 5,] "HYPOTHESIS: 1.add.component is polynomial of degree  1"
[ 6,] "-------------------------------------------------------"
[ 7,] "Hypothesis has been rejected at level  0"
[ 8,] "-------------------------------------------------------"
[ 9,] "highest possible level is  3"
[10,] " "
[11,] "-------------------------------------------------------"
[12,] "-------------------------------------------------------"
[13,] "            local Test              chi-2 like Test "
[14,] "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
[15,] "level  crit.value  test stat.    crit.value  test stat. "
[16,] "-------------------------------------------------------"
[17,] "  0      2.74767      4.34697      3.24940     12.65449"
[18,] "-------------------------------------------------------"
[19,] "-------------------------------------------------------"
[20,] " "

Here, the hypothesis of linearity has been rejected.


7.6.2 Testing for Interaction by 15407 intertest1


erg = 15497 intertest1 (t, y, h, g{, opt, file})
test for interaction

  library("gam")
  randomize(12345)
  n     = 50
  t     = uniform(n,3)*2-1
  g1    = 2*t[,1]
  g2    = t[,2]^2 - mean(t[,2]^2)
  g3    = sin(3*t[,3])
  g12   = t[,1].*t[,2]
  y     = g1+g2+g3+g12+normal(n)*sqrt(0.5)
  h     = #(0.9,0.9,0.7)
  g     = #(1.0,1.0,0.9)
  boot  = 99
  hb    = 1.1
  weight= matrix(n)-prod((abs(t[,1:2]).>0.85),2)
  opt   = list(boot,hb,weight)
  test  = intertest1(t,y,h,g,opt)
  test
15501 XAGgam12.xpl

The quantlet 15506 intertest1 provides a test procedure to test the hypothesis that a predetermined interaction function is zero, i.e. the interaction is not existing. The assumed underlying model is $ m = c
+f_1+\ldots +f_d+f_{12}+\ldots+f_{(d-1)d}$, see also 7.1.2 Marginal Integration. First, this procedure is estimating the interaction by the marginal integration estimator. Then the difference of this estimate to the hypothesis is calculated. Since the procedure is based on bootstrap, the hypothesis model has to be determined by the user, in practice he has to decide which of the possible interaction terms have to be included.

Input parameters:

t
$ n \times p$ matrix, the observed explanatory variable where the directions of interest have to be the first and the second column.
y
$ n \times 1 $ vector, the response variable.
h
$ p \times 1$ bandwidth vector for the directions of interest.
g
$ p \times 1$ bandwidth vector for the directions not of interest.

Optional parameters:

opt
list:
opt.hyp
$ pp \times 2$ vector, all pairs of indices of which the interaction shall be included
opt.boot
number of bootstrap replications (default: boot=249)
opt.hb
scalar, the bandwidth multiplicator for the bootstrap. When the test statistics are calculated we take h*hb and g*hb instead of h and g (default hb=1).
opt.weight
$ n \times 1 $ vector, the weights for the test statistic (default: equal to 1 for all components)
file
string, the name of the file to which the estimates will be saved if wished

The quantlet returns a table displaying all information about the test results. The example of this quantlet 15509 XAGgam12.xpl (probably with a different seed for the function randomize) produces table with the following text:

Contents of test

[ 1,] " "
[ 2,] "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
[ 3,] "no output of function estimates"
[ 4,] " "
[ 5,] "HYPOTHESIS: There is no interaction of x_1,x_2"
[ 6,] " "
[ 7,] "  looking at the interaction function estimate  "
[ 8,] "  Number of bootstrap replications:   99"
[ 9,] " "
[10,] "Hypothesis has not been rejected"
[11,] " "
[12,] "-------------------------------------------------------"
[13,] "-------------------------------------------------------"
[14,] " niveau  rejected    crit.value      test stat.  "
[15,] "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
[16,] "    1         0         7.77893        0.96358"
[17,] "    5         0         6.00822        0.96358"
[18,] "   10         0         5.18759        0.96358"
[19,] "   15         0         4.37140        0.96358"
[20,] "   20         0         3.73898        0.96358"
[21,] "-------------------------------------------------------"
[22,] "-------------------------------------------------------"
[23,] " "


7.6.3 Testing for Interaction by 15512 intertest2


erg = 15604 intertest2 (t, y, h, g{, opt, file})
test for interaction

  library("gam")
  randomize(12345)
  n     = 50
  t     = uniform(n,3)*2-1
  g1    = 2*t[,1]
  g2    = t[,2]^2 - mean(t[,2]^2)
  g3    = sin(3*t[,3])
  g12   = t[,1].*t[,2]
  y     = g1+g2+g3+g12+normal(n)*sqrt(0.5)
  h     = #(1.1,1.0,0.9)
  g     = #(1.2,1.2,1.1)
  boot  = 99
  hb    = 1.5
  weight= matrix(n)-prod((abs(t[,1:2]).>0.85),2)
  opt   = list(boot,hb,weight)
  test  = intertest2(t,y,h,g,opt)
  test
15608 XAGgam13.xpl

The quantlet 15613 intertest2 provides a test procedure to test the hypothesis that a predetermined interaction function is zero, i.e. the interaction is not existing. The assumed underlying model is $ m = c
+f_1+\ldots +f_d+f_{12}+\ldots+f_{(d-1)d}$, see also Subsection 7.1.2. First, this procedure is estimating the mixed derivative of the interaction by the marginal integration estimator. Then the difference of this estimate to the hypothesis is calculated. Since the procedure is based on bootstrap, the hypothesis model has to be determined by the user, in practice he has to decide which of the possible interaction terms have to be included. For the bootstrap the user also can choose whether the model shall be estimated with a local linear or a local quadratic estimator.

Input parameters:

t
A $ n \times p$ matrix, the observed explanatory variable where the directions of interest have to be the first and the second column.
y
A $ n \times 1 $ vector, the response variable.
h
A $ p \times 1$ bandwidth vector for the directions of interest.
g
A $ p \times 1$ bandwidth vector for the directions not of interest.

Optionally it is possible to use:

opt
list:
opt.hyp
$ pp \times 2$ vector, all pairs of indices of which the interaction shall be included
opt.boot
number of bootstrap replications (default: boot=249)
opt.hb
scalar, the bandwidth multiplicator for the bootstrap. When the test statistics are calculated we take h*hb and g*hb instead of h and g (default hb=1).
opt.weight
$ n \times 1 $ vector, the weights for the test statistic, (default: equal to 1 for all components)
opt.loc
scalar, the degree of the local polynomial smoother (1=local linear, 2=local quadratic)
file
string, the name of the file to which the estimates will be saved if wished

The quantlet returns a table displaying all information about the test results. The example of this quantlet 15616 XAGgam13.xpl (probably with a different seed for the function randomize) produces the following output:

Contents of test

[ 1,] " "
[ 2,] "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
[ 3,] "no output of function estimates"
[ 4,] " "
[ 5,] "HYPOTHESIS: There is no interaction of x_1,x_2"
[ 6,] " "
[ 7,] "  testing for the mixed derivative  "
[ 8,] "  Number of bootstrap replications:   99"
[ 9,] " "
[10,] "Hypothesis has not been rejected"
[11,] " "
[12,] "-------------------------------------------------------"
[13,] "-------------------------------------------------------"
[14,] " niveau  rejected    crit.value      test stat.  "
[15,] "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
[16,] "    1         0        48.26525        6.55640"
[17,] "    5         0        33.84235        6.55640"
[18,] "   10         0        32.34334        6.55640"
[19,] "   15         0        25.73994        6.55640"
[20,] "   20         0        20.97699        6.55640"
[21,] "-------------------------------------------------------"
[22,] "-------------------------------------------------------"
[23,] " "