fit.sentopicmodel {sentopics} | R Documentation |
Estimate a topic model
Description
This function is used to estimate a topic model created by
LDA()
, JST()
or rJST()
. In essence, this function iterates a Gibbs
sampler MCMC.
Usage
## S3 method for class 'sentopicmodel'
fit(
object,
iterations = 100,
nChains = 1,
displayProgress = TRUE,
computeLikelihood = TRUE,
seed = NULL,
...
)
## S3 method for class 'multiChains'
fit(
object,
iterations = 100,
nChains = NULL,
displayProgress = TRUE,
computeLikelihood = TRUE,
seed = NULL,
...
)
Arguments
object |
|
iterations |
the number of iterations by which the model should be fitted. |
nChains |
if set above 1, the model will be fitted multiple times
from various starting positions. Latent variables will be re-initialized if
|
displayProgress |
if |
computeLikelihood |
if set to |
seed |
for reproducibility, a seed can be provided. |
... |
arguments passed to other methods. Not used. |
Value
a sentopicmodel
of the relevant model class if nChains
is
unspecified or equal to 1. A multiChains
object if nChains
is greater
than 1.
Parallelism
When nChains > 1
, the function can take advantage of
future.apply::future_lapply (if installed) to spread the computation over
multiple processes. This requires the specification of a parallel strategy
using future::plan()
. See the examples below.
See Also
Examples
model <- rJST(ECB_press_conferences_tokens)
fit(model, 10)
# -- Parallel computation --
require(future.apply)
future::plan("multisession", workers = 2) # Set up 2 workers
fit(model, 10, nChains = 2)
future::plan("sequential") # Shut down workers