본문으로 건너뛰기
cccskills
무료GitHub에 공개

structural-modeling

Build and estimate economic models that represent underlying choices and incentives. Get guidance on demand, dynamic choice, and auction models, select estimation methods, and diagnose numerical problems such as failed convergence or sensitivity to starting values.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

This skill covers structural econometric models. Use when the user is building, estimating, or debugging structural models — including BLP demand estimation, dynamic discrete choice, auction models, or any workflow involving moment conditions, nested fixed-point algorithms, or MPEC formulations. Triggers on "structural model", "moment conditions", "NFXP", "MPEC", "BLP", "random coefficients", "dynamic discrete choice", "CCP", "Rust model", "auction estimation", "GMM objective", "inner loop", "contraction mapping", or convergence/starting value problems in optimization-based estimation.

설치 방법 보기

이럴 때 유용합니다

  • Choose an estimation method for a structural economic model
  • Implement BLP demand estimation
  • Estimate dynamic choice and auction models
  • Diagnose convergence and starting-value problems

포함된 파일(4)

  • SKILL.md10.4 KB
  • references/diagnostics-and-se.md4.9 KB
  • references/estimation-methods.md12.5 KB
  • references/jax-guide.md2.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Structural Modeling

Reference for implementing structural econometric models: from economic model to moment conditions to estimated parameters. Covers the full workflow of taking a theoretical model, deriving its empirical content, and recovering structural parameters from data.

When to Use This Skill

Use when the user is:

  • Specifying a structural model and deriving moment conditions
  • Implementing NFXP or MPEC estimation routines
  • Working with BLP-style demand systems (random coefficients logit)
  • Building dynamic discrete choice models (Rust, Hotz-Miller CCP)
  • Estimating auction models (first-price, ascending, common value)
  • Debugging convergence failures in structural estimation
  • Choosing between estimation approaches for a given model

Skip when:

  • The task is reduced-form causal inference (use causal-inference skill)
  • The task is pure simulation design (use numerical-auditor agent)
  • The user just needs standard regression (statsmodels/linearmodels suffice)

Quick Reference: Structural Methods

MethodUse CaseKey PackageEstimator
NFXPDynamic discrete choice (small state space)scipy.optimizeMLE / GMM
MPECDynamic discrete choice (large state space, slow inner loop)cyipopt (IPOPT)MLE / GMM
BLPDifferentiated products demand with RC logitpyblpGMM (2-step)
CCP (Hotz-Miller)Dynamic models, counterfactuals not neededscipy2-step semiparametric
GPVFirst-price auctions, nonparametric valuesscipyNonparametric
Ascending auctionEnglish auctions, private valuesscipyMLE on order statistics

The Structural Estimation Workflow

Every structural estimation follows the same logical arc:

Economic Model → Equilibrium/Decision Rule → Observable Implications
    → Moment Conditions → Estimator → Optimization → Inference

Step 1: Model Specification

Define primitives clearly before writing any code:

# model_spec.py — Document structural primitives
"""
Model: Single-agent optimal stopping (Rust 1987 bus engine replacement)

State:    x_t ∈ {0, 1, ..., X_max}  (mileage bin)
Action:   a_t ∈ {0, 1}  (0 = maintain, 1 = replace)
Flow payoff:
    u(x, 0; θ) = -θ_1 * x - θ_2 * x²     (maintenance cost)
    u(x, 1; θ) = -RC                        (replacement cost)
Discount:  β = 0.9999 (fixed)
Shocks:    ε ~ Type 1 Extreme Value (logit errors)
"""

Document these before writing estimation code: agents, information, timing, payoff functional form, equilibrium concept.

Step 2: Derive Moment Conditions

SourceExampleEstimator
Optimality conditions (FOCs)Euler equations, Bellman optimalityGMM
Equilibrium restrictionsMarket clearing, Nash conditionsGMM / ML
Distributional assumptionsChoice probabilities under logit errorsMLE
Exclusion restrictionsCost shifters excluded from demandIV-GMM

Key question: Just-identified → method of moments; over-identified → GMM with optimal weighting matrix; under-identified → revisit assumptions.

NFXP vs MPEC

Two dominant paradigms for models with latent quantities (unobserved heterogeneity, future expectations, equilibrium objects):

