7.6 Noninteractive Quantlets for Testing
- erg =
wavetest(t, y, p{, dis, levels, data, adjust})
- component analysis in additive (partially linear) models
- erg =
intertest1(t, y, h, g{, opt, file})
- test for interaction
- erg =
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 =
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
The quantlet
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
distance. You
can test whether the considered additive component is significantly
different from a predetermined polynomial.
Input parameters:
- x
matrix, the observed explanatory variable, where the
dis (see list of optional parameters) last columns are expected to be dummy
variables
- y
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
-
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
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 (
gam11.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
intertest1
- erg =
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
The quantlet
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
, 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
matrix, the observed explanatory variable where the
directions of interest have to be the first and the second column.
- y
vector, the response variable.
- h
bandwidth vector for the directions of
interest.
- g
bandwidth vector for the directions not of
interest.
Optional parameters:
- opt
- list:
- opt.hyp
-
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
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
gam12.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
intertest2
- erg =
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
The quantlet
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
, 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
matrix, the observed explanatory variable where the
directions of interest have to be the first and the second column.
- y
- A
vector, the response variable.
- h
- A
bandwidth vector for the directions of
interest.
- g
- A
bandwidth vector for the directions not of
interest.
Optionally it is possible to use:
- opt
- list:
- opt.hyp
-
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
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
gam13.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,] " "