'initSmallEM.R'
'EMGrank.R'
'EMGLLF.R'
- 'EMGrank_R.R'
- 'EMGLLF_R.R'
'generateXY.R'
'A_NAMESPACE.R'
#' @include generateXY.R
-#' @include EMGLLF_R.R
-#' @include EMGrank_R.R
#' @include EMGLLF.R
#' @include EMGrank.R
#' @include initSmallEM.R
if (!fast)
{
# Function in R
- return (EMGLLF_R(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau))
+ return (.EMGLLF_R(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau))
}
# Function in C
}
# R version - slow but easy to read
-EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau)
+.EMGLLF_R = function(phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,tau)
{
# Matrix dimensions
n = dim(X)[1]
if (!fast)
{
# Function in R
- return (EMGrank_R(Pi, Rho, mini, maxi, X, Y, tau, rank))
+ return (.EMGrank_R(Pi, Rho, mini, maxi, X, Y, tau, rank))
}
# Function in C
}
# R version - slow but easy to read
-EMGrank_R = function(Pi, Rho, mini, maxi, X, Y, tau, rank)
+.EMGrank_R = function(Pi, Rho, mini, maxi, X, Y, tau, rank)
{
#matrix dimensions
n = dim(X)[1]
source("helper.R")
+library(valse)
generateRunSaveTest_EMGLLF = function(n=200, p=15, m=10, k=3, mini=5, maxi=10,
gamma=1., lambda=0.5, tau=1e-6)
testFolder = "../data/"
dir.create(testFolder, showWarnings=FALSE, mode="0755")
- require(valse)
params = basicInitParameters(n, p, m, k)
xy = generateXYdefault(n, p, m, k)
write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
row.names=F, col.names=F)
- res = EMGLLF_R(params$phiInit,params$rhoInit,params$piInit,params$gamInit,mini,maxi,
- gamma,lambda,xy$X,xy$Y,tau)
+ res = valse::EMGLLF(params$phiInit,params$rhoInit,params$piInit,params$gamInit,mini,
+ maxi,gamma,lambda,xy$X,xy$Y,tau,fast=FALSE)
#save outputs
- write.table(as.double(res$phi), paste(testFolder,"phi",sep=""), row.names=F, col.names=F)
- write.table(as.double(res$rho), paste(testFolder,"rho",sep=""), row.names=F, col.names=F)
- write.table(as.double(res$pi), paste(testFolder,"pi",sep=""), row.names=F, col.names=F)
- write.table(as.double(res$llh), paste(testFolder,"llh",sep=""), row.names=F, col.names=F)
- write.table(as.double(res$S), paste(testFolder,"S",sep=""), row.names=F, col.names=F)
- write.table(as.integer(res$affec), paste(testFolder,"affec",sep=""), row.names=F, col.names=F)
+ write.table(as.double(res$phi),paste(testFolder,"phi",sep=""),row.names=F,col.names=F)
+ write.table(as.double(res$rho),paste(testFolder,"rho",sep=""),row.names=F,col.names=F)
+ write.table(as.double(res$pi),paste(testFolder,"pi",sep=""),row.names=F,col.names=F)
+ write.table(as.double(res$llh),paste(testFolder,"llh",sep=""),row.names=F,col.names=F)
+ write.table(as.double(res$S),paste(testFolder,"S",sep=""),row.names=F,col.names=F)
+ write.table(as.integer(res$affec),paste(testFolder,"affec",sep=""),row.names=F,col.names=F)
}
source("helper.R")
+library(valse)
generateRunSaveTest_EMGrank = function(n=200, p=15, m=10, k=3, mini=5, maxi=10, gamma=1.0,
rank = c(1,2,4))
rho = array(dim=c(m,m,k))
for(i in 1:k)
rho[,,i] = diag(1,m)
- require(valse)
xy = generateXYdefault(n, p, m, k)
testFolder = "../data/"
write.table(as.integer(c(n,p,m,k)), paste(testFolder,"dimensions",sep=""),
row.names=F, col.names=F)
- res = EMGrank_R(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank)
+ res = valse::EMGrank(pi,rho,mini,maxi,xy$X,xy$Y,tau,rank,fast=FALSE)
#save output
- write.table(as.double(res$phi), paste(testFolder,"phi",sep=""), row.names=F,col.names=F)
- write.table(as.double(res$LLF), paste(testFolder,"LLF",sep=""), row.names=F,col.names=F)
+ write.table(as.double(res$phi),paste(testFolder,"phi",sep=""),row.names=F,col.names=F)
+ write.table(as.double(res$LLF),paste(testFolder,"LLF",sep=""),row.names=F,col.names=F)
}