fix/improve selectVariables.R
[valse.git] / test / generate_test_data / generateRunSaveTest_EMGrank.R
CommitLineData
31463ab8 1source("EMGrank.R")
825cf55f 2
c3bc4705
BA
3generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0,
4 rank = c(1,2,4))
5{
f1b906da 6 tau = 1e-6
f1b906da 7 pi = rep(1.0/k, k)
ef67d338
BA
8 rho = array(dim=c(m,m,k))
9 for(i in 1:k)
f1b906da 10 rho[,,i] = diag(1,m)
9ade3f1b 11 require(valse)
ef67d338 12 xy = valse:::generateXYdefault(n, p, m, k)
c3bc4705 13
825cf55f 14 testFolder = "../data/"
ef67d338 15 dir.create(testFolder, showWarnings=FALSE, mode="0755")
f1b906da 16 #save inputs
c3bc4705
BA
17 write.table(as.double(rho), paste(testFolder,"rho",sep=""),
18 row.names=F, col.names=F)
19 write.table(as.double(pi), paste(testFolder,"pi",sep=""),
20 row.names=F, col.names=F)
21 write.table(as.integer(mini), paste(testFolder,"mini",sep=""),
22 row.names=F, col.names=F)
23 write.table(as.integer(maxi), paste(testFolder,"maxi",sep=""),
24 row.names=F, col.names=F)
ef67d338 25 write.table(as.double(xy$X), paste(testFolder,"X",sep=""),
c3bc4705 26 row.names=F, col.names=F)
ef67d338 27 write.table(as.double(xy$Y), paste(testFolder,"Y",sep=""),
c3bc4705
BA
28 row.names=F, col.names=F)
29 write.table(as.double(tau), paste(testFolder,"tau",sep=""),
30 row.names=F, col.names=F)
31 write.table(as.integer(rank), paste(testFolder,"rank",sep=""),
32 row.names=F, col.names=F)
825cf55f 33 write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
c3bc4705
BA
34 row.names=F, col.names=F)
35
f7244815 36 res = EMGrank_R(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank)
c3bc4705 37
f1b906da 38 #save output
c3bc4705
BA
39 write.table(as.double(res$phi), paste(testFolder,"phi",sep=""), row.names=F,col.names=F)
40 write.table(as.double(res$LLF), paste(testFolder,"LLF",sep=""), row.names=F,col.names=F)
f1b906da 41}