X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=reports%2Faccuracy.R;h=9a9d21d10b445e4c1e2d9d8250d96c08058c1909;hb=5af71d43f3f2dba21c6667939fcff88923af3b7b;hp=6f322bf685999590653f344a99105b9bab7bb564;hpb=38c65767eb0c8c5a7ad6025471f56dbaffc68e6e;p=morpheus.git diff --git a/reports/accuracy.R b/reports/accuracy.R index 6f322bf..9a9d21d 100644 --- a/reports/accuracy.R +++ b/reports/accuracy.R @@ -10,14 +10,15 @@ optimBeta <- function(N, n, p, beta, b, link, ncores) K <- ncol(fargs$beta) M <- computeMoments(fargs$X, fargs$Y) mu <- computeMu(fargs$X, fargs$Y, list(K=K, M=M)) - op <- optimParams(fargs$X, fargs$Y, K, fargs$link, M) + op <- optimParams(fargs$X, fargs$Y, K, fargs$link, M, 1) #only 1 OpenMP core x_init <- list(p=rep(1/K,K-1), beta=mu, b=rep(0,K)) res2 <- NULL tryCatch({ res2 <- do.call(rbind, op$run(x_init)) }, error = function(e) {}) res2 - }, + } + , # flexmix function(fargs) { library(flexmix) @@ -28,12 +29,12 @@ optimBeta <- function(N, n, p, beta, b, link, ncores) tryCatch({ fm <- flexmix( cbind(V1, 1-V1) ~ .-V1, data=dat, k=K, model = FLXMRglm(family = binomial(link = link)) ) - p <- mean(fm@posterior[["scaled"]][,1]) + pf <- mean(fm@posterior[["scaled"]][,1]) out <- refit(fm) beta_b <- sapply( seq_len(K), function(i) { as.double( out@components[[1]][[i]][,1] ) } ) - res2 <- rbind(p, beta_b[2:nrow(beta_b),], beta_b[1,]) + res2 <- rbind(pf, beta_b[2:nrow(beta_b),], beta_b[1,]) }, error = function(e) { res2 <- NA })