-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexamples_3.r
More file actions
45 lines (41 loc) · 1000 Bytes
/
examples_3.r
File metadata and controls
45 lines (41 loc) · 1000 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
library(tidyverse)
library(smacof)
dat1 <- read.table(file = file.choose(), header = F)
dat1 %>% mutate(V1 = NULL) %>%
setNames(paste0("x", 1:5)) -> dat1
dat1
D_x <- dist(dat1)
Model_cmd <- cmdscale(dist(dat1), k = 5, add = TRUE)
Model2_smacof <- smacofSym(dist(dat1), ndim = 5)
Model2_smacof$conf -> v1
v1
colSums(v1)
colSums(Model_cmd)
Model_cmd$GOF
#################################
library(tidyverse)
library(MVA)
tapply(1:nrow(skulls), skulls$epoch, function(x){
dat = skulls[x, -1]
return(cov(dat))
}) -> skulls_var
id_row <- tapply(1:nrow(skulls), skulls$epoch, function(x){
dat = skulls[x, -1]
return(nrow(dat))
})
id_row
S <- matrix(0, 4, 4)
for(i in 1:5){
S = S + (id_row[[i]] - 1) * skulls_var[[i]]
}
Sp = S / (nrow(skulls) - length(skulls_var))
Sp %>% round(3) -> Sp
Sp
xbar1 <- tapply(1:nrow(skulls), skulls$epoch, function(x){
colMeans(skulls[x, -1])
})
xbar1
class(xbar1)
dim(xbar1)
xbar1 %>% transpose %>% as_tibble() %>% unnest(cols = c(mb, bh, bl, nh)) %>%
as.data.frame