NFXP (Nested Fixed-Point): Solve the model in an inner loop for each parameter guess, evaluate likelihood/moments in an outer loop. Conceptually simple; inner loop must fully converge at every iteration — requires tight tolerance (1e-12, not 1e-6; see Su & Judd 2012).

MPEC (Mathematical Programming with Equilibrium Constraints): Reformulate as a single constrained optimization. No inner loop — solver handles everything; can be faster for large state spaces; requires IPOPT or KNITRO.

FactorFavors NFXPFavors MPEC
State spaceSmall (< 500 states)Large (> 1000 states)
Inner loopFast convergence (rate < 0.9)Slow or fragile
Solver availabilityscipy.optimize sufficientIPOPT/KNITRO available
DebuggingEasier — isolate inner vs outerHarder to diagnose constraint violations

For full NFXP and MPEC code (Rust 1987 bus engine model), see references/estimation-methods.md.

BLP Demand Estimation

BLP (Berry, Levinsohn, Pakes 1995) is the workhorse for differentiated products demand. Use PyBLP whenever possible — it handles the difficult numerical details correctly.

import pyblp

# Define the problem
problem = pyblp.Problem(
    product_formulations=(
        pyblp.Formulation('1 + prices + x1 + x2'),       # linear (β)
        pyblp.Formulation('1 + prices + x1'),              # random coefficients (Σ)
    ),
    product_data=product_data,
    agent_data=agent_data
)

# Solve — always use multiple starting values; BLP objective is non-convex
results = problem.solve(
    sigma=sigma_init,
    optimization=pyblp.Optimization('l-bfgs-b', {'gtol': 1e-8}),
    iteration=pyblp.Iteration('squarem', {'atol': 1e-14}),
    method='2s'
)

For the full multi-start loop, two-step GMM, elasticity checks, instrument selection, and marginal cost computation, see references/estimation-methods.md.

BLP Diagnostics Checklist:

  • First-stage F > 10 for price instruments
  • Run 10+ random starts (objective is non-convex)
  • Own-price elasticities all negative: results.compute_elasticities('prices')
  • All markets converged: results.fp_converged.all()
  • Marginal costs positive: results.compute_costs()
  • Inner loop atol <= 1e-14 (tighter is safer)

Dynamic Discrete Choice

Rust (1987) NFXP: Full solution — solve the Bellman equation by value function iteration at every outer iteration. Use for models where counterfactuals require the full model.

Hotz-Miller CCP: Two-step semiparametric approach. Step 1: estimate conditional choice probabilities nonparametrically. Step 2: form pseudo-value functions for a linear regression. Faster; less efficient; sufficient when counterfactuals are not needed.

FeatureFull Solution (NFXP/MPEC)CCP (Hotz-Miller)
Computational costHigh (solve DP at each θ)Low (no DP solving)
EfficiencyEfficient (MLE)Less efficient (2-step)
CounterfactualsNatural (full model available)Must resolve for new policies

For full CCP implementation code, see references/estimation-methods.md.

Auction Models

First-price sealed-bid (GPV): Guerre, Perrigne, Vuong (2000) — invert the bidding equilibrium condition v(b) = b + G(b)/((n-1)g(b)) to recover latent values nonparametrically from observed bids.

Ascending (English): In IPV setting, transaction price = second-highest value. Use MLE on order statistics to recover the value distribution.

Common value: Requires accounting for winner's curse. Li-Perrigne-Vuong (2002) approach; typically requires parametric assumptions.

For full GPV estimator code, ascending auction MLE, and validation diagnostics, see references/estimation-methods.md.

Method Selection

When to use structural vs. reduced-form:

  • Structural: Need to evaluate counterfactual policies, recover preference parameters, or model strategic interactions
  • Reduced-form: Need a credible causal estimate of a specific treatment effect with minimal assumptions

Within structural:

  1. Static discrete choice with heterogeneity? → BLP / mixed logit
  2. Dynamic single-agent optimal stopping? → NFXP (small state) or MPEC (large state)
  3. Counterfactuals not needed, data rich? → CCP estimator
  4. Auction data? → GPV (first-price) or order statistics MLE (ascending)
  5. Market-level entry/exit? → Bresnahan-Reiss or Ciliberto-Tamer (see game-theory skill)

