-
Notifications
You must be signed in to change notification settings - Fork 2
/
momentos.R
93 lines (64 loc) · 1.76 KB
/
momentos.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
# vector de medias -------------------------------------------------------
M1 <- data.frame()
for (i in 1:dim(data)[2]){
# i <- 1
M1[i,1] <- mean(data[,i])
}
# matriz de varianzas y covarianzas ---------------------------------------
M2 <- data.frame()
for (i in 1:dim(data)[2]){
# i <- 1
for (j in 1:dim(data)[2]){
# j <- 1
u <- 0
for (t in 1:dim(data)[1]){
# t <- 1
u <- u + (( data[t,i] - mean(data[,i])) * ( data[t,j]-mean(data[,j]))) #es la suma del producto de cada valor menor la media de la columna
}
M2[i,j] <- u / (dim(data)[1]-1)
}
}
# matriz de sesgos -------------------------------------------------------------
M3 <- data.frame()
for (i in 1:dim(data)[2]){
s <- data.frame()
# i <- 1
for (j in 1:dim(data)[2]){
# j<-1
for (k in 1:dim(data)[2]){
# k <- 2
u <- 0
for (t in 1:dim(data)[1]){
# t<-1
u <- u + ((data[t,i] - mean(data[,i])) * (data[t,j] - mean(data[,j])) *
(data[t,k] - mean(data[,k])))
}
s[j,k] <- u / dim(data)[1]
}
}
M3 <- rbind(M3, s)
}
# matriz de kurtosis ----------------------------------------------------------------
M4 <- data.frame()
for (i in 1:dim(data)[2]){
# i <- 1
for (j in 1:dim(data)[2]){
s <- data.frame()
# j<-1
for (k in 1:dim(data)[2]){
# k <- 2
for (l in 1:dim(data)[2]){
# l<-1
u <- 0
for (t in 1:dim(data)[1]){
# t<-1
u <- u + ( (data[t,i] - mean(data[,i])) * (data[t,j] - mean(data[,j])) *
(data[t,k] - mean(data[,k])) * ( data[t,l] - mean(data[,l])) )
}
s[k,l] <- u / dim(data)[1]
}
}
M4 <- rbind(M4, s)
}
}
rm(s, i, j, k, l , t, u)