Social Sequence Analysis Expert logo

Social Sequence Analysis Expert

Community
ptreezh
social-sequence-analysis-expert

Social Sequence Analysis expert. Provides sequence alignment, optimal matching, event history analysis, trajectory modeling, and social process visualization. Suitable for life course research, organizational sequences, and sequential data analysis.

Overview

Publisherptreezh
Repositorysscisubagent-skills
Skill namesocial-sequence-analysis-expert
Stars
45
Forks
7
Bundled files
5
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ptreezh on GitHub. Read the source before you install it.

Installation

Install the Social Sequence Analysis Expert AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ptreezh/sscisubagent-skills/tree/main/skills/social-sequence-analysis-expert
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ptreezh/sscisubagent-skills.git /tmp/sscisubagent-skills
mkdir -p .claude/skills
cp -r /tmp/sscisubagent-skills/skills/social-sequence-analysis-expert .claude/skills/social-sequence-analysis-expert
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Social Sequence Analysis Expert in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Social Sequence Analysis Expert on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Social Sequence Analysis Expert is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

-------|----------|------| | 职业轨迹 | 就业状态 | 就业、失业、退休 | | 家庭形成 | 居住状态 | 独居、同居、已婚 | | 教育历程 | 学历状态 | 小学、中学、大学 | | 健康轨迹 | 健康状态 | 健康、慢性病、失能 |

距离度量

最优匹配(Optimal Matching)

原理: 通过插入、删除、替换操作将一个序列转换为另一个序列

操作成本:
- 插入(I): 插入一个状态的成本
- 删除(D): 删除一个状态的成本
- 替换(S): 替换一个状态的成本

距离 = 最小操作成本之和

示例:
序列A: E E W W M
序列B: E W W M M

转换: E→E(0), 删除E(1), W→W(0), W→W(0), M→M(0), 插入M(1)
距离 = 2

替换成本矩阵

状态相似性 → 替换成本

示例(职业状态):
      E    W    M    R
E     0    1    2    2
W     1    0    1    2
M     2    1    0    2
R     2    2    2    0

解读:
- E↔W成本1: 教育和工作相关性高
- E↔M成本2: 教育和管理差距大
- 对角线为0: 相同状态无成本

其他距离度量

方法原理适用场景
汉明距离对应位置差异等长序列
Levenshtein编辑距离一般序列
LCS最长公共子序列模式匹配
子序列距离公共子序列比例稀疏序列

序列描述统计

状态分布

每个时间点的状态分布:

时间点 │ 状态A  状态B  状态C
  1    │  80%    15%    5%
  2    │  60%    30%   10%
  3    │  40%    40%   20%
  ...

转换矩阵

状态转换概率:

     │  E   W   M   R
─────┼────────────────
  E  │ .3  .6  .1  .0
  W  │ .1  .5  .3  .1
  M  │ .0  .1  .6  .3
  R  │ .0  .0  .0 1.0

解读:
- P(E→W)=0.6: 教育后60%进入工作
- P(M→M)=0.6: 管理岗位稳定性高

序列指标

指标公式含义
持续时间状态占用时间状态稳定性
转换次数状态变化次数轨迹复杂性
熵-Σp·log(p)轨迹多样性
索引质量Σp²序列典型性

聚类分析

方法

聚类流程:
1. 计算距离矩阵(OM距离)
2. 选择聚类算法
   ├── 层次聚类: Ward/Complete
   ├── K-medoids: PAM
   └── 混合模型: 潜在类别
3. 确定聚类数
   ├── 轮廓系数
   ├── CH指数
   └── 解释性
4. 解释聚类结果

典型序列提取

聚类后提取代表性序列:

聚类1: "稳定型" (35%)
  典型轨迹: E→W→W→W→R
  
聚类2: "上升型" (28%)  
  典型轨迹: E→W→M→M→R
  
聚类3: "波动型" (22%)
  典型轨迹: E→W→U→W→U→W→R

聚类4: "延迟型" (15%)
  典型轨迹: E→E→W→W→R

(U=失业)

可视化方法

状态分布图(Index Plot)

个体序列展示:

序列1 ████████████████
      EEEEEEEWWWWWWRRR
      
序列2 ████████████████
      EEEEWWWWWMMMRRRR
      
序列3 ████████████████
      EEEWWWUUUWWWRRRR

横轴: 时间
颜色: 状态

转换图

状态转换网络:

      ┌──→ W ──┐
      │    │    ↓
  E ──┤    ↓    M
      │         │
      └────────→ R

箭头宽度 = 转换概率
节点大小 = 状态占比

序列图(Sequence Index Plot)

时间
  │
  │  ████
  │  ████  ████
  │  ████  ████  ████
  │  ████  ████  ████  ████
  └─────────────────────────→ 样本

Python实现

使用TraMineR(R)/seqanalyst(Python)

python
from sequence_analyzer import SequenceData, OM_distance

# 定义序列
sequences = [
    ['E', 'E', 'W', 'W', 'M', 'M', 'R'],
    ['E', 'W', 'W', 'M', 'M', 'M', 'R'],
    ['E', 'E', 'E', 'W', 'W', 'W', 'R'],
]

# 计算距离矩阵
seq_data = SequenceData(sequences, 
                        states=['E', 'W', 'M', 'R'])
dist_matrix = OM_distance(seq_data, 
                          indel=1, 
                          substitution_matrix=cost_matrix)

# 聚类分析
from scipy.cluster.hierarchy import linkage, fcluster
Z = linkage(dist_matrix, method='ward')
clusters = fcluster(Z, t=4, criterion='maxclust')

应用场景

生命历程研究

研究问题: 教育如何影响职业轨迹?

变量:
- 因变量: 职业序列类型
- 自变量: 教育水平、家庭背景
- 控制变量: 性别、年龄、地区

