From: Benjamin Auder Date: Mon, 16 Dec 2019 14:47:39 +0000 (+0100) Subject: Remove weights from reports scripts + first naive attempt to optimize computeW X-Git-Url: https://git.auder.net/js/current/app_dev.php/css/rpsls.js?a=commitdiff_plain;h=074c721aa587d45c4f7ef10f8a28fdc09273d31a;p=morpheus.git Remove weights from reports scripts + first naive attempt to optimize computeW --- diff --git a/pkg/R/optimParams.R b/pkg/R/optimParams.R index c42e6c5..13aec83 100644 --- a/pkg/R/optimParams.R +++ b/pkg/R/optimParams.R @@ -122,7 +122,7 @@ setRefClass( dd <- d + d^2 + d^3 M <- Moments(θ) Omega <- matrix( .C("Compute_Omega", - X=as.double(X), Y=as.double(Y), M=as.double(M), + X=as.double(X), Y=as.integer(Y), M=as.double(M), pn=as.integer(n), pd=as.integer(d), W=as.double(W), PACKAGE="morpheus")$W, nrow=dd, ncol=dd ) MASS::ginv(Omega) @@ -257,7 +257,7 @@ setRefClass( else if (!is.numeric(θ0$b) || length(θ0$b) != K || any(is.na(θ0$b))) stop("θ0$b: length K, no NA") # TODO: stopping condition? N iterations? Delta <= epsilon ? - for (loop in 1:10) + for (loop in 1:2) { op_res = constrOptim( linArgs(θ0), .self$f, .self$grad_f, ui=cbind( diff --git a/pkg/src/functions.c b/pkg/src/functions.c index 1f35585..feea3ad 100644 --- a/pkg/src/functions.c +++ b/pkg/src/functions.c @@ -58,7 +58,59 @@ void Moments_M3(double* X, double* Y, int* pn, int* pd, double* M3) // W = 1/N sum( t(g(Zi,theta)) g(Zi,theta) ) // with g(Zi, theta) = i-th contribution to all moments (size dim) - real moments -void Compute_Omega(double* X, double* Y, double* M, int* pn, int* pd, double* W) +//void Compute_Omega(double* X, int* Y, double* M, int* pn, int* pd, double* W) +//{ +// int n=*pn, d=*pd; +// int dim = d + d*d + d*d*d; +// //double* W = (double*)malloc(dim*dim*sizeof(double)); +// +// // (Re)Initialize W: +// for (int j=0; jout_${n}_${link}_${d}_${weights} 2>&1 - done + R --slave --args N=$N n=$n nc=$nc d=$d link=$link out_${n}_${link}_${d}_${weights} 2>&1 done done - -#for d in 2 5; do -# for n in 5000 10000 100000 500000 1000000; do -# for link in "logit" "probit"; do -# R --slave --args N=$N n=$n nc=$nc d=$d link=$link out_$n$link$d 2>&1 -# done -# done -#done