still some problems with LLF
[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,
5 rank = c(1,2,4))
6 {
7 tau = 1e-6
8 pi = rep(1.0/k, k)
9 rho = array(dim=c(m,m,k))
10 for(i in 1:k)
11 rho[,,i] = diag(1,m)
12 xy = 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 = valse::EMGrank(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank,fast=FALSE)
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 }