Few changes in R code
This commit is contained in:
@ -215,6 +215,41 @@ compile_simulation <- function(scenario) {
|
||||
}
|
||||
N <- ifelse(substr(scenario,start=nchar(scenario)-1,stop=nchar(scenario))=="50","50",substr(scenario,start=nchar(scenario)-2,stop=nchar(scenario)))
|
||||
zz <- ifelse(N=="50",substr(scenario,start=0,stop=nchar(scenario)-3),substr(scenario,start=0,stop=nchar(scenario)-4))
|
||||
zz.type <- substr(zz,start=nchar(zz),stop=nchar(zz))
|
||||
|
||||
if (unique(is.na(s$dif.size))) {
|
||||
s$dif.size <- 0
|
||||
}
|
||||
if(zz=="10B") {
|
||||
s$dif.size <- 0.3
|
||||
}
|
||||
if (substr(zz,1,1)%in%c("6","8")) {
|
||||
s$nb.dif <- 1
|
||||
}
|
||||
if (substr(zz,1,2)%in%c("10","12","14",'16')) {
|
||||
s$nb.dif <- 2
|
||||
}
|
||||
if (substr(zz,1,1)%in%c("18","20")) {
|
||||
s$nb.dif <- 3
|
||||
}
|
||||
|
||||
if (zz.type!="A") {
|
||||
if (zz.type=="B") {
|
||||
s$eff.size <- 0.2
|
||||
} else if (zz.type=="C" & unique(s$dif.size)==0) {
|
||||
s$eff.size <- 0.4
|
||||
} else if (zz.type=="C" & unique(s$dif.size)!=0) {
|
||||
s$eff.size <- 0.2
|
||||
} else if (zz.type=="D" & unique(s$dif.size)!=0) {
|
||||
s$eff.size <- 0.4
|
||||
} else if (zz.type=="E" & unique(s$dif.size)!=0) {
|
||||
s$eff.size <- 0.4
|
||||
}
|
||||
} else {
|
||||
s$eff.size <- 0
|
||||
s$dif.size <- -1*s$dif.size
|
||||
}
|
||||
|
||||
b <- data.frame(scenario=zz,
|
||||
scenario.type=substr(zz,start=nchar(zz),stop=nchar(zz)),
|
||||
N=N,
|
||||
@ -229,6 +264,7 @@ compile_simulation <- function(scenario) {
|
||||
se.analytical.beta=mean(s$se.beta),
|
||||
m.low.ci.beta=mean(s$low.ci.beta),
|
||||
m.high.ci.beta=mean(s$high.ci.beta),
|
||||
bias=mean(s$beta-s$eff.size),
|
||||
true.value.in.ci.p=mean(s$true.value.in.ci),
|
||||
h0.rejected.p=mean(s$h0.rejected),
|
||||
beta.same.sign.truebeta.p=mean(s$beta.same.sign.truebeta,na.rm=T),
|
||||
@ -247,18 +283,8 @@ for (x in results[seq(2,length(results))]) {
|
||||
res.dat <- bind_rows(res.dat,y)
|
||||
}
|
||||
|
||||
res.dat[res.dat$scenario.type=='A','dif.size'] <- -res.dat[res.dat$scenario.type=='A','dif.size']
|
||||
res.dat[is.na(res.dat$dif.size),'dif.size'] <- 0
|
||||
res.dat[res.dat$scenario=="10B",]$dif.size <- 0.3
|
||||
res.dat[substr(res.dat$scenario,1,1)%in%c("6","8"),'nb.dif'] <- 1
|
||||
res.dat[substr(res.dat$scenario,1,2)%in%seq(10,16,2),'nb.dif'] <- 2
|
||||
res.dat[substr(res.dat$scenario,1,2)%in%seq(18,20,2),'nb.dif'] <- 3
|
||||
res.dat[res.dat$N==50,"dif.size"] <- res.dat[which(res.dat$N==50)+1,"dif.size"]
|
||||
res.dat[res.dat$scenario.type=="B",]$eff.size <- 0.2
|
||||
res.dat[res.dat$scenario.type=="C" & res.dat$dif.size==0,]$eff.size <- 0.4
|
||||
res.dat[res.dat$scenario.type=="C" & res.dat$dif.size!=0,]$eff.size <- 0.2
|
||||
res.dat[res.dat$scenario.type=="D" & res.dat$dif.size!=0,]$eff.size <- 0.4
|
||||
res.dat[res.dat$scenario.type=="E" & res.dat$dif.size!=0,]$eff.size <- 0.4
|
||||
|
||||
|
||||
is.nan.data.frame <- function(x) {
|
||||
do.call(cbind, lapply(x, is.nan))
|
||||
@ -266,7 +292,6 @@ is.nan.data.frame <- function(x) {
|
||||
|
||||
|
||||
res.dat[is.nan(res.dat)] <- NA
|
||||
res.dat$bias <- res.dat$eff.size-res.dat$m.beta
|
||||
|
||||
|
||||
##############################################################################
|
||||
|
Reference in New Issue
Block a user