Skip to content

Commit 681e5c1

Browse files
author
Eric Weine
committed
made code more memory efficient
1 parent 7222d45 commit 681e5c1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

R/fit.R

+3-6
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,10 @@ fit_glmpca_pois <- function(
263263

264264
update_indices_f <- sort(setdiff(1:K,fixed_f))
265265

266-
FF_to_update <- FF_test
267-
#browser()
268-
269266
# now, I just need to project the results back
270267
update_factors_faster_parallel(
271268
L_T = t(res$fit$LL),
272-
FF = FF_to_update,
269+
FF = FF_test,
273270
M = as.matrix(res$fit$LL[update_indices_f,,drop = FALSE] %*% Y_test),
274271
update_indices = update_indices_f - 1,
275272
num_iter = 1000,
@@ -280,7 +277,7 @@ fit_glmpca_pois <- function(
280277

281278
# now, I need to reconstruct FF, and hopefully compute the log-likelihood
282279
FF[, train_idx] <- res$fit$FF
283-
FF[, test_idx] <- FF_to_update
280+
FF[, test_idx] <- FF_test
284281
res$fit$FF <- FF
285282

286283
if (inherits(Y,"sparseMatrix")) {
@@ -291,7 +288,7 @@ fit_glmpca_pois <- function(
291288
loglik_func <- lik_glmpca_pois_log
292289
}
293290

294-
test_loglik <- loglik_func(Y_test,res$fit$LL,FF_to_update,test_loglik_const)
291+
test_loglik <- loglik_func(Y_test,res$fit$LL,FF_test,test_loglik_const)
295292
res$loglik <- res$loglik + test_loglik
296293

297294
}

0 commit comments

Comments
 (0)