Adjustments for CRAN upload
[valse.git] / test / test_EMGLLF.R
... / ...
CommitLineData
1library(valse)
2testFolder = "data/"
3
4# NOTE: R typing is really terrible. as.double as.matrix ...and so on; don't remove.
5
6#get inputs
7npmk = as.matrix(read.table(paste(testFolder,"dimensions",sep="")))
8n = npmk[1]; p=npmk[2]; m=npmk[3]; k=npmk[4]
9phiInit = array(as.double(as.matrix(read.table(paste(testFolder,"phiInit",sep="")))), dim=c(p,m,k))
10rhoInit = array(as.double(as.matrix(read.table(paste(testFolder,"rhoInit",sep="")))), dim=c(m,m,k))
11piInit = as.double(as.matrix(read.table(paste(testFolder,"piInit",sep="")))[,])
12gamInit = matrix(as.double(as.matrix(read.table(paste(testFolder,"gamInit",sep="")))), n,k)
13mini = as.integer(as.matrix(read.table(paste(testFolder,"mini",sep="")))[1])
14maxi = as.integer(as.matrix(read.table(paste(testFolder,"maxi",sep="")))[1])
15gamma = as.double(as.matrix(read.table(paste(testFolder,"gamma",sep="")))[1])
16lambda = as.double(as.matrix(read.table(paste(testFolder,"lambda",sep="")))[1])
17X = matrix(as.double(as.matrix(read.table(paste(testFolder,"X",sep="")))), n,p)
18Y = matrix(as.double(as.matrix(read.table(paste(testFolder,"Y",sep="")))), n,m)
19eps = as.double(as.matrix(read.table(paste(testFolder,"eps",sep="")))[1])
20
21#get outputs
22phi = array(as.double(as.matrix(read.table(paste(testFolder,"phi",sep="")))), dim=c(p,m,k))
23rho = array(as.double(as.matrix(read.table(paste(testFolder,"rho",sep="")))), dim=c(m,m,k))
24pi = as.double(as.matrix(read.table(paste(testFolder,"pi",sep="")))[,])
25llh = as.double(as.matrix(read.table(paste(testFolder,"llh",sep="")))[1])
26S = array(as.double(as.matrix(read.table(paste(testFolder,"S",sep="")))), dim=c(p,m,k))
27affec = as.double(as.matrix(read.table(paste(testFolder,"affec",sep="")))[,])
28
29res = valse::EMGLLF(
30 phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,eps,fast=TRUE)
31
32#compare outputs
33nd=7 #number of digits
34print( all(round(phi,nd) == round(res$phi,nd)) )
35print( all(round(rho,nd) == round(res$rho,nd)) )
36print( all(round(pi,nd) == round(res$pi,nd)) )
37print( all(round(llh,nd) == round(res$llh,nd)) )
38print( all(round(S,nd) == round(res$S,nd)) )
39print( all(affec == res$affec) )