add affect[ations] in EMGLLF.c return
[valse.git] / test / generate_test_data / generateRunSaveTest_EMGLLF.R
1 source("EMGLLF.R")
2
3 generateRunSaveTest_EMGLLF = function(n=200, p=15, m=10, k=3, mini=5, maxi=10,
4 gamma=1., lambda=0.5, tau=1e-6)
5 {
6 testFolder = "../data/"
7 dir.create(testFolder, showWarnings=FALSE, mode="0755")
8
9 require(valse)
10 params = valse:::basicInitParameters(n, p, m, k)
11 xy = valse:::generateXYdefault(n, p, m, k)
12
13 #save inputs
14 write.table(as.double(params$phiInit), paste(testFolder,"phiInit",sep=""),
15 row.names=F, col.names=F)
16 write.table(as.double(params$rhoInit), paste(testFolder,"rhoInit",sep=""),
17 row.names=F, col.names=F)
18 write.table(as.double(params$piInit), paste(testFolder,"piInit",sep=""),
19 row.names=F, col.names=F)
20 write.table(as.double(params$gamInit), paste(testFolder,"gamInit",sep=""),
21 row.names=F, col.names=F)
22 write.table(as.integer(mini), paste(testFolder,"mini",sep=""),
23 row.names=F, col.names=F)
24 write.table(as.integer(maxi), paste(testFolder,"maxi",sep=""),
25 row.names=F, col.names=F)
26 write.table(as.double(gamma), paste(testFolder,"gamma",sep=""),
27 row.names=F, col.names=F)
28 write.table(as.double(lambda), paste(testFolder,"lambda",sep=""),
29 row.names=F, col.names=F)
30 write.table(as.double(xy$X), paste(testFolder,"X",sep=""),
31 row.names=F, col.names=F)
32 write.table(as.double(xy$Y), paste(testFolder,"Y",sep=""),
33 row.names=F, col.names=F)
34 write.table(as.double(tau), paste(testFolder,"tau",sep=""),
35 row.names=F, col.names=F)
36 write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
37 row.names=F, col.names=F)
38
39 res = EMGLLF_R(params$phiInit,params$rhoInit,params$piInit,params$gamInit,mini,maxi,
40 gamma,lambda,xy$X,xy$Y,tau)
41
42 #save outputs
43 write.table(as.double(res$phi), paste(testFolder,"phi",sep=""), row.names=F, col.names=F)
44 write.table(as.double(res$rho), paste(testFolder,"rho",sep=""), row.names=F, col.names=F)
45 write.table(as.double(res$pi), paste(testFolder,"pi",sep=""), row.names=F, col.names=F)
46 write.table(as.double(res$LLF), paste(testFolder,"LLF",sep=""), row.names=F, col.names=F)
47 write.table(as.double(res$S), paste(testFolder,"S",sep=""), row.names=F, col.names=F)
48 write.table(as.integer(res$affec), paste(testFolder,"affec",sep=""), row.names=F, col.names=F)
49 }