This repository has been archived by the owner on Feb 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimulWebs.r
executable file
·53 lines (37 loc) · 1.79 KB
/
SimulWebs.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
Outputs = list.files(path='output', pattern='WEB')
Results = NULL
for (o in Outputs){
sim = read.table(paste('output/',o,sep=''))
Results = rbind(Results,sim)
}
res = Results
MotId = c(paste('S',c(1:5),sep=''),paste('D',c(1:8),sep=''))
colnames(res) =
c('w','repl','scaling','L',MotId,'S','b','bm','bprod','bpred')
for(i in c(1:nrow(res))){
Mo = res[i,MotId]
res[i,MotId] = Mo / sum(Mo)
}
res$compratio = res$S4/res$S5
res$co = res$L / res$S^2
lapply(split(res,res$scaling),function(x) anova(lm(bm~S1+S2+S3+S4+S5,x)))
lapply(split(res,res$scaling),function(x) summary(lm(bm~S1+S2+S3+S4+S5,x)))
lapply(split(res,res$scaling),function(x) anova(lm(bprod~S1+S2+S3+S4+S5,x)))
lapply(split(res,res$scaling),function(x) summary(lm(bprod~S1+S2+S3+S4+S5,x)))
lapply(split(res,res$scaling),function(x) anova(lm(bpred~S1+S2+S3+S4+S5,x)))
lapply(split(res,res$scaling),function(x) summary(lm(bpred~S1+S2+S3+S4+S5,x)))
## Using compratio
lapply(split(res,res$scaling),function(x) anova(lm(bm~S1+S2+S3+log(compratio,10),x)))
lapply(split(res,res$scaling),function(x) summary(lm(bm~S1+S2+S3+log(compratio,10),x)))
lapply(split(res,res$scaling),function(x) anova(lm(bprod~S1+S2+S3+log(compratio,10),x)))
lapply(split(res,res$scaling),function(x) summary(lm(bprod~S1+S2+S3+log(compratio,10),x)))
lapply(split(res,res$scaling),function(x) anova(lm(bpred~S1+S2+S3+log(compratio,10),x)))
lapply(split(res,res$scaling),function(x) summary(lm(bpred~S1+S2+S3+log(compratio,10),x)))
sim = aggregate(.~w+scaling,res,mean,na.rm=TRUE)
sim = sim[order(sim$bm),]
Scaled = subset(sim,sim$scaling==2)
UnScaled = subset(sim,sim$scaling==0)
Scaled$prank = rank(Scaled$bm)
write.table(Scaled,file='w-scaled.dat', row.names=FALSE,quote=FALSE)
UnScaled$prank = rank(UnScaled$bm)
write.table(UnScaled,file='w-unscaled.dat', row.names=FALSE,quote=FALSE)