ワンクリックで
topic-modeling
Structural topic modeling: STM spec, topic count, coherence-exclusivity.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Structural topic modeling: STM spec, topic count, coherence-exclusivity.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Scaffold or audit an entire research project repository organized around its source library. Use whenever the user is starting, structuring, organizing, or reviewing a whole project — "set up a research repo", "how should I structure/organize this project", "initialize my sources folder", "new paper or literature-review project", "audit my repo structure", "is my sources folder set up right", "check my project layout". Builds the full tree from the sources spine outward — sources/{og,md,unprocessed}, references.bib, a PDF→Markdown convert script (OpenDataLoader PDF), a process-source intake command, CLAUDE.md/AGENTS.md, .gitignore, .venv — plus the analysis, manuscript, and review folders; or audits an existing repo and reports what is present, partial, or missing. NOT for intaking or converting a single PDF (use process-source) or building a publication replication package (use replication-package).
LLM token logprobs and calibration: per-decision confidence, ECE, Brier, reliability diagrams, low-confidence triage.
LLM council/panel voting: multi-model coders, consensus rules, inter-rater agreement (kappa, alpha), correlated-error diagnostics.
Compare OCR systems before a bulk run: candidate set, stratified ground truth, CER/WER, normalization, per-language and per-stratum accuracy.
Fact-check a manuscript's claims against the cited sources themselves: locate each source's knowledge-base Markdown file and verify the in-text claim is actually supported. Runs a pre-flight gate that refuses unless a per-source Markdown knowledge base exists and is clean (PDFs converted via process-source); then runs citation-check; then audits claim support, overclaiming, direction, scope, and misattribution.
Audit citation existence and fabrication risk, in-text/reference parity, DOIs, claim support, and style.
| name | topic-modeling |
| description | Structural topic modeling: STM spec, topic count, coherence-exclusivity. |
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 RANDOM initializations; pick off the
# frontier. Do not pass init.type = "Spectral" here: spectral init is
# deterministic, so all runs would be identical and the frontier degenerate.
k_chosen <- 10
candidates <- selectModel(prepped$documents, prepped$vocab, K = k_chosen,
prevalence = ~ treatment_arm, data = prepped$meta,
runs = 20, init.type = "LDA")
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)