fixing attempt: LLF size in src/adapters/EMGLLF seemed wrong
[valse.git] / test / generateRunSaveTest_EMGrank.R
CommitLineData
086ca318 1source("helper.R")
a3105972 2library(valse)
825cf55f 3
c3bc4705
BA
4generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0,
5 rank = c(1,2,4))
6{
f1b906da 7 tau = 1e-6
f1b906da 8 pi = rep(1.0/k, k)
ef67d338
BA
9 rho = array(dim=c(m,m,k))
10 for(i in 1:k)
f1b906da 11 rho[,,i] = diag(1,m)
321e13a9 12 xy = 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
a3105972 36 res = valse::EMGrank(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank,fast=FALSE)
c3bc4705 37
f1b906da 38 #save output
a3105972
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}