[fbf06f]: / partyMod / tests / TestStatistic-regtest.R

Download this file

34 lines (27 with data), 996 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
set.seed(290875)
library("party")
### get rid of the NAMESPACE
attach(asNamespace("party"))
###
###
### Regression tests for test statistics
###
### functions defined in file `./src/TestStatistic.c'
### tests for function C_maxabsTeststatistic
xf <- gl(3, 10)
yf <- gl(3, 10)[sample(1:30)]
x <- sapply(levels(xf), function(l) as.numeric(xf == l))
colnames(x) <- NULL
y <- sapply(levels(yf), function(l) as.numeric(yf == l))
colnames(y) <- NULL
weights <- sample(1:30)
linstat <- LinearStatistic(x, y, weights)
expcov <- ExpectCovarLinearStatistic(x, y, weights)
maxabs <- max(abs(linstat - expcov@expectation) / sqrt(diag(expcov@covariance)))
stopifnot(isequal(maxabs,
maxabsTestStatistic(linstat, expcov@expectation, expcov@covariance, 1e-10)))
expcov@covariance[1,1] <- 1e-12
stopifnot(isequal(maxabs,
maxabsTestStatistic(linstat, expcov@expectation, expcov@covariance, 1e-10)))
### tests for function C_quadformTeststatistic
### -> see LinearStatistic-regtest.R