|
|
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:
Optionally it is possible to use:
The quantlet returns a table displaying all information about the test
results. The example of this quantlet (
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.
|
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:
Optional parameters:
The quantlet returns a table displaying all information about the test
results. The example of this quantlet
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,] " "
|
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:
Optionally it is possible to use:
The quantlet returns a table displaying all information about the test
results. The example of this quantlet
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,] " "