File: tests.R

package info (click to toggle)
r-cran-teachingdemos 2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,168 kB
  • sloc: makefile: 2
file content (61 lines) | stat: -rw-r--r-- 1,867 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
SnowsPenultimateNormalityTest <- function(x){


        # the following function works for current implementations of R
        # to my knowledge, eventually it may need to be expanded
        is.rational <- function(x){
                rep( TRUE, length(x) )
        }


        tmp.p <- if( any(is.rational(x))) {
                0
        } else {
                # current implementation will not get here if length
                # of x is positive.  This part is reserved for the
                # ultimate test
                1
        }


        out <- list(
                p.value = tmp.p,
                alternative = strwrap(paste('The data does not come from a',
        'strict normal distribution (but may represent a distribution',
        'that is close enough)'), prefix="\n\t"),
                method = "Snow's Penultimate Normality Test",
                data.name = deparse(substitute(x))
        )


        class(out) <- 'htest'
        out
}

SnowsCorrectlySizedButOtherwiseUselessTestOfAnything <- function(x,
            data.name=deparse(substitute(x)), alternative='You Are Lucky',
                                                                 ...,
                                                                 seed) {
    if( !missing(seed) ) {
        if( is.numeric(seed) ) {
            set.seed(seed)
        } else {
            char2seed(seed)
        }
    }

    tmp.p <- runif(1)

    out <- list(
                p.value = tmp.p,
                data.name=data.name,
                method = "Snow's Correctly Sized But Otherwise Useless Test of Anything",
                alternative=alternative)
    if( !missing(seed) ) out$seed <- seed
    names(tmp.p) <- 'Random Uniform Value'
    out$statistic <- tmp.p

    class(out) <- 'htest'
    return(out)
}