Skip to content

Commit

Permalink
Small update to the run_lda() function in smallsim_functions.R.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarbo committed Aug 19, 2024
1 parent ceac0f2 commit 12cf5d3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/smallsim_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,15 @@ run_lda <- function (X, fit, numiter = 100, alpha = 1,
var = list(iter.max = 10)))

# Now fit the variational approximation with (i) "beta", the
# log-word frequencies, set to log(F) and (ii) "gamma", the topic
# proportions, set to L.
# log-word frequencies, initialized to log(F) and (ii) "gamma", the
# topic proportions, initialized to L.
#
# Note: It appears that setting the "initialize" option isn't
# strictly needed because it seems to figure out that you want to
# initialize to the provided model automatically (see the "model"
# input argument), but it is helpful to set initialize = "model" to
# make it more clear what we are doing here.
#
F <- normalize.cols(pmax(fit$F,e))
L <- normalize.rows(pmax(fit$L,e))
lda@beta <- t(log(F))
Expand All @@ -116,6 +123,7 @@ run_lda <- function (X, fit, numiter = 100, alpha = 1,
control = list(alpha = alpha,
estimate.alpha = estimate.alpha,
verbose = verbose,
initialize = "model",
em = list(iter.max = numiter,tol = 0),
var = list(iter.max = 20,tol = 0),
keep = 1)))
Expand Down

0 comments on commit 12cf5d3

Please sign in to comment.