-
Notifications
You must be signed in to change notification settings - Fork 2
/
classes.R
executable file
·104 lines (79 loc) · 4.37 KB
/
classes.R
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
setClass("mardia",
slots = c(g1p = "numeric", chi.skew="numeric", p.value.skew="numeric", chi.small.skew="numeric",
p.value.small="numeric", g2p="numeric", z.kurtosis="numeric", p.value.kurt="numeric", dname="character", dataframe="data.frame"))
setGeneric("mardia", function(object) standardGeneric("mardia"))
setMethod("show",
signature = "mardia",
definition = function(object) {
n=dim(object@dataframe)[1]
cat(" Mardia's Multivariate Normality Test", "\n", sep = " ")
cat("---------------------------------------", "\n", sep = " ")
cat(" data :", object@dname, "\n\n", sep = " ")
cat(" g1p :", object@g1p, "\n", sep = " ")
cat(" chi.skew :", object@chi.skew, "\n", sep = " ")
cat(" p.value.skew :", object@p.value.skew, "\n\n", sep = " ")
cat(" g2p :", object@g2p, "\n", sep = " ")
cat(" z.kurtosis :", object@z.kurtosis, "\n", sep = " ")
cat(" p.value.kurt :", object@p.value.kurt, "\n\n", sep = " ")
cat(" chi.small.skew :", object@chi.small.skew, "\n", sep = " ")
cat(" p.value.small :", object@p.value.small, "\n\n", sep = " ")
if(n>=20){
cat(if((object@p.value.skew > 0.05) & (object@p.value.kurt > 0.05)){" Result : Data is multivariate normal."}
else {" Result : Data is not multivariate normal."},"\n\n")
}
if(n<20){
cat(if((object@p.value.small > 0.05) & (object@p.value.kurt > 0.05)){" Result : Data is multivariate normal."}
else {" Result : Data is not multivariate normal."},"\n\n")
}
cat("NOTE: For multivariate normality, both p-values of skewness and kurtosis statistics should be greater than 0.05. If sample size (n) is less than 20 then 'p.value.small' should be used as significance value of skewness instead of 'p.value.skew'.", "\n", sep = " ")
cat("---------------------------------------", "\n\n", sep = " ")
invisible(NULL)
})
setClass("hz",
slots = c(HZ = "numeric", p.value="numeric", dname="character", dataframe="data.frame"))
setGeneric("hz", function(object) standardGeneric("hz"))
setMethod("show",
signature = "hz",
definition = function(object) {
cat(" Henze-Zirkler's Multivariate Normality Test", "\n", sep = " ")
cat("---------------------------------------------", "\n", sep = " ")
cat(" data :", object@dname, "\n\n", sep = " ")
cat(" HZ :", object@HZ, "\n", sep = " ")
cat(" p-value :", object@p.value, "\n\n", sep = " ")
cat(if(object@p.value > 0.05){" Result : Data is multivariate normal."}
else {" Result : Data is not multivariate normal."},"\n")
cat("---------------------------------------------", "\n\n", sep = " ")
invisible(NULL)
})
setClass("royston",
slots = c(H = "numeric", p.value="numeric", dname="character", dataframe="data.frame"))
setGeneric("royston", function(object) standardGeneric("royston"))
setMethod("show",
signature = "royston",
definition = function(object) {
cat(" Royston's Multivariate Normality Test", "\n", sep = " ")
cat("---------------------------------------------", "\n", sep = " ")
cat(" data :", object@dname, "\n\n", sep = " ")
cat(" H :", object@H, "\n", sep = " ")
cat(" p-value :", object@p.value, "\n\n", sep = " ")
cat(if(object@p.value > 0.05){" Result : Data is multivariate normal."}
else {" Result : Data is not multivariate normal."},"\n")
cat("---------------------------------------------", "\n\n", sep = " ")
invisible(NULL)
})
setClass("dh",
slots = c(TS = "numeric", p.value="numeric", dname="character", dataframe="data.frame"))
setGeneric("dh", function(object) standardGeneric("dh"))
setMethod("show",
signature = "dh",
definition = function(object) {
cat(" Doornick-Hansen's Multivariate Normality Test", "\n", sep = " ")
cat("---------------------------------------------", "\n", sep = " ")
cat(" data :", object@dname, "\n\n", sep = " ")
cat(" DH :", object@TS, "\n", sep = " ")
cat(" p-value :", object@p.value, "\n\n", sep = " ")
cat(if(object@p.value > 0.05){" Result : Data is multivariate normal."}
else {" Result : Data is not multivariate normal."},"\n")
cat("---------------------------------------------", "\n\n", sep = " ")
invisible(NULL)
})