A structured, dependency-annotated function registry for the social sciences and humanities — the omicverse registry mechanism, ported off AnnData onto a light StudyState vocabulary.
Project description
socialverse
A structured, dependency-annotated function registry for the social sciences and humanities.
socialverse ports the mechanism that makes omicverse's
agent capability work — not its data model. In AI-for-biology, what lets an agent
plan a real analysis without hallucinating the API is ov.registry: every
function is registered with a machine-readable contract (requires / produces /
prerequisites / auto_fix), so an agent queries the registry instead of
guessing. AnnData is only the vocabulary that contract speaks in.
Social data is not commensurable (a survey ≠ a corpus ≠ a network), so there is no
"AnnData for social science" and there never will be. So socialverse keeps the
registry and drops the container: the 12-slot StudyState
is a light vocabulary — not a data matrix — that requires/produces speak in.
The spine is the registry, not the container. Define the vocabulary first, register the federated tools against it, and an agent can plan, chain, verify, and auto-fix.
Install
pip install -e . # minimal (numpy + pandas)
pip install -e ".[full]" # + statsmodels/scipy/networkx/matplotlib to run every chain
pip install -e ".[dev]" # + pytest
Everything domain-specific (linearmodels, spaCy, lxml, pyfixest, python-docx, …) is federated and lazy-imported — a chain degrades gracefully if its backend is absent.
Query the registry (the whole point)
import socialverse as sv
sv.registry.find("双重差分") # fuzzy search (Chinese / English / abbrev / tool name)
sv.registry.get_prerequisites("did") # what does DID require & produce? who satisfies each slot?
sv.registry.resolve_plan("sv.pl.forest") # order the chain to reach a target
Coming from R / Stata / SPSS?
Search by the command name you already know — every function carries py-<command>
aliases drawn from Stata, R, and SPSS (the py- marks the Python reimplementation):
sv.registry.get("py-lmer") # R lme4::lmer -> sv.tl.multilevel
sv.registry.get("py-stcox") # Stata stcox -> sv.tl.survival
sv.registry.get("py-svyglm") # R survey::svyglm -> sv.tl.survey_estimate
sv.registry.find("mixed") # bare command also fuzzy-matches
164 such aliases across the registry map mixed/lmer, stcox/coxph, svyset/
svydesign, sem/lavaan, mirt, rdrobust, ergm, truthTable, lagsarlm,
oaxaca, … onto their socialverse equivalents (see socialverse/_compat_aliases.py).
社科方法 × 三大统计软件(Stata / SPSS / R)× socialverse 映射表
下表把社会科学最常用的 30 个方法家族逐一对齐到 Stata / SPSS / R 的原生命令,给出 socialverse(sv.*)的等价实现,并为每一族附一篇真实近年顶刊/权威期刊的使用案例(优先复用 15 篇顶刊调研样本;其余经 WebSearch 核实的真实论文,个别方法用「教材经典」兜底)。
一、定量 / 因果计量
| 方法家族 | 算法 / 统计量 | Stata | SPSS | R | socialverse | 顶刊使用案例(真实论文) |
|---|---|---|---|---|---|---|
| DiD(双向固定效应) | 处理组×处理后交互,组/时固定效应 | didregress / xtdidregress |
— | did::att_gt,fixest::feols |
sv.tl.did |
Medicaid 扩张使近老年年死亡率降约 9.4% —— Miller, Johnson & Wherry (QJE 2021) |
| 事件研究(动态 DiD) | 相对处理期的 leads/lags 系数 | eventdd / event_plot |
— | fixest::sunab |
sv.tl.event_study + sv.pl.event_study_plot |
事件研究招牌图刻画枪击后逐期选举效应 —— Hassell & Holbein (APSR 2025) |
| 平行趋势检验 | 处理前趋势平坦性诊断 | (手搭) | — | HonestDiD,pretrends |
sv.tl.parallel_trends |
平行趋势与 Rambachan-Roth 敏感性裁决现代 DiD 工具箱 —— Hassell & Holbein (APSR 2025) |
| RDD(断点回归) | 断点处局部多项式跳跃 | rdrobust / rdplot |
— | rdrobust::rdrobust |
sv.tl.rdd + sv.pl.rdd_plot |
险胜选举断点识别当选者特征的下游效应 —— Marshall (AJPS 2024) |
| 合成控制 | 加权对照拟合反事实路径 | synth / synth_runner |
— | Synth,augsynth,gsynth |
sv.tl.synthetic_control + sv.pl.synth_path |
合成控制评估洛杉矶大型养老机构条例的前后效应 —— Frochen, Rodnyansky & Ailshire (2024) |
| 工具变量 / 2SLS | 份额×供给外生变异两阶段 | ivregress / ivreg2 |
2SLS |
AER::ivreg,fixest |
sv.tl.iv_regress |
Shift-share IV 识别大迁徙对代际流动的因果影响 —— Derenoncourt (AER 2022) |
| 倾向得分匹配 / PSM | 倾向得分近邻匹配平衡协变量 | teffects psmatch / psmatch2 |
FUZZY(扩展) |
MatchIt::matchit |
sv.tl.psm |
(教材经典:MatchIt LaLonde 就业培训项目 ATT 估计,Ho–Imai–King–Stuart 2011 JSS) |
| 中介分析 | 直接/间接效应 bootstrap 分解 | mediate / sgmediation |
PROCESS macro | mediation::mediate |
sv.tl.mediation |
预注册实验+PROCESS bootstrap:来源→传输感→信念的间接效应 —— Chu & Liu (Journal of Communication 2024) |
| 广义线性模型 GLM | 连接函数+指数族似然 | glm / logit / poisson |
GENLIN / LOGISTIC |
stats::glm |
sv.tl.glm |
OLS→家庭FE→儿童FE 三层递进估计手足数与发展 —— Yu & Yan (ASR 2023) |
| 多项 Logit | 无序多类别对数几率 | mlogit |
NOMREG |
nnet::multinom |
sv.tl.mlogit |
多项 logit 分析健康/就业与生活满意度类别 —— Predictors of Life Satisfaction in U.S. Adults (2024, NHIS) |
| 有序 Logit | 比例几率累积对数几率 | ologit / oprobit |
PLUM |
MASS::polr |
sv.tl.ologit |
广义有序 logit:COPD 患者报告更差自评健康的九倍几率 —— Quality of Life Research (2025) |
| 边际效应 | AME / MEM 后估计边际量 | margins / marginsplot |
— | marginaleffects::slopes |
sv.tl.margins |
边际效应刻画兄弟姐妹数对发展的边际递减 —— Yu & Yan (ASR 2023) |
| 固定/随机效应面板 | 组内变换 / 混合效应 | xtreg / reghdfe / mixed |
MIXED |
lme4::lmer,fixest::feols |
sv.tl.multilevel |
个体嵌套班级多层回归识别移民网络分离效应 —— Zhao (ASR 2025) |
| Oaxaca-Blinder 分解 | 禀赋 vs 回报的组间差异分解 | oaxaca |
— | oaxaca |
sv.tl.decomposition |
Oaxaca 分解显示禀赋差异解释性别薪酬差 8–40% —— Hedija (AIP Conf. Proc. 2023) |
二、测量与调查
| 方法家族 | 算法 / 统计量 | Stata | SPSS | R | socialverse | 顶刊使用案例(真实论文) |
|---|---|---|---|---|---|---|
| 验证性因子分析 CFA | 潜变量测量模型拟合 | sem(latent) |
Amos | lavaan::cfa |
sv.tl.cfa |
MFQ-2 六因子跨 25 文化验证性因子结构 —— Atari et al. (JPSP 2023) |
| 探索性因子分析 EFA | 公因子提取+旋转 | factor / rotate |
FACTOR |
psych::fa |
sv.tl.efa |
EFA+ESEM 提取道德基础量表潜结构 —— Atari et al. (JPSP 2023) |
| 结构方程 SEM | 测量+结构路径联合估计 | sem / gsem |
Amos | lavaan::sem |
sv.tl.sem |
全潜变量路径模型检验道德判断法则网络 —— Atari et al. (JPSP 2023) |
| 信度 α/ω | 内部一致性系数 | alpha |
RELIABILITY |
psych::alpha / omega |
sv.tl.reliability |
α/ω 信度评估跨文化道德基础子量表 —— Atari et al. (JPSP 2023) |
| 项目反应理论 IRT | 1/2/3PL、GRM 潜特质校准 | irt 2pl / irt grm |
— | mirt,ltm |
sv.tl.irt |
展开式 IRT 模型校准 TPQue5 人格问卷题目 —— Mitropoulou, Zampetakis & Tsaousis (Evaluation Review 2024) |
| 评分者间信度 | κ / Krippendorff's α | — | CROSSTABS KAPPA |
irr::kripp.alpha |
sv.tl.interrater |
(教材经典:Krippendorff's α 评估内容分析多编码者一致性,Krippendorff 2004《Content Analysis》) |
| 复杂抽样设计 | 分层/整群/权重设计声明 | svyset |
CSPLAN |
survey::svydesign |
sv.tl.design_survey |
声明 NHANES strata/PSU/weights 抽样设计 —— Nguyen et al. (Lancet Healthy Longevity 2021) |
| 设计加权估计 | 设计一致均值/回归/分位 | svy: mean/regress |
CSGLM / CSLOGISTIC |
survey::svyglm |
sv.tl.survey_estimate + sv.pl.survey_dist |
加权估计 27 项生理指标与全因死亡关联 —— Nguyen et al. (Lancet Healthy Longevity 2021) |
| 生存分析(KM / Cox) | 风险集偏似然 / 生存曲线 | stcox / sts |
COXREG / KM |
survival::coxph,survfit |
sv.tl.survival + sv.pl.km_curve |
设计加权 Cox PH 估计生理指标死亡风险 HR —— Nguyen et al. (Lancet Healthy Longevity 2021) |
三、网络 / 空间 / 质性 / 人文
| 方法家族 | 算法 / 统计量 | Stata | SPSS | R | socialverse | 顶刊使用案例(真实论文) |
|---|---|---|---|---|---|---|
| 网络描述(中心性/社群) | 邻接矩阵度量与社群划分 | nwcommands |
— | igraph,sna |
sv.tl.build_network |
由好友提名重建班级网络并测网络分离 —— Zhao (ASR 2025) |
| ERGM | 网络子结构 MCMC 极大似然 | — | — | ergm::ergm |
sv.tl.ergm |
ERGM 揭示极端天气应急协作网络的形成机制 —— Humanit. Soc. Sci. Commun. (2026) |
| SAOM(SIENA) | 行动者导向连带-行为共演 | — | — | RSiena::siena07 |
sv.tl.saom |
(教材经典:Teenage Friends & Lifestyle 青少年友谊-饮酒共演 SIENA 分析,Snijders–Steglich–Schweinberger 教程) |
| Moran's I / LISA | 全局/局部空间自相关 | spatgsa |
— | spdep::localmoran |
sv.tl.spatial_autocorr + sv.pl.moran_scatter |
Moran's I + LISA 识别交通事故高发空间热点 —— Traffic Collisions in Montgomery, Maryland (2024) |
| 空间回归(SAR/SEM/SDM) | 空间滞后/误差极大似然 | spregress |
— | spatialreg::lagsarlm |
sv.tl.spatial_regression |
SAR/SEM/SDM 建模萨格勒布住房价格空间依赖 —— Spatial Dependence in Urban Housing Prices: Zagreb (Real Estate 2024) |
| QCA / fsQCA | 真值表布尔最小化 | fuzzy |
— | QCA::minimize |
sv.tl.qca |
fsQCA 揭示腐败×教育×不平等的投票率充分组态 —— Crime, Law & Social Change (2023) |
| 生命表 / 人口分解 | 多状态转移递推与分量分解 | ltable |
SURVIVAL |
demography::lifetable |
sv.tl.life_table + sv.tl.decomposition |
多状态生命表分解健康预期寿命的结构 vs 转移分量 —— Shen, Riffe, Payne & Canudas-Romo (Demography 2023) |
| 质性编码(主题/扎根) | 灵活编码+引文-码结构 | — | — | — | sv.tl.code_themes + sv.tl.trace_quotes |
106 访谈灵活编码 access/privacy/relationality 主题 —— O'Quinn et al. (Qualitative Sociology 2024) |
| 反身性备忘录 | 女性主义反身性写作追踪 | — | — | — | sv.tl.reflexive_memo |
远程访谈中以女性主义反身性备忘录追踪研究者立场 —— O'Quinn et al. (Qualitative Sociology 2024) |
| 文体计量 / 作者归属 | Delta 距离+PCA/聚类 | — | — | stylo::stylo |
sv.tl.stylometry |
文体计量做非作者聚类,揭示体裁/时代信号 —— Päpcke et al. (DSH 2023) |
| 文本校勘 | 见证本对齐与变异检出 | — | — | (CollateX 外部) | sv.tl.philology_collate |
CollateX 对贝克特现代手稿做计算机辅助校勘 —— Bleeker & Van Hulle (Beckett Digital Manuscript Project) |
| TEI 编码 | XML 语义标记数字学术版 | — | — | — | sv.tl.tei_encode + sv.pp.ocr_tei |
TEI 编码构建古北欧散文数字学术版标准案例 —— DHNB (2023, Digital Editions of Old Norse Prose) |
| Bourdieu 场域分析 | 资本/惯习/场域位置对应 | — | — | — | sv.gov / sv.tl(理论透镜) |
潜类别刻画中学生学术惯习与家庭资本的场域关系 —— Moll (Sociological Inquiry 2024) |
| Foucault 话语分析 | 权力-知识话语规训解读 | — | — | — | 理论透镜(foucault_discourse) |
Foucault 治理术透镜分析高等教育中的权力-知识 —— EHASS (2024, Foucault & Governmentality in Higher Education) |
| Weber 理想型 | 抽象纯粹类型建构比较 | — | — | — | 理论透镜(weber_ideal_type) |
韦伯官僚制理想型作比较历史分析基准 —— "Recontextualizing Max Weber's Ideal Type" (2024) |
统计:共写入 32 行(定量/因果计量 14 · 测量与调查 9 · 网络/空间/质性/人文 9),覆盖 socialverse sv.tl 全部主力方法函数。
引文核实:29 篇为真实可核实论文(15 篇来自顶刊调研样本直接复用;14 篇经 WebSearch 核实的真实近年论文/权威数字人文项目);3 处为「教材经典」兜底(PSM=MatchIt/LaLonde、评分者间信度=Krippendorff α、SAOM=Teenage Friends & Lifestyle SIENA 经典范例)——这三族的近两年顶刊「使用案例」检索未返回可锚定的单篇应用论文,故用学界公认的经典范例代替,绝不杜撰引文。
get_prerequisites("did") returns the same shape as omicverse's, so OmicOS's
registry_lookup tool can consume a socialverse registry unchanged:
{
"function": "socialverse.tl.did",
"required_functions": ["parallel_trends"],
"requires": {"design": ["panel_id","time","treatment"], "identification": ["parallel_trends"]},
"produces": {"models": ["did","twfe"], "diagnostics": ["robustness"]},
"auto_fix": "escalate",
"satisfied_by": {"identification.parallel_trends": ["parallel_trends"], "...": ["declare_design"]}
}
Run a chain — grounded, not guessed
import socialverse as sv
from socialverse import datasets
st = sv.StudyState()
st.write("estimand", "target", "ATT") # the one user-supplied input
df = datasets.load_did_panel()
sv.pp.ingest(st, data=df)
sv.pp.declare_design(st, panel_id="firm_id", time="year",
treatment="treat_post", first_treated="first_treated")
sv.tl.parallel_trends(st) # must pass before DID is called causal
sv.tl.did(st) # TWFE ATT + cluster-robust SE
sv.pl.forest(st) # publication figure
print(st.summary()) # slots populated + a full provenance ledger
Call sv.tl.did(st) on an unprepared state and the registry refuses, telling you
exactly which slot is missing and which function produces it — the leiden-before-
neighbors guard, ported to social science:
socialverse.tl.did cannot run — unmet requires:
- identification.parallel_trends (produced by: parallel_trends)
Query registry.get_prerequisites(...) or registry.resolve_plan(...) to plan the chain.
The StudyState vocabulary (12 slots)
The social-science analog of AnnData's obs / var / obsm / uns. Every contract
speaks only in these slots (validated at registration):
| slot | holds |
|---|---|
sources |
raw inputs: datasets, corpora, manuscripts, .bib, scans |
design |
sampling frame, weights, strata, PSU, panel_id, time, treatment/timing |
variables |
codebook, outcome, exposure, controls, scales, constructs |
corpus |
documents, coding units, dfm, TEI |
codes |
qualitative codebook, coded segments, themes, theme map |
estimand |
ATT / prevalence / association + target population (user-given) |
identification |
DAG, parallel-trends, IV validity, exclusion, positivity |
models |
DID/TWFE, event-study, weighted regression, topic model, network, field map |
diagnostics |
pretrend, balance, robustness matrix, reliability α, sensitivity |
evidence |
claim→quote/citation links, quote-trace index, verified .bib, provenance |
governance |
IRB, consent, PII-redaction status, data-use licence, AI-use disclosure |
artifacts |
figures, tables, DOCX/PDF, TEI-XML, apparatus, reproducible scripts |
Namespaces (two axes, like omicverse)
- phase:
sv.pp(prepare) ·sv.tl(analyze) ·sv.pl(plot/render) - social-science axes:
sv.gov(governance gates) ·sv.lit(literature & citation)
Governance is a first-class axis — in social science, ethics/licence/PII/AI-disclosure gate almost every analysis, so they are registered functions with their own contracts, not an afterthought.
Method coverage (64 registered functions)
Each family is a real, tested implementation (pure numpy/scipy/statsmodels, with the champion backend lazy-imported when present) — see docs/CONTRACT_CARDS.md.
- measurement: EFA (exploratory factor analysis), scale reliability (Cronbach α / McDonald ω / ICC), inter-rater reliability (Cohen/Fleiss κ, Krippendorff α) — complements the existing CFA/SEM/IRT
- regression base: GLM (
glmcovers OLS / logit / probit / Poisson), multinomial (mlogit), ordered (ologit), average marginal effects (margins) - causal / quasi-experimental: TWFE-DiD, event-study, RDD (local-linear), synthetic control, IV / 2SLS (
iv_regress), propensity-score matching / IPW (psm), causal mediation (mediation) - econometrics: 8-step replication pipeline (emits reproducible R/Stata scripts)
- complex survey: design-based weighted estimation (strata/PSU/weights)
- psychometrics: CFA, SEM (path fallback), IRT (2PL) — reliability, fit indices
- longitudinal: multilevel/HLM (MixedLM), survival/event-history (Cox PH, KM)
- spatial: Moran's I / LISA, spatial-lag (SAR) regression with impacts
- networks: descriptives, ERGM (MPLE), SAOM co-evolution (descriptive)
- set-theoretic: fsQCA (truth-table + Quine-McCluskey minimization)
- demography: life tables, Kitagawa / Oaxaca decomposition
- text / DH: corpus building, topic coding, OCR→TEI, philology collation, stylometry (Burrows's Delta)
- qualitative: reflexive thematic analysis, quote-traceability, theory lenses
- governance / literature: ethics/licence/AI-disclosure gates · search, citation-verify, review
Built-in analysis chains (auto-derived from requires ↔ produces)
- causal:
ingest → declare_design → parallel_trends → did → event_study → forest - quasi:
ingest → rdd → rdd_plot·synthetic_control → synth_path - survey:
ingest → declare_design → design_survey → survey_estimate → survey_dist - psychometrics:
ingest → cfa → sem·irt - longitudinal:
ingest → multilevel·survival → km_curve - spatial:
ingest → spatial_autocorr → spatial_regression → moran_scatter - qualitative:
build_corpus → redact_pii → code_themes → trace_quotes → reflexive_memo → theme_map - text / philology:
ocr_tei → build_corpus → philology_collate → tei_encode·stylometry → dendrogram - networks:
build_network → ergm·saom - QCA / demography:
qca·life_table → decomposition - literature / citation:
search_free → zotero_bridge → citation_manage → verify_citations → manuscript_review - governance (cross-cutting):
data_use_check · ethics_check · redact_pii · ai_use_disclosure
How it maps to OmicOS
This package is the concrete instantiation of the humanities_social domain's
registry table: its 54 registered functions cover all 26 humanities_social skills
plus the quantitative method families a social-science审稿 pipeline needs.
An OmicOS agent points its registry_lookup at sv.registry and gets the same
grounding it gets from ov.registry in the bio domain — query, plan, chain, auto-fix.
Design notes
- Registry first, tools second. Contracts are the spine; implementations are federated wrappers over the field's best tools (statsmodels, linearmodels, pyfixest, networkx, spaCy, lxml …), never rewrites.
- Provenance is built in. Every registered call records params + slots touched into
state.provenance— the reproducible/auditable "evidence spine". - Fail-soft. A missing optional backend degrades one chain, never the import.
Licence: CC-BY-4.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file
socialverse-0.2.5.tar.gz.File metadata
File hashes
cfc787c4692679b74f636324c9fac3ef1b126b46fc73fa59d36ffc69a53a16201876169fdd55325ad92a3fe6740fcabae3d2079c90f0de274d4b517c98da05bb3b30031cfc19d922e790c67fa7609905See more details on using hashes here.