ソースメモ

  • 次元で丸くするかボンフェロニか
df1<-1
df2s<-1:5
pdf1<-10^(-9:-1)
pp<-matrix(0,length(df2s),length(pdf1))
for(i in 1:length(df2s)){
	df2<-df2s[i]

	probs<-pchisq(qchisq(pdf1,df1,lower.tail=FALSE),df2,lower.tail=FALSE)
	plot(probs)
	probs

	plot(probs/pdf1)
	pp[i,]<-probs/pdf1
}
matplot(t(pp),type="l")
  • さらにただのメモ
Ns<-1000
ptype<-c(0,1)
p<-sample(ptype,Ns,replace=TRUE)

Nm<-5
gtype<-c(0,1,2)
g0<-sample(gtype,Ns,replace=TRUE)
g<-matrix(rep(g0,Nm),Ns,Nm)
rt<-0.05
for(i in 2:Nm){
	for(j in 1:Ns){
		if(runif(1)<rt){
			g[j,i]<-sample(gtype,1)
		}
	}
}
#g<-matrix(sample(gtype,Nm*Ns,replace=TRUE),nrow=Ns)

O<-matrix(c(p,(p-1)*(-1)),nrow=2,byrow=TRUE)
O

Sp<-RegularSpherize(O)

W<-matrix(0,Nm,length(O))
for(i in 1:Nm){
	W[i,]<-c(g[,i],rep(0,Ns))
}

W
df <- (length(O[1, ]) - 1) * (length(O[, 1]) - 1)
bothside<-TRUE
Tiis <- matrix(0, Nm, df)
for (i in 1:Nm) {
	Tiis[i, ] <- TestDf1(O, matrix(W[i, ], nrow = length(O[,1]), byrow = TRUE), Sp= Sp, simple = TRUE)$Tiist
}
if (bothside) {
	Tiis <- rbind(Tiis, -Tiis)
}
#Kv<-Tiis[1,]
Kv<-apply(Tiis[1:Nm,],2,sum)
Kv<-Kv/sqrt(sum(Kv^2))
Kv<-c(1,rep(0,df-1))
Ks<-1:6
CheckDists<-sqrt(qchisq(10^(-8),df=1,lower.tail=FALSE))
CheckDists<-c(5)
CheckDist<-sqrt(Ns)
Ks<-CheckDist
nperm<-10000

pout<-SpherePower(df=df,Kv=Kv,Ks=Ks,CheckDists=CheckDists,Tiis=Tiis,nperm=nperm)
plot(pout$Ks,pout$p.out)

image(1-cor(g))

gmt<-GeneralMatrixTest(O=O,Sp=Sp,W=W,power=TRUE)
df1<-1
df2s<-1:5
pdf1<-10^(-9:-1)
pp<-matrix(0,length(df2s),length(pdf1))
for(i in 1:length(df2s)){
	df2<-df2s[i]

	probs<-pchisq(qchisq(pdf1,df1,lower.tail=FALSE),df2,lower.tail=FALSE)
	plot(probs)
	probs

	plot(probs/pdf1)
	pp[i,]<-probs/pdf1
}
matplot(t(pp),type="l")