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