Common Anti-Patterns

Anti-PatternProblemBetter Approach
Estimating β jointly with payoff parametersNotoriously poorly identified; flat objectiveFix β at reasonable value (0.95, 0.99) or calibrate externally
Loose inner loop tolerance (1e-6)Optimizer sees noise; spurious convergenceUse 1e-12 or tighter; see Su & Judd (2012)
Single starting valueStructural objectives are non-convexUse 10+ random starts plus grid search
Ignoring simulation error in simulated MLE/MSMBiased standard errorsUse enough draws (R >> N) or bias-correct
Numerical gradients with default step sizeInaccurate for poorly scaled problemsUse central differences or analytic gradients (JAX)
Hard-coding state space discretizationResults sensitive to grid coarsenessTest sensitivity to grid refinement

JAX Acceleration

For GPU-accelerated structural estimation (JIT compilation, autodiff, vmap for simulated moments, differentiable fixed-point iteration with lax.while_loop), see references/jax-guide.md.

Integration with compound-science

  • numerical-auditor — Systematic convergence review: gradient norms, conditioning, tolerance sensitivity
  • numerical-auditor — DGP formalization, Monte Carlo studies, convergence review
  • identification-critic — Verify equilibrium existence, uniqueness, stability, comparative statics
  • econometric-reviewer — Reviews moment-matching strategy, parameter identification, sensitivity to targets
  • /estimate — Full estimation pipeline with quality gates

Additional References

  • references/estimation-methods.md — Full code: BLP multi-start, NFXP Bellman solver, MPEC cyipopt formulation, Hotz-Miller CCP, GPV auction estimator
  • references/diagnostics-and-se.md — Convergence failure diagnosis, numerical safeguards (logsumexp, conditioning), GMM sandwich SEs, parametric bootstrap
  • references/jax-guide.md — JAX JIT/autodiff for structural objectives, vmap for simulation, lax.while_loop for differentiable contraction mappings

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

a1

무료

Turn a broad research idea into clear, testable questions. Compare familiar and less conventional approaches, structure the selected question around its population and methods, and assess variables, feasibility, and potential theoretical contributions.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Turn a research topic into testable questions
  • Narrow an overly broad research question
  • Compare alternative research angles
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

a2

무료

Helps build a research framework by comparing theories, mapping relationships between variables, and deriving testable hypotheses. Explores less conventional options, examines weaknesses and competing explanations, and produces diagrams with anticipated reviewer objections.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Comparing theories for a research question
  • Deriving hypotheses from relationships between variables
  • Examining weaknesses and anticipated reviewer objections
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

a5

무료

Clarify the philosophical assumptions behind a research project and check whether they fit the proposed methods. Get a reasoned research stance, draft proposal wording, and guidance for explaining how the researcher's background and values shape the study.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Clarifying philosophical foundations for a research proposal
  • Explaining why the chosen research methods fit the study
  • Drafting a statement about the researcher's position
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

Plan and draft academic papers through specialized agent roles covering literature, arguments, citations, and review. Get chapter guidance, revision roadmaps, Traditional Chinese and English abstracts, and documents formatted as LaTeX, DOCX, PDF, or Markdown.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Planning a paper chapter by chapter
  • Drafting a paper from research materials
  • Turning reviewer comments into a revision roadmap
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

Turn a detailed outline into a philosophy or interdisciplinary manuscript. Draft chapters with repeated quality reviews, check terminology and arguments across sections, and prepare the manuscript, evaluation reports, abstract, and metadata for submission.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Draft a full paper from a detailed outline
  • Review argument and citation quality chapter by chapter
  • Check terminology and argument flow across chapters
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

Simulate academic peer review through five reviewer roles tailored to the paper's field. Receive separate critiques, an editorial decision, and a prioritized revision roadmap, or check whether a revised manuscript addresses earlier comments.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Review a manuscript before journal submission
  • Examine research methods and statistical validity
  • Challenge core arguments and alternative explanations
brycewang-stanford/Auto-Empirical-Research-Skills4.7천2026년 10월 20일 업데이트

brycewang-stanford의 스킬 모두 보기

이 스킬의 문제 신고