p
#
#
n	<- t(matrix(c(15539,	3842,	3778,	7919,
1769,	475,	404,	890,
1324,	358,	331,	635,
#
2465,	592,	612,	1261,
225,	58,	48,	119,
42,	10,	7,	25,
279,	79,	69,	131,
9435,	2270,	2307,	4858), nrow=4))
rm(p)
n
p	<- matrix(NA, ncol=4, nrow=6)
p
rownames(p)	<- c(4:9)
p
p[1,]	<- n[2,]/n[1,]
n[1,]+n[2,]
n[1,]
n[1,]-n[2,]
p[1,]	<- n[2,]/(n[1,])#
p[2,]	<- n[3,]/(n[1,]-n[2,])
p[6,]	<- n[7,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,]-n[6,])
p
p[1,]	<- n[2,]/(n[1,])#
p[2,]	<- n[3,]/(n[1,]-n[2,])#
p[3,]	<- n[4,]/(n[1,]-n[2,]-n[3,])#
p[4,]	<- n[5,]/(n[1,]-n[2,]-n[3,]-n[4,])#
p[5,]	<- n[6,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,])#
p[6,]	<- n[7,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,]-n[6,])
p
#
#
n	<- t(matrix(c(15539,	3842,	3778,	7919,
1769,	475,	404,	890,
1324,	358,	331,	635,
#
2465,	592,	612,	1261,
225,	58,	48,	119,
42,	10,	7,	25,
279,	79,	69,	131,
9435,	2270,	2307,	4858), nrow=4))
#
#
p	<- matrix(NA, ncol=4, nrow=6)#
rownames(p)	<- c(4:9)#
#
p[1,]	<- n[2,]/(n[1,])#
p[2,]	<- n[3,]/(n[1,]-n[2,])#
p[3,]	<- n[4,]/(n[1,]-n[2,]-n[3,])#
p[4,]	<- n[5,]/(n[1,]-n[2,]-n[3,]-n[4,])#
p[5,]	<- n[6,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,])#
p[6,]	<- n[7,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,]-n[6,])
n#
p
?round
round(p*100, digits=1)
#
#
n	<- t(matrix(c(15539,	3842,	3778,	7919,
1769,	475,	404,	890,
1324,	358,	331,	635,
#
2465,	592,	612,	1261,
225,	58,	48,	119,
42,	10,	7,	25,
279,	79,	69,	131,
9435,	2270,	2307,	4858), nrow=4))
#
#
p	<- matrix(NA, ncol=4, nrow=6)#
rownames(p)	<- c(4:9)#
colnames(p)	<- c("total","ML","control","MF")#
p[1,]	<- n[2,]/(n[1,])#
p[2,]	<- n[3,]/(n[1,]-n[2,])#
p[3,]	<- n[4,]/(n[1,]-n[2,]-n[3,])#
p[4,]	<- n[5,]/(n[1,]-n[2,]-n[3,]-n[4,])#
p[5,]	<- n[6,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,])#
p[6,]	<- n[7,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,]-n[6,])#
#
n#
round(p*100, digits=1)
colnames(n)	<- c("total","ML","control","MF")
n
rownames(p)	<- c(3:10)
rownames(p)	<- c(3:9)
rownames(n)	<- c(3:9)
rownames(n)	<- c(3:10)
n
p[7,]	<- n[7,]/n[1,]
n[7,]/n[1,]
p	<- matrix(NA, ncol=4, nrow=7)#
rownames(p)	<- c(4:10)#
colnames(p)	<- c("total","ML","control","MF")#
p[1,]	<- n[2,]/(n[1,])#
p[2,]	<- n[3,]/(n[1,]-n[2,])#
p[3,]	<- n[4,]/(n[1,]-n[2,]-n[3,])#
p[4,]	<- n[5,]/(n[1,]-n[2,]-n[3,]-n[4,])#
p[5,]	<- n[6,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,])#
p[6,]	<- n[7,]/(n[1,]-n[2,]-n[3,]-n[4,]-n[5,]-n[6,])#
#
p[7,]	<- n[7,]/n[1,]
n#
round(p*100, digits=1)
n[7,]/n[1,]
n[7,]
p[7,]	<- n[8,]/n[1,]
n#
round(p*100, digits=1)
library(lme4)
sessionInfo()
0.95^4
0.95^5
0.9^5
x	<- seq(-3,3,0.1)
x
?logit
??logit
?tanh
plot(x, tanh(x))
plot(x, tanh(x), type="l")
plot(x, tanh(x), type="l"); abline(v=0)
plot(x, tanh(x), type="l"); abline(v=0); abline(h=0)
plot(x, tanh(x), type="l"); abline(h=-1); abline(h=1)
plot(x, tanh(x), type="l"); abline(h=-1, col="grey"); abline(h=1, col="grey")
abline(h=0, col="grey");
abline(h=0, col="grey");abline(v=0, col="grey");
lines(x, 1/(1+exp(-1*x)))
lines(x, -1+2/(1+exp(-1*x)))
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
lines(x, -1+2/(1+exp(-1*x)))
lines(x, -1+2/(1+exp(-2*x)))
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
lines(x, -1+2/(1+exp(-2*x)))
plot(x, -1+2/(1+exp(-2*x)))#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, -1+2/(1+exp(-2*x)))
-1+2/(1+exp(-2*x)) == tanh(x)
 cbind( x, -1+2/(1+exp(-2*x)), tanh(x), -1+2/(1+exp(-2*x)) == tanh(x) )
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, 1-2/(1+exp(-2*x)))#
#
# cbind( x, -1+2/(1+exp(-2*x)), tanh(x), -1+2/(1+exp(-2*x)) == tanh(x) )
points(x, -1+2/(1+exp(-2*x)))
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, -1+2/(1+exp(-2*x)))#
#
# cbind( x, -1+2/(1+exp(-2*x)), tanh(x), -1+2/(1+exp(-2*x)) == tanh(x) )
tanh(1)
1 - tanh(x)^2
1 - tanh(1)^2
1 - tanh(0)^2
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, 1/(1+exp(-2*x)))#
points(x, -1+2/(1+exp(-2*x)))
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
lines(x, 1/(1+exp(-2*x)))#
points(x, -1+2/(1+exp(-2*x)))
lines(x, -1+1/(1+exp(-2*x)))
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, -1+2/(1+exp(-2*x)))#
lines(x, 1/(1+exp(-2*x)));lines(x, -1+1/(1+exp(-2*x)))#
#
# cbind( x, -1+2/(1+exp(-2*x)), tanh(x), -1+2/(1+exp(-2*x)) == tanh(x) )#
#
1 - tanh(0)^2
#
#
x	<- seq(-3,3,0.1)#
#
plot(x, tanh(x), type="l")#
abline(h=-1, col="grey"); abline(h=1, col="grey")#
abline(h=0, col="grey");abline(v=0, col="grey")#
points(x, -1+2/(1+exp(-2*x)))#
#lines(x, 1/(1+exp(-2*x)));lines(x, -1+1/(1+exp(-2*x)))#
#
# cbind( x, -1+2/(1+exp(-2*x)), tanh(x), -1+2/(1+exp(-2*x)) == tanh(x) )#
#
1 - tanh(0)^2
table(d$x1, d$x2, d$x3)
20*0.05
idx	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/idxR.out")
str(idx)
names(idx)	<- c("var","word nr","bin","wid")#
#
str(idx)
names(idx)	<- c("variable","word nr","bin","wid")#
#
str(idx)
table(idx$wid, idx$bin)
table(idx$wid, idx$variable)
names(idx)	<- c("variable","wordNr","bin","wid")
table(idx$wid, idx$wordNr)
table(idx$wordNr, idx$wid)
table(idx$bin, idx$variable)
table(idx$bin, idx$variable, idx$wordNr)
table(idx$variable, idx$bin, idx$wordNr)
load("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/Corpus/PSC.DWDS.rda")
str(PSC.DWDS)
dim(idx)
nrow(idx)/3/3
PSC.DWDS	<- PSC.DWDS[ PSC.DWDS$wn!=1 & PSC.DWDS$wn!=PSC.DWDS$nw,]
nrow(PSC.DWDS)
nrow(idx)/3/3#
nrow(PSC.DWDS)
rm(list=ls())
idx	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/idxR.out")#
#
names(idx)	<- c("variable","wordNr","bin","wid")#
#
str(idx)#
#
table(idx$wid, idx$variable)#
#
table(idx$wid, idx$wordNr)#
table(idx$wordNr, idx$wid)#
#
table(idx$variable, idx$bin, idx$wordNr)#
#
#
load("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/Corpus/PSC.DWDS.rda")
names(PSC.DWDS)
idx[1:30,]
range(idx$wid)
length(unique(idx$wid))
idx[,c("sn","wn","nw","nchr","freq","predid")] <- PSC.DWDS[ idx$wid ,c("sn","wn","nw","nchr","freq","predid"]
idx$wid
idx[,c("sn","wn","nw","nchr","freq","predid")] <- PSC.DWDS[ idx$wid ,c("sn","wn","nw","nchr","freq","predid")]
str(idx)
qplot(x=wid, y=freq, data=idx, geom="point", colour="wid", facets=variable~wordNr)
library(ggplot2)
qplot(x=wid, y=freq, data=idx, geom="point", colour=wid, facets=variable~wordNr)
qplot(x=wid, y=freq, data=idx, geom="point", colour=bin, facets=variable~wordNr)
qplot(x=wid, y=bin, data=idx, geom="point", colour=freq, facets=variable~wordNr)
qplot(x=wid, y=bin, data=idx, geom="point", colour=nchr, facets=variable~wordNr)
qplot(x=wid, y=bin, data=idx, geom="point", colour=factor(nchr), facets=variable~wordNr)
qplot(x=wid, y=bin, data=idx, geom="point", colour=freq, facets=variable~wordNr)
qplot(x=wid, y=bin, data=idx, geom="point", colour=predid, facets=variable~wordNr)
str(PSC.DWDS)
PSC.DWDS$l	<- PSC.DWDS$nchr#
PSC.DWDS$f	<- PSC.DWDS$freq#
PSC.DWDS$p	<- PSC.DWDS$predid#
PSC.DWDS[,c("len1","f1","pre1")] <- rbind(c(NA,NA,NA),PSC.DWDS[1:(dim1-1),c("l","f","p")])#
PSC.DWDS[,c("len2","f2","pre2")] <- rbind(PSC.DWDS[2:dim1,c("l","f","p")], c(NA,NA,NA))#
PSC.DWDS[PSC.DWDS$wn==1		,c("len1","f1","pre1")] <- NA#
PSC.DWDS[PSC.DWDS$wn==PSC.DWDS$nw,c("len2","f2","pre2")] <- NA
PSC.DWDS$l	<- PSC.DWDS$nchr#
PSC.DWDS$f	<- PSC.DWDS$freq#
PSC.DWDS$p	<- PSC.DWDS$predid
PSC.DWDS[,c("len1","f1","pre1")] <- rbind(c(NA,NA,NA),PSC.DWDS[1:(dim1-1),c("l","f","p")])
dim1 <- nrow(SHUF.dwds)#
PSC.DWDS$l	<- PSC.DWDS$nchr#
PSC.DWDS$f	<- PSC.DWDS$freq#
PSC.DWDS$p	<- PSC.DWDS$predid#
PSC.DWDS[,c("len1","f1","pre1")] <- rbind(c(NA,NA,NA),PSC.DWDS[1:(dim1-1),c("l","f","p")])
dim1 <- nrow(PSC.DWDS)#
PSC.DWDS$l	<- PSC.DWDS$nchr#
PSC.DWDS$f	<- PSC.DWDS$freq#
PSC.DWDS$p	<- PSC.DWDS$predid#
PSC.DWDS[,c("len1","f1","pre1")] <- rbind(c(NA,NA,NA),PSC.DWDS[1:(dim1-1),c("l","f","p")])
PSC.DWDS[,c("len2","f2","pre2")] <- rbind(PSC.DWDS[2:dim1,c("l","f","p")], c(NA,NA,NA))
PSC.DWDS[PSC.DWDS$wn==1		,c("len1","f1","pre1")] <- NA#
PSC.DWDS[PSC.DWDS$wn==PSC.DWDS$nw,c("len2","f2","pre2")] <- NA
vars <- c("sn","wn","nw","l","f","p","len1","f1","pre1","len2","f2","pre2")#
idx[,vars] <- PSC.DWDS[ idx$wid ,vars]
str(idx)
idx$var	<- 	ifelse(idx$variable==1, #
					ifelse(idx$wordNr==1, "len1",#
					ifelse(idx$wordNr==2, "l",#
					ifelse(idx$wordNr==3, "len2", NA))),#
			ifelse(idx$variable==2, #
					ifelse(idx$wordNr==1, "f1",#
					ifelse(idx$wordNr==2, "f",#
					ifelse(idx$wordNr==3, "f2", NA))),#
			ifelse(idx$variable==3, #
					ifelse(idx$wordNr==1, "pre1",#
					ifelse(idx$wordNr==2, "p",#
					ifelse(idx$wordNr==3, "pre2", NA))),#
			NA)))
str(idx)
idx[,idx$var]
idx$x	<- NA#
IDX	<- which(idx$variable==1 & idx$wordNr==1)
IDX	<- which(idx$variable==1 & idx$wordNr==1)#
idx$x[IDX] <- idx$len1[IDX]
idx$x	<- NA#
IDX	<- idx$variable==1 & idx$wordNr==1; idx$x[IDX] <- idx$len1[IDX]#
IDX	<- idx$variable==1 & idx$wordNr==2; idx$x[IDX] <- idx$l[IDX]#
IDX	<- idx$variable==1 & idx$wordNr==3; idx$x[IDX] <- idx$len2[IDX]#
IDX	<- idx$variable==2 & idx$wordNr==1; idx$x[IDX] <- idx$f1[IDX]#
IDX	<- idx$variable==2 & idx$wordNr==2; idx$x[IDX] <- idx$f[IDX]#
IDX	<- idx$variable==2 & idx$wordNr==3; idx$x[IDX] <- idx$f2[IDX]#
IDX	<- idx$variable==3 & idx$wordNr==1; idx$x[IDX] <- idx$pre1[IDX]#
IDX	<- idx$variable==3 & idx$wordNr==2; idx$x[IDX] <- idx$p[IDX]#
IDX	<- idx$variable==3 & idx$wordNr==3; idx$x[IDX] <- idx$pre2[IDX]
qplot(x=x, y=bin, data=idx, geom="point", colour=x, facets=variable~wordNr)
qplot(x=x, y=bin, data=idx, geom="point", colour=x, facets=variable~wordNr, scales="free")
?scles
?scales
?scale
?qplot
?facet
?facets
?facet_grid
qplot(x=x, y=bin, data=idx, geom="point", colour=x) + facets_grid(variable~wordNr, scales="free")
qplot(x=x, y=bin, data=idx, geom="point", colour=x) + #
	facet_grid(variable~wordNr, scales="free")
qplot(x=x, y=bin, data=idx, geom="point", colour=x) + #
	facet_grid(variable~wordNr, scales="free_x")
qplot(x=x, y=bin, data=idx, geom="point", colour=x) + #
	facet_grid(wordNr~ variable , scales="free_x")
#
#
library(reshape)#
library(ggplot2)#
rm(list=ls())#
#
## read in and plot newgoffunc - output#
#
exp		<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.exp")#
fit		<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.fit") #
esqs	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.esqs")#
#
VARs	<- c("l1","l","l2","f1","f","f2","p1","p","p2")[1:dim(exp)[1]]#
esqs		<- data.frame(t(as.matrix(esqs)), row.names=NULL)#
names(esqs)	<- VARs#
esqs$bin	<- rownames(esqs)#
esqs		<- melt(esqs, measure=VARs, id=c("bin"))#
esqs$data	<- "esqs"#
#
exp			<- data.frame(t(as.matrix(exp)), row.names=NULL)#
names(exp)	<- VARs#
exp$bin		<- rownames(exp)#
exp			<- melt(exp, measure=VARs, id=c("bin"))#
exp$data	<- "exp"#
exp$esqs	<- esqs$value#
#
fit			<- data.frame(t(as.matrix(fit)), row.names=NULL)#
names(fit)	<- VARs#
fit$bin		<- rownames(fit)#
fit			<- melt(fit, measure=VARs, id=c("bin"))#
fit$data	<- "fit"#
fit$esqs	<- NA#
#
# combine data#
dat	<- rbind(exp, fit)#
#
dat$var	<- NA#
dat$var[ dat$variable %in% c("l1","l","l2") ] <- "Word Length"#
dat$var[ dat$variable %in% c("f1","f","f2") ] <- "Word Frequency"#
dat$var[ dat$variable %in% c("p1","p","p2") ] <- "Word Predictability"#
#
dat$word	<- NA#
dat$word[ dat$variable %in% c("l1","f1","p1") ] <- "word n-1"#
dat$word[ dat$variable %in% c("l" ,"f" ,"p" ) ] <- "word n"#
dat$word[ dat$variable %in% c("l2","f2","p2") ] <- "word n+1"#
dat$word	<- factor(dat$word)#
dat$word	<- factor(dat$word, levels=levels(dat$word)[c(2,1,3)])#
#
dat$bin	<- as.numeric(dat$bin)#
dat$bin[dat$var=="Word Length"] <- dat$bin[dat$var=="Word Length"] + 1#
#
dat	<- dat[dat$value>0,] # remove empty cells#
#
quartz(width=10, height=6)#
qplot(x=bin, y=value, data=dat, geom=c("point","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]")
#
# check whether this is the same as produced via swift-input#
#
dat	<- "shuf"#
#
if (dat=="shuf") s	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/swift_SHUF_FixStat_pSW2R.dat")#
if (dat=="psc") s	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/swift_PSC275_FixStat_pW2R.dat")#
names(s)	<- c("nw","l","f","p","d1","d2","d0","trt","p0","p1","p2","rgc")#
s[s==-1]	<- NA#
#
if (dat=="shuf") idx.out	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/idx.SHUFpSW_2R.out")#
if (dat=="psc") idx.out	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/idx.PSC275pW_2R.out")#
names(idx.out)	<- c("var","wordNr","bin","wid")#
#
str(s)#
str(idx.out)#
#
range(idx.out$wid)#
nrow(s)#
#
idx.out$d0	<- s$d0[idx.out$wid]#
#
#
idxm	<- melt(idx.out, measure=c("d0"), id=c("var","wordNr","bin"))#
idxc	<- data.frame(cast(idxm, var + wordNr + bin ~ variable, mean))
str(idxc)
idxc	<- data.frame(cast(idxm, var + wordNr + bin ~ variable, mean, na.rm=TRUE))
str(idxc)
idxc
exp2	<- exp#
exp2$value	<- idxc$d0#
exp2$data	<- "man"#
dat2	<- rbind(exp, exp2)#
#
dat2$var	<- NA#
dat2$var[ dat2$variable %in% c("l1","l","l2") ] <- "Word Length"#
dat2$var[ dat2$variable %in% c("f1","f","f2") ] <- "Word Frequency"#
dat2$var[ dat2$variable %in% c("p1","p","p2") ] <- "Word Predictability"#
#
dat2$word	<- NA#
dat2$word[ dat2$variable %in% c("l1","f1","p1") ] <- "word n-1"#
dat2$word[ dat2$variable %in% c("l" ,"f" ,"p" ) ] <- "word n"#
dat2$word[ dat2$variable %in% c("l2","f2","p2") ] <- "word n+1"#
dat2$word	<- factor(dat2$word)#
dat2$word	<- factor(dat2$word, levels=levels(dat2$word)[c(2,1,3)])#
#
dat2$bin	<- as.numeric(dat2$bin)#
dat2$bin[dat2$var=="Word Length"] <- dat2$bin[dat2$var=="Word Length"] + 1#
#
dat2	<- dat2[dat2$value>0,] # remove empty cells#
#
#
#
quartz(width=10, height=6)#
qplot(x=bin, y=value, data=dat2, geom=c("point","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]")
qplot(x=bin, y=value, data=dat2, geom=c("jitter","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]")
exp2
cbind(exp,exp2)
mean(exp$d0 == idxc$d0)
idxc$d0
exp$d0
exp$value
mean(exp$value == idxc$d0)
exp$value == idxc$d0
str(idxc$d0)
str(exp$value)
plot(idxc$d0, exp$value)
exp$value == idxc$d0
qplot(x=bin, y=value, data=dat2, geom=c("jitter","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]", linetype=data)
qplot(x=bin, y=value, data=dat2, geom=c("point","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]", linetype=data)
qplot(x=bin, y=value, data=dat2, geom=c("point","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]", linetype=data, shape=data)
#
#
library(reshape)#
library(ggplot2)#
rm(list=ls())#
#
## read in and plot newgoffunc - output#
#
exp		<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.exp")#
fit		<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.fit") #
esqs	<- read.table("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB/newgoffunc.esqs")#
#
VARs	<- c("l1","l","l2","f1","f","f2","p1","p","p2")[1:dim(exp)[1]]#
esqs		<- data.frame(t(as.matrix(esqs)), row.names=NULL)#
names(esqs)	<- VARs#
esqs$bin	<- rownames(esqs)#
esqs		<- melt(esqs, measure=VARs, id=c("bin"))#
esqs$data	<- "esqs"#
#
exp			<- data.frame(t(as.matrix(exp)), row.names=NULL)#
names(exp)	<- VARs#
exp$bin		<- rownames(exp)#
exp			<- melt(exp, measure=VARs, id=c("bin"))#
exp$data	<- "exp"#
exp$esqs	<- esqs$value#
#
fit			<- data.frame(t(as.matrix(fit)), row.names=NULL)#
names(fit)	<- VARs#
fit$bin		<- rownames(fit)#
fit			<- melt(fit, measure=VARs, id=c("bin"))#
fit$data	<- "fit"#
fit$esqs	<- NA#
#
# combine data#
dat	<- rbind(exp, fit)#
#
dat$var	<- NA#
dat$var[ dat$variable %in% c("l1","l","l2") ] <- "Word Length"#
dat$var[ dat$variable %in% c("f1","f","f2") ] <- "Word Frequency"#
dat$var[ dat$variable %in% c("p1","p","p2") ] <- "Word Predictability"#
#
dat$word	<- NA#
dat$word[ dat$variable %in% c("l1","f1","p1") ] <- "word n-1"#
dat$word[ dat$variable %in% c("l" ,"f" ,"p" ) ] <- "word n"#
dat$word[ dat$variable %in% c("l2","f2","p2") ] <- "word n+1"#
dat$word	<- factor(dat$word)#
dat$word	<- factor(dat$word, levels=levels(dat$word)[c(2,1,3)])#
#
dat$bin	<- as.numeric(dat$bin)#
dat$bin[dat$var=="Word Length"] <- dat$bin[dat$var=="Word Length"] + 1#
#
dat	<- dat[dat$value>0,] # remove empty cells#
#
quartz(width=10, height=6)#
qplot(x=bin, y=value, data=dat, geom=c("point","line"), colour=data, facets=var~word, ylab="Single Fixation Durations [ms]")
dat	<- "SHUF"	# "SHUF"	"PSC275" "PSC30"
paste(dat,"_samples.rda",sep="")
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData",dat,"_samples.rda",sep="")
isamp
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")
idat	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")
isamp
idat
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")
load(isamp)#
load(idatL)#
load(idatR)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# load files#
load(isamp)#
load(idatL)
ls()
str(samp)
names(a)
str(a)
table(a$id)
samp
samp$sample==1
samp$id[samp$sample==1]
idx	<- a$id %in% samp$id[samp$sample==1]
sum(idx)
mean(idx)
str(idx)
a[which(idx)[1:20],c("id","sn")]
a[which(idx)[1:20],c("id")]
table(a[which(idx),c("id")])
samp[samp$sample==1]
samp$id[samp$sample==1]
samp$id[samp$sample==2]
idx2	<- a$id %in% samp$id[samp$sample==2]#
a2		<- a[ idx1 , ]
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
idatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L1.rda",sep="")#
idatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L2.rda",sep="")#
#
idatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R1.rda",sep="")#
idatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R2.rda",sep="")
idatL1
idatL2
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
idatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L1.rda",sep="")#
idatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L2.rda",sep="")#
#
idatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R1.rda",sep="")#
idatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R2.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# left eye data#
load(idatL)#
A	<- a#
rm(a)
# sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L1.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L2.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R1.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R2.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# left eye data#
load(idatL)#
A	<- a#
rm(a)#
# sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L1.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L2.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R1.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R2.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"1/",dat3,"_fix_L.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"1/",dat3,"_fix_L.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"1/",dat3,"_fix_R.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"1/",dat3,"_fix_R.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_L.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_L.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_R.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_R.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
#
rm(list=ls())#
#
dat1	<- "shuf"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "SHUF"	#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "shuf"	#	"shuf"	"PSC275"	"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_L.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_L.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_R.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_R.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
#
rm(list=ls())#
#
dat1	<- "psc275S"	#	"shuf"	"psc275S"	"psc30"#
dat2	<- "PSC275"		#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "275S"		#	"shuf"	"275S"		"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_L.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_L.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_R.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_R.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
#
rm(list=ls())#
#
dat1	<- "psc30"		#	"shuf"	"psc275S"	"psc30"#
dat2	<- "PSC30"		#	"SHUF"	"PSC275"	"PSC30"#
dat3	<- "PSCmSHUF"	#	"shuf"	"275S"		"PSC30"#
#
# define input files#
isamp	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_10SWIFTinput/RData/",dat1,"_samples.rda",sep="")#
#
idatL	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_L.rda",sep="")#
idatR	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"/",dat3,"_fix_R.rda",sep="")#
#
# define output files#
odatL1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_L.rda",sep="")#
odatL2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_L.rda",sep="")#
#
odatR1	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_1/",dat3,"_fix_R.rda",sep="")#
odatR2	<- paste("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_15RData2/exp/",dat2,"_2/",dat3,"_fix_R.rda",sep="")#
#
#
# load & process files#
load(isamp)#
#
# 1) left eye data#
#-------------------#
load(idatL)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatL1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatL2)#
#
rm(a,A)#
#
# 2) right eye data#
#-------------------#
load(idatR)#
A	<- a#
rm(a)#
#
#sample 1#
idx1	<- A$id %in% samp$id[samp$sample==1]#
a		<- A[ idx1 , ]#
save(a, file=odatR1)#
#sample 2#
idx2	<- A$id %in% samp$id[samp$sample==2]#
a		<- A[ idx1 , ]#
save(a, file=odatR2)
install.packages("ggplot2")
install.packages("gtools")
install.packages("lme4", repos="http://R-Forge.R-project.org")
library(lme4)
install.packages("Matrix")
library(lme4)
install.packages("lme4")
library(lme4)
?lmer
library(ggplot2)
?qplot
?geom_smooth
install.packages("Hmisc")
library(Hmisc)
library(ggplot2)
setwd("/Users/daniel/Documents/Projects_ML/04SHUF3_SIM/shuf3_11Simulation/swift3pgB10a/xplot2")
#
	load("gacollect2.rda")#
	#
	collect2	<- collect[,1:(dim(collect)[2]-1)]#
	collect2$delta1a	<- collect2$delta0*collect2$delta1	#
	panel.cor <- function(x, y, digits=2, prefix="", cex.cor, ...)#
	{#
		usr <- par("usr"); on.exit(par(usr))#
		par(usr = c(0, 1, 0, 1))#
		r <- rcorr(x, y,type="spearman")$r[1,2]#cor(x, y)#
		txt <- format(c(r, 0.123456789), digits=digits)[1]#
		txt <- paste(prefix, txt, sep="")#
		if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)#
		text(0.5, 0.5, txt, cex = cex.cor * r)#
	}#
#	if (nrow(collect2)>4)#
#		pairs(collect2, lower.panel=panel.smooth,#
#						upper.panel=panel.cor)#
#	if (nrow(collect2)<=4)#
#		pairs(collect2)#
#	dev.copy2eps(file="corCross2.eps")#
	#
#
	#
	# transform delta1-parameter into additive scale (from multiplicative)#
	# old:	dynfac = 1.0 - a[k]/aord;#
	# old:	deltar = delta0*(1.0+delta1*dynfac);#
	#		deltar = delta0 + delta0*delta1 *dynfac;#
	# new:	deltar = delta0 + 		 delta1a*dynfac;#
	collect$delta1a	<- collect$delta0*collect$delta1#
#
	#collect$SimNr	<- 1:nrow(collect)#
	#
	cm	<- melt(collect, id=c("delta1","corp"))#
	cc	<- data.frame(cast(cm, corp + delta1 + variable ~ ., mean))#
#	print(qplot(delta1, X.all., data=cc, geom=c("point"), #
#		se=F, ylab="parameter value", colour=corp)+#
#		facet_wrap(~variable, scales="free_y"))#
#	ggsave("corDelta12.png")#
	#
	#
	cm	<- melt(collect, id=c("dev","corp"))#
	cc	<- data.frame(cast(cm, corp + dev + variable ~ ., mean))#
#	print(qplot(dev, X.all., data=cc, geom=c("point"), #
#		se=F, ylab="parameter value", colour=corp)+#
#		#geom_smooth(method=lm, formula=y~x, se=F)+#
#		facet_wrap(~variable, scales="free_y"))#
#	ggsave("corDev2.png")#
		#
	# load range.dat#
	names(collect)[names(collect)=="dev"] <- "Xdev"#
	cm		<- melt(collect, id=c("corp"))#
	rang 	<- read.table(paste("../swift3pgB0/range.dat",sep=""))#
	rang[,1]<- as.character(rang[,1])#
	rang	<- rbind(rang, c(#
				"delta1a",#
				rang[rang[,1]=="delta0",2]*rang[rang[,1]=="delta1",2],#
				NA ) )#
#				rang[rang[,1]=="delta0",3]*rang[rang[,1]=="delta1",3] ) )#
	idx		<- match(cm$variable, rang[,1])#
	cm$low	<- as.numeric(rang[idx,2])#
	cm$high	<- as.numeric(rang[idx,3])#
#
	load("datED.rda")#
	datED$parameter	<- row.names(datED)#
	cmED	<- melt(datED)#
	names(cmED)	<- c("variable","corp","value")#
#	match(cm)#
	#
	# determine significance levels for parameter tests against 0#
#	PV	<- c()#
#	nc	<- dim(collectP)[2]#
#	for (i in 1:nc) {#
#		pvalue	<- ceiling(t.test(collectP[,i])$p.value*1000)/1000#
#		print(paste(names(collectP)[i], "    ", pvalue,sep=""))#
#		PV	<- c(PV, pvalue)#
#		}#
#	names(PV)		<- names(collectP)#
#	names(collectP)	<- paste(names(collectP),"    p = ",PV,sep="")#
#	collectX		<- data.frame(t(collectP))#
#	collectX$pars	<- rownames(collectX)#
	source("/Users/daniel/Documents/R/Rfunctions/mean_SE.R")#
	#
	# plot#
#	bquote(theta == .(theta))#
#	expression(paste(lambda))#
	#
	cm$corp		<- factor(cm$corp)#
	cm$Model	<- factor(cm$corp, levels=levels(cm$corp)[c(2,1)])#
	levels(cm$Model)	<- c("Shuffled-SWIFT 3","Normal-SWIFT 3")#
	cm$variable	<- factor(cm$variable, levels=levels(cm$variable)[c(1,2,3,4,12,5,6,7,8,9,10,11)])#
	levels(cm$variable)[levels(cm$variable)=="delta1a"] <- "delta1\nadditive"#
#	levels(cm$variable)[levels(cm$variable)=="alpha"] <- bquote(theta == .(theta))#
	levels(cm$variable)	<- c("alpha","beta","delta0","delta1","delta1\nadditive","msac","h","ppf","iota","proc","theta","Xdev")#
#	levels(cm$variable)	<- c( expression(alpha), expression(beta), expression(paste(delta,"0")), #
#			expression(paste(delta,"1")), expression(paste(delta,"1\nadditive")), "msac", "h", "ppf",#
#			expression(iota), "proc", expression(theta), "Xdev")#
#	levels(cm$variable)	<- c( bquote(alpha), bquote(beta), expression(paste(delta,"0")), #
#			expression(paste(delta,"1")), expression(paste(delta,"1\nadditive")), "msac", "h", "ppf",#
#			bquote(iota), "proc", bquote(theta), "Xdev")#
#
	cm$SimNr	<- factor(rep(c(1:10), times=nrow(cm)/10))#
	quartz(width=8.5,height=5)
grid.ls()
grid.ls()
	  p1	<- qplot(corp, value, data=subset(cm, variable!="Xdev"), geom=c("point"), ylab="parameter value", #
		position=position_jitter(h=0), colour=Model)+#
		geom_errorbar(stat="summary",fun.data="mean_cl_normal",aes(colour=Model))+#
		geom_point(stat="summary",fun.data="mean_cl_normal",size=9, aes(colour=Model), shape=8)+#shape=3,#
		geom_hline(aes(yintercept=low))+ geom_hline(aes(yintercept=high))+#
		scale_colour_grey()+ scale_shape(legend=FALSE)+#
		scale_x_discrete(name="", breaks=c(1,2), labels=c("",""))+#
		scale_y_continuous(name="Estimated Parameter Value")+#
		facet_wrap(~variable, scales="free_y", nrow=2) + theme_bw() + # , labeller=label_parsed#
		opts(legend.position=c(0.91,0.3))
grid.ls()
print(p1)
grid.ls()
grob	<- ggplotGrob(p1)
str(grob)
?str
str(grob, max.level=1)
str(grob, max.level=2)
str(grob$children, max.level=2)
str(grob$children, max.level=1)
str(grob$children$plot.title.text.1219, max.level=1)
grob$children$plot.title.text.1219
str(grob$children, max.level=1)
str(grob$children$legends, max.level=1)
grob$children$legends
str(grob, max.level=2)
str(grob$childrenvp, max.level=1)
str(grob$childrenvp, max.level=2)
grid.ls()
