f6a331456f48de43817269192e3423d3568d6fa2
[valse.git] / test / generateRunSaveTest_EMGrank.R
1 source("helper.R")
2 library(valse)
3
4 generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0, rank = c(1,2,4))
5 {
6 eps = 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 xy = generateXYdefault(n, p, m, k)
12
13 testFolder = "./data/"
14 dir.create(testFolder, showWarnings=FALSE, mode="0755")
15 #save inputs
16 write.table(as.double(Pi), paste(testFolder,"Pi",sep=""),
17 row.names=F, col.names=F)
18 write.table(as.double(Rho), paste(testFolder,"Rho",sep=""),
19 row.names=F, col.names=F)
20 write.table(as.integer(mini), paste(testFolder,"mini",sep=""),
21 row.names=F, col.names=F)
22 write.table(as.integer(maxi), paste(testFolder,"maxi",sep=""),
23 row.names=F, col.names=F)
24 write.table(as.double(xy$X), paste(testFolder,"X",sep=""),
25 row.names=F, col.names=F)
26 write.table(as.double(xy$Y), paste(testFolder,"Y",sep=""),
27 row.names=F, col.names=F)
28 write.table(as.double(eps), paste(testFolder,"eps",sep=""),
29 row.names=F, col.names=F)
30 write.table(as.integer(rank), paste(testFolder,"rank",sep=""),
31 row.names=F, col.names=F)
32 write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
33 row.names=F, col.names=F)
34
35 res = valse::EMGrank(Pi,Rho,mini,maxi,xy$X,xy$Y,eps,rank,fast=FALSE)
36
37 #save output
38 write.table(as.double(res$phi),paste(testFolder,"phi",sep=""),row.names=F,col.names=F)
39 write.table(as.double(res$LLF),paste(testFolder,"LLF",sep=""),row.names=F,col.names=F)
40 }