分析步骤:
1. 构建职业序列
2. 聚类识别轨迹类型
3. 回归分析影响因素

社会流动研究

研究问题: 代际流动模式

序列:
- 父代职业状态序列
- 子代职业状态序列

分析方法:
- 序列相似性分析
- 流动表分析
- 路径依赖检验

家庭形成轨迹

研究问题: 家庭形成多样化模式

状态:
S=单身, C=同居, M=已婚, D=离婚, W=丧偶

典型轨迹:
1. 传统型: S→M→M→M
2. 同居型: S→C→M→M
3. 中断型: S→M→D→S→M

使用示例

用户: 分析大学毕业生的职业发展轨迹

AI: 我将执行完整的序列分析:

## 数据概况
- 样本量: 500人
- 追踪期: 毕业5年(60个月)
- 状态: 就业(E)、失业(U)、深造(S)、创业(B)

## 状态分布
月份 │  E   U   S   B
─────┼──────────────
  1  │ 45% 25% 20% 10%
 12  │ 65% 15% 10% 10%
 24  │ 70% 10%  5% 15%
 36  │ 72%  8%  3% 17%
 60  │ 75%  5%  2% 18%

## 聚类结果(4类)
聚类1 "稳定就业型" (42%)
  典型轨迹: E→E→E→E→E
  特征: 快速就业、职业稳定

聚类2 "深造后就业型" (25%)
  典型轨迹: S→S→E→E→E
  特征: 先深造再就业

聚类3 "创业型" (18%)
  典型轨迹: E→B→B→B→B
  特征: 先就业后创业

聚类4 "波动型" (15%)
  典型轨迹: E→U→E→U→E
  特征: 就业不稳定

## 影响因素
| 变量 | 聚类1 | 聚类2 | 聚类3 | 聚类4 |
|------|-------|-------|-------|-------|
| 985高校 | + | + | ns | - |
| 理工科 | + | - | + | ns |
| 实习经历 | + | ns | + | ns |

🚫 绝对禁止原则

使用前必读:以下原则是不可逾越的红线,违反将导致序列分析结论失效。

  1. 禁止忽视时间结构 — 将序列当作无序集合处理,不考虑状态的时间顺序和转换逻辑
  2. 禁止替换成本矩阵无理论依据 — 使用最优匹配(OM)时,替换/插入/删除成本无领域依据,导致距离度量失真
  3. 禁止只看聚类结果不分析序列内容 — 仅报告聚类数量和轮廓系数,而不解读各聚类的实际轨迹含义
  4. 禁止混淆序列相似性与因果关系 — 序列相似不代表有因果关联,需结合回归分析检验
  5. 禁止忽视样本选择性偏倚 — 不考虑样本是否代表目标群体,导致轨迹类型分布估计偏差
  6. 禁止忽视观测间隔不等问题 — 不等间隔观测时使用等间隔假设,导致转换矩阵估计不准确

✅ 质量标准

完整性

  • 必做项清单完成度 ≥ 90%
  • 序列定义说明完整(状态、时间单位)
  • 替换成本矩阵有据可查

方法论

  • 理论框架与数据一致性 ≥ 90%
  • 分析步骤可复现性高
  • 距离度量选择有理论依据

深度

  • 核心维度覆盖 ≥ 80%
  • 典型序列解读完整
  • 影响因素分析深入

🖥️ Python 工具

工具链

#工具名称功能描述
1sequence_builder.py序列构建,支持状态定义、时间单位设置、不等间隔处理
2om_distance_calculator.py最优匹配距离计算,支持自定义替换成本矩阵和插入/删除成本
3trajectory_cluster.py轨迹聚类分析,支持Ward/PAM/K-medoids多方法聚类
4transition_analyzer.py转换矩阵分析,支持时依协变量Cox模型和事件史分析

CLI用法

bash
python tools/sequence_builder.py --input events.csv --output sequences.json
python tools/om_distance_calculator.py --input sequences.json --substitution-matrix costs.csv --output dist_matrix.json
python tools/trajectory_cluster.py --input dist_matrix.json --method ward --n-clusters 4 --output clusters.json

CLI用法

bash
# 社会序列分析推荐使用TraMineR(R)或Python的sequence_analyzer
python -c "print('Social Sequence Analysis: 序列分析与聚类')"

参考文献

  1. Abbott, A. (1995). Sequence analysis: New methods for old ideas. Annual Review of Sociology, 21, 93-113.
  2. Cornwell, B. (2015). Social sequence analysis. In Emerging Trends in the Social and Behavioral Sciences.
  3. Studer, M., & Ritschard, G. (2016). What matters in differences between life trajectories. Sociological Methods & Research, 45(1), 5-48.
  4. Gabadinho, A., et al. (2011). Analyzing and visualizing state sequences in R. Journal of Statistical Software, 40(4), 1-37.

技能版本: 5.0.0
方法论标准: Abbott (1995), Cornwell (2015)
创建时间: 2026-03-15

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Social Sequence Analysis Expert AI skill do?

Social Sequence Analysis expert. Provides sequence alignment, optimal matching, event history analysis, trajectory modeling, and social process visualization. Suitable for life course research, organizational sequences, and sequential data analysis.

Why use Social Sequence Analysis Expert on TypingMind?

Because you install it once and use it with any model. Social Sequence Analysis Expert is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Social Sequence Analysis Expert in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ptreezh/sscisubagent-skills/tree/main/skills/social-sequence-analysis-expert. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Social Sequence Analysis Expert?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Social Sequence Analysis Expert?

As many as you like. As long as a model supports skills, you can use Social Sequence Analysis Expert with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Social Sequence Analysis Expert AI skill free?

Yes. It is published on GitHub by ptreezh under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