This repository has been archived by the owner on Mar 16, 2020. It is now read-only.
forked from scotthlee/autism-surveillance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysis.R
66 lines (55 loc) · 1.97 KB
/
analysis.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
library(data.table)
library(multcomp)
#######################################################
# Analysis for the accuracies
#setwd('data')
x <- fread('accuracies.csv')
# original
x.mean <- colMeans(x)
x.cov <- cov(x)
x.names <- names(copy(x))
# ascending mean
y.mean <- x.mean[order(x.mean)]
y.cov <- x.cov[order(x.mean),order(x.mean)]
y.names <- x.names[order(x.mean)]
# precontrasts - i.e., vectors to construct pairwise contrasts
y.precontr <- rep(1,8); names(y.precontr) <- y.names
# all values contrasted with nbsvm
point.mod <- glht(parm(y.mean, y.cov),
linfct=diag(8))
point.cis <- confint(point.mod)
diff.mod <- glht(parm(y.mean, y.cov),
linfct=contrMat(y.precontr,
type="Dunnett",
base=8))
diff.cis <- confint(diff.mod)
write.csv(point.cis$confint, 'acc-cis.csv')
write.csv(diff.cis$confint, 'acc-diff-cis.csv')
#######################################################
# Analysis for the discordances
count.df <- fread('counts.csv')
x.mean <- (count.df$pos.calls - count.df$true.pos) / count.df$pop
names(x.mean) <- count.df$model
# original
x.cov <- cov(x)
x.names <- names(x.mean)
# descending mean (by abs)
ord <- order(abs(x.mean), decreasing=T)
y.mean <- x.mean[ord]
y.cov <- x.cov[ord, ord]
y.names <- x.names[ord]
# precontrasts - i.e., vectors to construct pairwise contrasts
y.precontr <- rep(1,8); names(y.precontr) <- y.names
# getting the CIs for the point estimates
point.mod <- glht(parm(y.mean, y.cov),
linfct=diag(8))
point.cis <- as.data.frame(confint(point.mod)$confint) * 100
point.cis$model <- y.names
write.csv(point.cis, 'disc-cis.csv')
# getting the CIs for the differences in point estimates
diff.mod <- glht(parm(y.mean, y.cov),
linfct=contrMat(y.precontr,
type="Dunnett",
base=8))
diff.cis <- confint(diff.mod)
write.csv(diff.cis$confint * 100, 'disc-diff-cis.csv')