99da9bc3a9b6161e35d320650d458b1d9c4fdda0
[valse.git] / test / generate_test_data / generateRunSaveTest_EMGrank.R
1 source("EMGrank.R")
2
3 generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0,
4 rank = c(1,2,4))
5 {
6 tau = 1e-6
7 pi = rep(1.0/k, k)
8 rho = array(dim=c(m,m,k))
9 for(i in 1:k)
10 rho[,,i] = diag(1,m)
11 require(valse)
12 xy = valse:::generateXYdefault(n, p, m, k)
13
14 testFolder = "../data/"
15 dir.create(testFolder, showWarnings=FALSE, mode="0755")
16 #save inputs
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)
25 write.table(as.double(xy$X), paste(testFolder,"X",sep=""),
26 row.names=F, col.names=F)
27 write.table(as.double(xy$Y), paste(testFolder,"Y",sep=""),
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)
33 write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
34 row.names=F, col.names=F)
35
36 res = EMGrank(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank)
37
38 #save output
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)
41 }