Data Analysisのロゴ

Data Analysis

コミュニティ
HaipingXu
data-analysis

This skill should be used when the user asks to "run data analysis", "analyze this dataset", "regress Y on X", "run the main regressions", "produce tables and figures", "end-to-end analysis", "write analysis script", "set up panel regression", "exploratory data analysis", or "produce publication-ready output". Provides end-to-end data analysis workflow for social science research in Python (primary) or Stata, from data loading through publication-ready tables and figures.

概要

公開者HaipingXu
リポジトリsocial-science-claude-scholar
スキル名data-analysis
スター
26
フォーク
5
同梱ファイル
指示のみ
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    HaipingXuがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルData AnalysisをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/HaipingXu/social-science-claude-scholar/tree/main/skills/data-analysis
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HaipingXu/social-science-claude-scholar.git /tmp/social-science-claude-scholar
mkdir -p .claude/skills
cp -r /tmp/social-science-claude-scholar/skills/data-analysis .claude/skills/data-analysis
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでData Analysisを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にData Analysisを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Data Analysisは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Data Analysis Workflow — Social Science Research

End-to-end data analysis: load, explore, analyze, and produce publication-ready output. Primary language is Python (transitioning from Stata); Stata workflows are also supported.

Input: Dataset path or description of analysis goal (e.g., "regress log wages on education with individual fixed effects using PSID panel 2000-2020").


Constraints

  • Use relative paths everywhere — no hardcoded absolute paths
  • Set seed once at top for all stochastic operations
  • Save all scripts to scripts/ with descriptive names
  • Save all outputs (figures, tables, processed data) to output/
  • Follow coding-style.md for Python file structure

Workflow Phases

Phase 1: Setup

Python setup:

python
# ============================================================
# [Descriptive Title]
# Purpose: [What this script does]
# Inputs:  [Data files]
# Outputs: [Figures, tables, parquet/pickle files]
# ============================================================

import random
import numpy as np
import pandas as pd
from pathlib import Path

# Set seed
SEED = 42
random.seed(SEED)
np.random.seed(SEED)

# Paths
ROOT = Path(__file__).parent.parent
DATA = ROOT / "data"
OUTPUT = ROOT / "output"
(OUTPUT / "figures").mkdir(parents=True, exist_ok=True)
(OUTPUT / "tables").mkdir(parents=True, exist_ok=True)

Stata setup:

stata
clear all
set more off
set seed 42

global root  "/path/to/project"  // SET THIS
global data  "$root/data"
global out   "$root/output"

Phase 2: Exploratory Data Analysis

Generate diagnostic outputs before running regressions:

  • Summary statistics: means, SDs, min/max, missingness
  • Distributions: histograms for key variables
  • Time trends: if panel data, plot key variables over time
  • Treatment/control balance: compare groups before treatment
  • Correlation: between outcome and main predictors

Save all EDA figures to output/figures/eda/.

Phase 3: Main Analysis

Python — panel regression (linearmodels / pyfixest):

python
# Fixed effects regression with clustered SE
from pyfixest.estimation import feols

# Baseline
m1 = feols("log_wage ~ educ | ind_id + year", data=df, vcov={"CRV1": "state"})

# With controls
m2 = feols("log_wage ~ educ + exp + exp2 | ind_id + year", data=df, vcov={"CRV1": "state"})

print(m1.summary())
print(m2.summary())

Python — DID with staggered adoption (pyfixest):

python
from pyfixest.estimation import feols
from pyfixest.report import etable

# Two-way FE (baseline, biased under staggered)
twfe = feols("y ~ i(rel_time, ref=-1) | unit + year", data=df, vcov={"CRV1": "unit"})

# Sun & Abraham (2021) heterogeneity-robust
sa = feols("y ~ sunab(cohort, rel_time) | unit + year", data=df, vcov={"CRV1": "unit"})

Stata — equivalent:

stata
reghdfe log_wage educ, absorb(ind_id year) cluster(state)
estimates store m1

