YouMind
Sign in
MATLAB Coding Engineer

MATLAB Coding Engineer

Write, review, and debug code for research

Installed by
2
FromYouMind

Showcase

DID 双重差分分析 · MATLAB 实现

面向科研政策评估的完整 DID 工具集:双向固定效应估计、个体层聚类稳健标准误、事件研究法平行趋势检验、出版级可视化。

方案说明

基准模型为双向固定效应 DID:

$$y_{it} = \alpha_i + \lambda_t + \beta \cdot \left(\text{Treat}_i \times \text{Post}t\right) + \varepsilon{it}$$

其中 $\alpha_i$ 为个体固定效应,$\lambda_t$ 为时间固定效应,交互项系数 $\beta$ 即政策处理效应。估计上用稀疏虚拟变量承载固定效应并配合反斜杠求解,避免逐元素循环与 inv;标准误采用聚类稳健 sandwich 形式 $V = (X'X)^{-1} M (X'X)^{-1}$,其中 $M = \sum_g X_g' u_g u_g' X_g$。

平行趋势检验采用事件研究法,以政策前一期($k = -1$)为基期。若政策前的系数 $\beta_k$($k < -1$)联合不显著异于 0,则平行趋势假设成立。

文件清单

文件作用
estimateDid.mDID 主估计,返回政策效应、聚类稳健标准误、p 值、置信区间
estimateEventStudy.m事件研究法,输出动态系数与平行趋势 Wald 检验
plotDidResults.m绘制均值趋势图与事件研究系数图
buildDummyMatrix.m工具函数:分组变量转稀疏虚拟变量矩阵
computeClusterRobustVariance.m工具函数:聚类稳健方差-协方差矩阵

五个文件放在同一目录下即可直接调用。


1. estimateDid.m

<EMPTY_PARAGRAPH>

function results = estimateDid(panelTable, options)

DID 双重差分分析 · MATLAB 实现

Description

Write, review, and refactor MATLAB code based on the official MathWorks MATLAB Coding Guidelines. Automatically identify three modes—writing new code, reviewing existing code, and diagnosing errors—to produce engineering-grade code that passes Code Analyzer checks, includes Chinese comments, and provides optimization suggestions for vectorization, preallocation, and numerical robustness.

Related Skills

View all

Programming Expert

A programming assistant for software development that analyzes code, logs, and user-provided files. It provides code implementation, review, debugging, testing, technical design, and project planning suggestions, adjusting the depth of clarification and verification based on risk.

亚
01.9k

Model Routing & Token Saver

Based on task difficulty, content type, and project stage, it helps you choose a more suitable AI model and apply quota-saving rules to AI to reduce token usage. While keeping quota consumption under control, it supports programming, creative work, planning, design, and information analysis. Whether you need page components, API integrations, simple bug fixes, architecture design, complex logic, code reviews, or refactoring, it provides clear model recommendations and directly delivers the requested results. It is also well suited to everyday copywriting, titles and hooks, story-driven content, brand proposals, marketing plans, PPT outlines, visual concepts, market trends, competitor analysis, and data interpretation. Simple, batch, and formatting tasks are prioritized for greater quota efficiency. For major decisions, complex reasoning, or final polishing, it reminds you to invest in a more suitable model for quality. With continued use, it adjusts its recommendations based on your model preferences, output habits, project tech stack, key decisions, pending tasks, and known issues, reducing repetitive communication. For coding tasks, it focuses by default on the core changes and summarizes what was modified. For copywriting and proposal tasks, it first organizes the overall framework and then expands it as needed, making each conversation better aligned with your current project and working rhythm.

一
01k
Research

Professional Code Reviewer

Automatically validate code against plans and best practices to catch issues early and ensure a flawless delivery.

L
6650

Information

Version
v4
Last updated
Runtime credits
Usage-based
Models
Auto

Ready to create something bolder?

MATLAB Coding Engineer