-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticNetSML.R
36 lines (31 loc) · 1023 Bytes
/
elasticNetSML.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
elasticNetSML <-
function(Y,X,Missing,B,Verbose = 0){
M = nrow(Y);
N = ncol(Y);
if(Verbose>=0) cat("\telastic net SML;",M, "Nodes, ", N , "samples; Verbose: ", Verbose, "\n\n")
f = matrix(1,M,1);
stat = rep(0,6);
#dyn.load("elasticSMLv1.dll")
tStart = proc.time();
output<-.C("mainSML_adaEN",
Y = as.double(Y),
X = as.double(X),
M = as.integer(M),
N = as.integer(N),
Missing = as.integer(Missing),
B = as.double(B),
f = as.double(f),
stat = as.double(stat),
verbose = as.integer(Verbose),
package = "sparseSEM");
tEnd = proc.time();
simTime = tEnd - tStart;
#dyn.unload("elasticSMLv1.dll")
if(Verbose>=0) cat("\t computation time:", simTime[1], "sec\n");
Bout = matrix(output$B,nrow= M, ncol = M, byrow = F);
fout = matrix(output$f,nrow= M, ncol = 1, byrow = F);
stat = matrix(output$stat,nrow = 6,ncol = 1, byrow = F);
SMLresult <- list(Bout,fout,stat,simTime[1]);
names(SMLresult) <-c("weight","F","statistics","simTime")
return(SMLresult)
}