Longitudinal Analysis Expert logo

Longitudinal Analysis Expert

Community
ptreezh
longitudinal-analysis-expert

Longitudinal Analysis expert. Provides panel data modeling, growth curve estimation, time-series analysis, attrition handling, and repeated measures design. Suitable for developmental research, panel studies, and temporal trend analysis.

Overview

Publisherptreezh
Repositorysscisubagent-skills
Skill namelongitudinal-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 Longitudinal 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/longitudinal-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/longitudinal-analysis-expert .claude/skills/longitudinal-analysis-expert
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Longitudinal 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 Longitudinal 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 Longitudinal 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.

---|--------|------| | 因果推断 | 弱 | 强 | | 变化测量 | 无 | 有 | | 个体差异 | 无法控制 | 可控制 | | 成本 | 低 | 高 | | 样本流失 | 无 | 有 |

纵向数据类型

类型1: 面板数据
时间点固定 → 相同间隔测量

类型2: 加速纵向设计
不同年龄队列 → 重叠部分连接

类型3: 事件史数据
事件发生时间 → 持续时间分析

类型4: 强度数据
观察间隔不等 → 连续时间建模

核心分析方法

1. 重复测量ANOVA

模型: Yij = μ + αi + βj + (αβ)ij + εij

问题:
- 球形假设(sphericity)
- 缺失数据敏感性
- 假设过多

适用: 少量时间点、完整数据

2. 潜在增长模型(LGM)

基本模型:
Yti = π0i + π1i(Time)ti + π2i(Time²)ti + εti

个体参数:
π0i = β00 + β01Zi + ζ0i  (截距因子)
π1i = β10 + β11Zi + ζ1i  (斜率因子)
π2i = β20 + β21Zi + ζ2i  (曲线因子)

解释:
- 截距因子: 初始状态
- 斜率因子: 变化速度
- 曲线因子: 非线性变化

3. 交叉滞后模型

时间点1         时间点2         时间点3
   X1 ───────────→ X2 ───────────→ X3
   │              │               │
   ↓              ↓               ↓
   Y1 ←─────────── Y2 ←─────────── Y3
   │              │
   └───→ Y2       └───→ Y3

路径含义:
- 自回归: X1→X2, Y1→Y2 (稳定性)
- 交叉滞后: X1→Y2, Y1→X2 (因果关系)
- 同期相关: X1↔Y1 (共享方差)

4. 事件史分析

风险函数: h(t) = lim[Pr(t ≤ T < t+Δt | T ≥ t)/Δt]

生存函数: S(t) = Pr(T ≥ t)