reghdfe log_wage educ exp c.exp#c.exp, absorb(ind_id year) cluster(state)
estimates store m2

Phase 4: Publication-Ready Output

Regression tables — Python:

python
from pyfixest.report import etable

# Export to LaTeX
etable([m1, m2, m3],
       file="output/tables/table1.tex",
       digits=3,
       coef_fmt="b (se)")

Figures — Python (ggplot-style with plotnine):

python
from plotnine import ggplot, aes, geom_point, geom_line, theme_bw, labs, ggsave

fig = (ggplot(df_plot, aes(x="year", y="estimate", ymin="ci_low", ymax="ci_high"))
       + geom_point()
       + geom_line()
       + theme_bw()
       + labs(x="Year", y="Coefficient Estimate", title="Event Study"))

ggsave(fig, "output/figures/event_study.pdf", width=7, height=5)
ggsave(fig, "output/figures/event_study.png", width=7, height=5, dpi=300)

Save objects for reuse:

python
import pickle

with open("output/reg_results.pkl", "wb") as f:
    pickle.dump({"m1": m1, "m2": m2}, f)

Phase 5: Quality Check

Before finalizing:

  1. Verify script runs top-to-bottom without errors
  2. Check: Are SEs clustered at the right level? Justify in a comment.
  3. Check: Is the effect size economically meaningful? Add a sentence.
  4. Check: Are all output files labeled and self-contained?
  5. Apply quality-gates scoring (target ≥ 80)

Common Analysis Patterns

Event Study / DID Pre-Trends

python
# Plot coefficients from dynamic DID
twfe_coefs = twfe.coef().reset_index()
twfe_coefs["t"] = twfe_coefs["Coefficient"].str.extract(r"rel_time::(-?\d+)").astype(float)
# Plot with CI bands — see Phase 4 for plotnine code

IV / 2SLS

python
from pyfixest.estimation import feols

# First stage + IV
iv = feols("y ~ x2 | id + year | x1 ~ z1", data=df, vcov={"CRV1": "state"})
print(iv.first_stage())  # F-statistic

RDD

python
from rdrobust import rdrobust, rdplot

rdd = rdrobust(y=df["outcome"], x=df["running"], c=0)
rdplot(y=df["outcome"], x=df["running"], c=0)

Stata-to-Python Translation Reference

StataPython (pyfixest/linearmodels)Notes
reghdfe y x, absorb(id year) cluster(g)feols("y ~ x | id + year", vcov={"CRV1": "g"})Check if df-adjustment differs
areg y x, absorb(id) cluster(g)feols("y ~ x | id", vcov={"CRV1": "g"})Equivalent
ivreg2 y (x=z), cluster(g)feols("y ~ 1 | id | x ~ z", vcov={"CRV1": "g"})First stage F-stat: iv.first_stage()
bootstrap, reps(999): reg y xresample + loopMatch seed, reps, bootstrap type
estout m1 m2 using t.texetable([m1, m2], file="t.tex")pyfixest ≥ 0.18

Important

  • Reproduce, don't guess. If the user specifies a regression, run exactly that specification.
  • Show your work. Print summary statistics before jumping to regressions.
  • Check for issues. Look for multicollinearity, outliers, treatment overlap.
  • Comment identification logic. Each regression should have a 1-2 line comment explaining what variation is being exploited and what threat is being addressed.

よくある質問

AIスキル「Data Analysis」では何ができますか?

This skill should be used when the user asks to "run data analysis", "analyze this dataset", "regress Y on X", "run the main regressions", "produce tables and figures", "end-to-end analysis", "write analysis script", "set up panel regression", "exploratory data analysis", or "produce publication-ready output". Provides end-to-end data analysis workflow for social science research in Python (primary) or Stata, from data loading through publication-ready tables and figures.

TypingMindでData Analysisを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Data Analysisはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにData Analysisをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/HaipingXu/social-science-claude-scholar/tree/main/skills/data-analysisを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Data Analysisを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Data Analysisは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもData Analysisを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Data Analysis」は無料ですか?

HaipingXuがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