stmCorrViz(mod, file_out, documents_raw=NULL, documents_matrix=NULL, title="STM Model", clustering_threshold=FALSE, search_options = list(range_min=.05, range_max=5, step=.05), labels_number=7, display=TRUE, verbose=FALSE)
STM
object from stm.
prepDocuments
function.
If FALSE
, a grid search is performed to find valid thresholds is performed using findThreshold
. The valid clustering threshold resulting in a median level of tree complexity is chosen.
clustering_threshold
is FALSE
.
hclust
.
Then the hierarchy is written out to a JSON object using stmJSON
. Finally D3.js is used to create
an interactive visualization.The visualization is built as a HTML page, and as such requires a web browser for inspection. The function does not return and object, but writes HTML output to disk.
The visualization takes the form of an indented tree. The leaves of the tree correspond to topics.
The leaf nodes are grouped in topic clusters. This allows the model to be visualized at differing levels of aggregation.
The function uses the D3.js library for visualization purpose.
The visualization is largely built on top of Mike Bostock's Collapsible Indented Tree block. A nested JSON structure representing the hierarchical model is produced using the stmJSON
function.
Margaret E. Roberts, Brandon M. Stewart and Dustin Tingley (2014). stm: R Package for Structural Topic Models.
stmJSON
data(immigration_perceptions)
stmCorrViz(immigration_perceptions$model, "corrviz.html",
documents_raw=immigration_perceptions$raw_documents,
documents_matrix=immigration_perceptions$documents_matrix)
Run the code above in your browser using DataLab