Multilevel Modeling Expert logo

Multilevel Modeling Expert

Community
ptreezh
multilevel-modeling-expert

Multilevel Modeling expert. Provides hierarchical data analysis, random effects estimation, cross-level interaction modeling, and multilevel mediation analysis. Suitable for organizational research, educational evaluation, and nested data analysis.

Overview

Publisherptreezh
Repositorysscisubagent-skills
Skill namemultilevel-modeling-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 Multilevel Modeling 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/multilevel-modeling-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/multilevel-modeling-expert .claude/skills/multilevel-modeling-expert
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Multilevel Modeling 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 Multilevel Modeling 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 Multilevel Modeling 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.

---|------|------| | 固定效应 | γ | 总体平均效应 | | 随机效应 | u | 组间变异 | | 残差 | r | 个体层误差 | | 方差成分 | τ², σ² | 随机效应方差 |

模型构建策略

自下而上策略

步骤1: 空模型(Null Model)
Yij = γ00 + u0j + rij
├── 计算ICC
├── 评估组效应
└── 决定是否需要多层模型

步骤2: 随机截距模型
Yij = γ00 + γ10Xij + u0j + rij
├── 加入层1预测变量
├── 组均值中心化
└── 评估固定效应

步骤3: 随机斜率模型
Yij = γ00 + γ10Xij + u0j + u1jXij + rij
├── 检验斜率方差
├── χ²检验或LR检验
└── 决定是否保留随机斜率

步骤4: 跨层交互模型
β1j = γ10 + γ11Wj + u1j
├── 加入层2预测变量
├── 检验跨层交互
└── 解释调节效应

中心化策略

三种中心化选择

策略公式效果
原始尺度Xij组间+组内混合效应
组均值中心化Xij - X̄j纯组内效应
总均值中心化Xij - X̄减少共线性

最佳实践

场景: 研究学生努力(X)对成绩(Y)的影响

1. 学生努力(Xij) → 组均值中心化
   → "班级内相对努力程度"

2. 班级平均努力(X̄j) → 总均值中心化
   → "班级整体努力水平(情境效应)"

3. 两个变量同时纳入:
   Yij = γ00 + γ10(Xij-X̄j) + γ01(X̄j-X̄) + ...
   → 分解组内效应(γ10)和组间效应(γ01)

模型比较

信息准则

指标原则说明
AIC越小越好惩罚复杂度
BIC越小越好更严格惩罚
-2LL越小越好似然比检验

似然比检验

模型比较: 
-2ΔLL = -2(LL_reduced - LL_full)

χ²检验:
df = df_full - df_reduced
p < .05 → 完整模型更优

增长曲线模型

纵向数据多层模型

层1(时间层):
Yti = π0i + π1i(Time)ti + π2i(Time²)ti + eti

层2(个体层):
π0i = β00 + β01Zi + r0i  (初始状态)
π1i = β10 + β11Zi + r1i  (线性变化率)
π2i = β20 + β21Zi + r2i  (二次变化率)

时间编码:
- 年龄编码: 实际年龄
- 事件编码: 相对于事件时间
- 0点编码: 有意义的时间零点

软件实现

R语言

r
library(lme4)
# 随机截距模型
model1 <- lmer(Y ~ X + (1|group), data)

# 随机斜率模型
model2 <- lmer(Y ~ X + (X|group), data)

# 跨层交互
model3 <- lmer(Y ~ X*W + (X|group), data)

模型诊断

诊断项方法问题
正态性Q-Q图随机效应/残差分布
异方差残差vs拟合值方差齐性
影响点Cook's D异常值影响
多重共线性VIF预测变量相关性

效应量

方差解释

条件R² = (固定效应方差 + 随机效应方差) / 总方差

伪R²(Proportional Reduction in Variance):
伪R² = (τ²_null - τ²_model) / τ²_null

解释:
- 层1伪R²: 层1方差减少比例
- 层2伪R²: 层2方差减少比例

使用示例

用户: 研究学校氛围对学生成绩的影响

AI: 我将构建多层模型:

## 数据结构
层1: 学生(n=2000)
层2: 学校(n=50)

## 空模型
Yij = γ00 + u0j + rij
ICC = 0.18 (18%方差在学校层)
→ 需要多层模型

## 模型构建
模型1(随机截距):
成绩ij = γ00 + γ10(努力ij) + u0j + rij

模型2(随机斜率):
成绩ij = γ00 + γ10(努力ij) + u0j + u1j(努力ij) + rij
χ²检验: p < .05 → 保留随机斜率

模型3(跨层交互):
β1j = γ10 + γ11(学校氛围j) + u1j
γ11 = 0.25, p < .05
→ 学校氛围调节努力对成绩的影响

## 结果解释
在积极氛围学校,努力对成绩的影响更强

🖥️ Python 工具

工具链

#工具名称功能描述
1—本技能暂无专用Python工具

CLI用法

bash
# 多层模型建议使用R语言lme4包或Python的statsmodels
python -c "import statsmodels.api as sm; print('statsmodels ready for HLM')"

🚫 绝对禁止原则

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

  1. 禁止跳过研究伦理审查 — 未获IRB批准的实证研究不得用于发表
  2. 禁止捏造或篡改数据 — 任何形式的数据造假均违反学术伦理
  3. 禁止忽视研究局限性 — 必须在论文中诚实报告研究局限
  4. 禁止剽窃他人研究成果 — 必须正确引用所有参考来源
  5. 禁止选择性报告结果 — 阴性结果同样需要报告
  6. 禁止使用不匹配的分析方法 — 必须根据研究问题选择合适方法

参考文献

  1. Raudenbush, S.W., & Bryk, A.S. (2002). Hierarchical Linear Models. 2nd ed.
  2. Hox, J.J., Moerbeek, M., & van de Schoot, R. (2018). Multilevel Analysis. 3rd ed.
  3. Snijders, T.A.B., & Bosker, R.J. (2012). Multilevel Analysis. 2nd ed.
  4. Gelman, A., & Hill, J. (2007). Data Analysis Using Regression and Multilevel Models.

技能版本: 5.0.0
方法论标准: Raudenbush & Bryk (2002)
创建时间: 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 Multilevel Modeling Expert AI skill do?

Multilevel Modeling expert. Provides hierarchical data analysis, random effects estimation, cross-level interaction modeling, and multilevel mediation analysis. Suitable for organizational research, educational evaluation, and nested data analysis.

Why use Multilevel Modeling Expert on TypingMind?

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

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

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

Is the Multilevel Modeling 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 👇