[go: up one dir, main page]

File: assets-testing.R

package info (click to toggle)
fassets 3011.83-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 428 kB
  • sloc: makefile: 1
file content (121 lines) | stat: -rw-r--r-- 3,212 bytes parent folder | download | duplicates (4)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General
# Public License along with this library; if not, write to the
# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA


################################################################################
# FUNCTION:                   DESCRIPTION:
#  assetsTest                  Tests for multivariate Normal Assets
# FUNCTION:                   DESCRIPTION:
#  mvshapiroTest               Multivariate Shapiro Test
#  mvenergyTest                Multivariate E-Statistic (Energy) Test
################################################################################


assetsTest <-
    function(x, method = c("shapiro", "energy"), Replicates = 99)
{
    # Description:
    #   Tests for multivariate Normal Assets

    # Example:
    #   mvnormTest(x = assetsSim(100))
    #   mvnormTest(x = assetsSim(100), method = "e", Replicates = 99)

    # FUNCTION:

    # Test:
    method <- match.arg(method)
    if (method == "shapiro") {
        test <- mvshapiroTest(x)
    }
    if (method == "energy") {
        test <- mvenergyTest(x, Replicates = Replicates)
    }

    # Return Value:
    test
}


# ------------------------------------------------------------------------------


mvshapiroTest <-
    function(x)
{
    # Description:
    #   Computes Shapiro's normality test for multivariate variables
    
    # Requires: 
    #   Package: mvnormtest
    #   Version: 0.1-6
    #   Date: 2005-04-02
    #   Title: Normality test for multivariate variables
    #   Author: Slawomir Jarek
    #   Maintainer: Slawomir Jarek <slawomir.jarek@gallus.edu.pl>
    #   Description: Generalization of shapiro-wilk test for
    #       multivariate variables.
    #   License: GPL
              
    # Example:
    #   mvshapiroTest(x = assetsSim(100))

    # FUNCTION:

    # Transform:
    U <- t(as.matrix(x))
    
    # Test
    test <- mvnormtest::mshapiro.test(U)
    
    # Return Value:
    test
}


# ------------------------------------------------------------------------------


mvenergyTest <- 
    function(x, Replicates = 99)
{
    # Description:
    #   Computes E-statistics test for multivariate variables

    # Requires:
    #   Package: energy
    #   Author: Maria L. Rizzo <mrizzo @ bgnet.bgsu.edu> and
    #       Gabor J. Szekely <gabors @ bgnet.bgsu.edu>
    #   License: GPL 2.0 or later

    # Example:
    #   mvenergyTest(x = assetsSim(100), 99)

    # FUNCTION:

    # Transform:
    x <- as.matrix(x)
    
    # Test:
    test <- energy::mvnorm.etest(x, R = Replicates)
    
    # Return Value:
    test
}


################################################################################