Cox比例风险模型:
h(t|X) = h0(t) × exp(β'X)

解释:
- h(t): 在时间t发生事件的瞬时风险
- h0(t): 基线风险函数
- exp(β): 风险比(HR)

时间效应建模

时间编码策略

编码方式特点适用场景
原始时间实际测量时间发展研究
0起点有意义的起点干预研究
中心化减少共线性多项式模型
年龄基准生物年龄发展心理学

轨迹形状

线性: Y = π0 + π1t
      ↓
单调增/减

二次: Y = π0 + π1t + π2t²
      ↓
先增后减/先减后增

分段: Y = π0 + π1t1 + π2t2
      ↓
不同阶段不同斜率

渐近: Y = α - (α-π0)e^{-βt}
      ↓
趋近渐近线

缺失数据处理

缺失数据机制

类型符号特点处理方法
完全随机MCAR与所有变量无关可忽略
随机MAR与观测变量相关FIML/MI
非随机MNAR与未观测变量相关模式混合

处理方法

方法1: 全信息最大似然(FIML)
- 使用所有可用数据
- 适合MAR
- SEM软件默认

方法2: 多重插补(MI)
- 生成多个完整数据集
- 合并分析结果
- 灵活性高

方法3: 模式混合模型
- 对MNAR建模
- 敏感性分析
- 模型依赖性强

软件实现

R语言示例

r
# 潜在增长模型(lavaan)
library(lavaan)
model <- '
  i =~ 1*t1 + 1*t2 + 1*t3
  s =~ 0*t1 + 1*t2 + 2*t3
  i ~ predictor
  s ~ predictor
'
fit <- growth(model, data)

# Cox回归(survival)
library(survival)
cox_model <- coxph(Surv(time, event) ~ X, data)

质量控制

样本流失分析

流失模式分析:
1. 比较流失者vs保留者
   - 基线特征比较
   - t检验/卡方检验

2. 流失预测模型
   - 流失与变量的关系
   - 判断MAR vs MNAR

3. 敏感性分析
   - 最佳/最差情景
   - 估计稳健性

检验力分析

纵向设计检验力:
- 时间点数量
- 样本规模
- 效应量大小
- 相关性结构

经验法则:
时间点 ≥ 3 → 可估计斜率
时间点 ≥ 4 → 可估计曲率
样本量 ≥ 10N参数

使用示例

用户: 分析学生学业成绩3年追踪数据

AI: 我建议采用潜在增长模型:

## 数据特征
- 时间点: 3年(6、7、8年级)
- 样本: N=500学生
- 变量: 数学成绩、社会经济地位

## 模型构建
模型1: 无条件增长模型
Yti = π0i + π1i(Time)ti + εti

结果:
- 截距均值 β00 = 70 (初始水平)
- 斜率均值 β10 = 3 (年均增长)
- 截距方差 τ00 = 45 (个体差异显著)
- 斜率方差 τ11 = 4 (增长差异显著)

模型2: 条件增长模型
π0i = β00 + β01(SES)i + ζ0i
π1i = β10 + β11(SES)i + ζ1i

结果:
- SES对初始水平: β01 = 5.2***
- SES对增长速度: β11 = 0.8(n.s.)

结论:
高SES学生起点更高,但增长速度无差异

🚫 绝对禁止原则

使用前必读:以下原则是不可逾越的红线,违反将导致纵向研究结论失效。

  1. 禁止忽视缺失数据机制 — 不检验MCAR/MAR/MNAR,直接删除缺失值或使用不恰当的处理方法,导致估计偏倚
  2. 禁止混淆相关与因果 — 将时间上的前后顺序等同于因果关系,忽略遗漏变量偏倚和反向因果
  3. 禁止忽视时间编码 — 不说明时间变量的编码方式(原始/0起点/中心化),导致模型不可复现
  4. 禁止只看均值轨迹 — 仅报告组均值变化而忽视个体差异轨迹(离散性),导致个体异质性被掩盖
  5. 禁止忽视样本流失分析 — 不检验流失者与保留者的基线差异,导致结论无法推广
  6. 禁止时间点不足仍建模变化 — 时间点<3时声称分析"变化轨迹"或"发展趋势",导致模型过度拟合

✅ 质量标准

完整性

  • 必做项清单完成度 ≥ 90%
  • 缺失数据机制检验报告完整
  • 样本流失分析完整

方法论

  • 理论框架与数据一致性 ≥ 90%
  • 分析步骤可复现性高(含时间编码说明)
  • 模型比较有据可查

深度

  • 核心维度覆盖 ≥ 80%
  • 个体差异轨迹分析(不仅是均值)
  • 敏感性分析完整

🖥️ Python 工具

工具链

#工具名称功能描述
1lgm_analyzer.py潜在增长模型,支持无条件/条件增长模型、轨迹形状检验
2cross_lag_analyzer.py交叉滞后模型,支持随机截距交叉滞后面板模型(RICLPM)
3survival_analyzer.py事件史分析,支持Kaplan-Meier、Cox回归、风险比计算
4missing_data_handler.py缺失数据处理,支持MCAR/MAR/MNAR检验、FIML、多重插补

CLI用法

bash
python tools/lgm_analyzer.py --input panel_data.csv --time t1,t2,t3 --output growth_model.json
python tools/cross_lag_analyzer.py --input data.csv --variables X,Y --output cross_lag.json
python tools/survival_analyzer.py --input event_data.csv --time time --event status --output survival.json

参考文献

  1. Singer, J.D., & Willett, J.B. (2003). Applied Longitudinal Data Analysis.
  2. Bollen, K.A., & Curran, P.J. (2006). Latent Curve Models.
  3. Little, T.D. (2013). Longitudinal Structural Equation Modeling.
  4. Allison, P.D. (2014). Event History and Survival Analysis. 2nd ed.

技能版本: 5.0.0
方法论标准: Singer & Willett (2003)
创建时间: 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 Longitudinal Analysis Expert AI skill do?

Longitudinal Analysis expert. Provides panel data modeling, growth curve estimation, time-series analysis, attrition handling, and repeated measures design. Suitable for developmental research, panel studies, and temporal trend analysis.

Why use Longitudinal Analysis Expert on TypingMind?

Because you install it once and use it with any model. Longitudinal 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 Longitudinal Analysis Expert in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ptreezh/sscisubagent-skills/tree/main/skills/longitudinal-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 Longitudinal 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 Longitudinal Analysis Expert?

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

Is the Longitudinal 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 👇