skills/54-scdenney-open-science-skills/skills/topic-modeling/SKILL.md
Structural topic modeling: STM spec, topic count, coherence-exclusivity.
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research topic-modelingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
text-classification skill).stm, use plotRemoved() to visualize how many documents and terms are dropped across candidate thresholds before committing to one, then pass it to prepDocuments(). Report the threshold chosen and the counts of terms and documents retained.prevalence = ~ treatment + country (Roberts et al. 2014). For experimental applications, pre-register the prevalence-covariate hypotheses (see the companion pre-registration-writing skill) so that estimateEffect() outputs are confirmatory rather than exploratory by default (Nosek et al. 2018).sageLabels() and interpret with care (Roberts, Stewart & Tingley 2014; 2019).init.type = "Spectral") for reproducibility. Spectral initialization is deterministic on a given machine/BLAS configuration, unlike random initialization which requires multiple runs; cross-machine numerical precision can still produce minor differences, so record the hardware/OS when sharing replication materials (Roberts, Stewart & Tingley 2019).stm package version and R session info for DA-RT-compliant replication.stm, searchK() sweeps over K and returns all four diagnostics at once; selectModel() fits multiple initializations at a fixed K and returns the coherence-exclusivity frontier (useful when spectral initialization is not being used).stm package reports FREX, a weighted harmonic mean of frequency and exclusivity ranks (default weight ω = 0.7). The coherence-FREX frontier identifies models that balance both (Roberts, Stewart & Tingley 2019).findThoughts() or equivalent. Do not interpret topics from word lists alone — the documents provide essential context.estimateEffect(). For experimental data, test whether treatment conditions significantly shift which topics respondents discuss. For cross-national data, test whether topic prevalence differs by country. Plot these effects with confidence intervals (Roberts et al. 2014). When testing many topics against a treatment, report corrections for multiple comparisons (e.g., FDR) alongside uncorrected estimates.permutationTest() (Roberts, Stewart & Tingley 2014; 2019). The function permutes the treatment label and refits the STM, returning a null distribution of topic-level treatment effects against which the observed effect is compared — essentially a randomization inference check for estimateEffect().prepDocuments), number of topics and selection rationale, initialization method, convergence diagnostics (max EM iterations and final variational lower bound), random seed, stm package version, and R session info. For the broader reporting checklist see the companion methods-reporting skill.searchK / selectModel over coherence, FREX/exclusivity, held-out likelihood, residuals) plus substantive interpretabilitysageLabels() inspected when a content covariate is usedfindThoughts()estimateEffect() and reported with confidence intervals; multiple-comparison adjustment reported when testing many topicspermutationTest() run against the treatment covariatetopicCorr())plotRemoved() / prepDocuments retention counts reportedstm version, R session info) available or plannedA minimal STM workflow for a survey experiment in which df holds one row per respondent with columns open_ended_responses (text) and treatment_arm (factor). The four stages — (a) preprocess, (b) sweep K, (c) refit with multiple initializations, (d) estimate treatment effects — map directly onto §§2–5. The four diagnostic functions (searchK, selectModel, permutationTest, topicCorr) should all appear in the final analysis script.
# Minimal STM workflow: survey experiment with open-ended responses.
library(stm)
set.seed(20260418)
# (a) Preprocess and prune rare terms (see §2).
processed <- textProcessor(df$open_ended_responses, metadata = df)
plotRemoved(processed$documents, lower.thresh = seq(1, 20, by = 2))
prepped <- prepDocuments(processed$documents, processed$vocab,
processed$meta, lower.thresh = 5)
# (b) Sweep K over candidate values (coherence, exclusivity, held-out, residuals).
k_search <- searchK(prepped$documents, prepped$vocab,
K = c(5, 10, 15, 20),
prevalence = ~ treatment_arm,
data = prepped$meta, init.type = "Spectral")
plot(k_search)
# (c) At the chosen K, refit with multiple initializations; pick off the frontier.
k_chosen <- 10
candidates <- selectModel(prepped$documents, prepped$vocab, K = k_chosen,
prevalence = ~ treatment_arm, data = prepped$meta,
runs = 20, init.type = "Spectral")
plotModels(candidates)
fit <- candidates$runout[[1]]
# (d) Estimate treatment effects on topic prevalence (§5); then permutationTest / topicCorr.
effects <- estimateEffect(1:k_chosen ~ treatment_arm, fit,
metadata = prepped$meta, uncertainty = "Global")
summary(effects)
tools
Recommend AND run open-source AI tools, agents, Claude Code / Codex skills, and MCP servers for any stage of a literature review — searching, reading, extracting, synthesizing, screening, citation-checking, and paper writing. Use when the user asks "what tool should I use to..." OR "install/run/use <tool> to ..." for research/lit-review work: automating a survey or related-work section, PDF→Markdown extraction for LLMs (MinerU/marker/docling), PRISMA / systematic review (ASReview), citation-backed Q&A over PDFs (PaperQA2), wiring papers into Claude/Cursor via MCP (arxiv/paper-search/zotero servers), or chatting with a Zotero library. Ships a launcher (scripts/litrun.py) that installs each tool in an isolated venv and runs it. Curated catalog of 70+ vetted projects. 支持中英文(用于「文献综述工具选型」与「一键安装/运行」)。
development
Route empirical-research requests through the Auto-Empirical Research Skills catalog when this whole repository is installed as one skill in Codex, CodeBuddy, Claude Code, or another IDE. Use to choose and load the right vendored AERS skill for causal inference, econometrics, replication, data acquisition, manuscript writing, peer review and referee responses, citation checking, de-AIGC editing, or full empirical-paper workflows without reading the entire repository at once.
documentation
Use when the project collects primary data or runs a field, lab, or survey experiment, before the intervention begins — write the pre-analysis plan, size the sample from a power calculation, and register with the AEA RCT Registry. Apply after the design is chosen in aer-identification and before any outcome data are seen.
tools
Guide economists to authoritative data sources with explicit, confirmed data specifications before retrieval; interfaces with Playwright MCP to navigate portals and extract real data, not articles about data.