界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
设计与创意 · SKILL.md

linear-and-formula-models

linear-and-formula-models

【设计与创意】Use statsmodels linear, generalized linear, robust, mixed, GEE, GAM, and formula APIs for model fitting, prediction, summaries, missing data, robust covariance, and design-matrix troubleshooting.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: linear-and-formula-models description: "Use statsmodels linear, generalized linear, robust, mixed, GEE, GAM, and formula APIs for model fitting, prediction, summaries, missing data, robust covariance, and design-matrix troubleshooting." disable-model-invocation: true metadata: disco-role: operating license: BSD 3-Clause

Linear and formula models

Use this sub-skill for OLS/WLS/GLS/GLSAR, RollingOLS/RollingWLS, QuantReg, RLM, GLM, GEE, GAM, MixedLM, variance components, formula workflows, design matrices, missing-data handling, robust covariance, prediction, and summary interpretation.

Start here

  1. Choose interface:
    • DataFrame plus formula: import statsmodels.formula.api as smf; call smf.ols(...), smf.glm(...), smf.mixedlm(...), or smf.gee(...).
    • Prepared arrays: import statsmodels.api as sm; add an intercept with sm.add_constant when required and call model classes such as sm.OLS(endog, exog) or sm.GLM(endog, exog, family=...).
  2. Validate data before fitting: shape, missing values, categorical encoding, constant column, rank, and domain restrictions for the chosen family.
  3. Fit once, inspect result attributes (params, bse, pvalues, conf_int(), summary()), and only then add robust covariance, predictions, or diagnostics.
  4. For residual diagnostics, ANOVA/contrasts, or outlier influence details, cross-route to statistical-tests-and-diagnostics. For result export and plotting, cross-route to datasets-results-graphics.

Read or run

Boundaries

  • Route binary choice, multinomial choice, ordered models, count-model-specific marginal effects, zero-inflated, hurdle, and truncated count workflows to discrete-and-count-models.
  • Route ARIMA/SARIMAX/VAR/forecasting and time-index problems to time-series-analysis.
  • Route general hypothesis tests, influence/outlier procedures, and multiple testing to statistical-tests-and-diagnostics, but keep model-specific fit setup here.
  • Do not recommend statsmodels.sandbox implementations for production linear modeling unless the user explicitly asks about sandbox code.

Quality checks before answering

  • State whether the snippet uses formula or matrix API.
  • Show how the intercept is handled.
  • Mention missing-data policy when inputs may contain NaN.
  • Keep new prediction data aligned with training columns and categorical levels.
  • Explain convergence/rank warnings as statistical identification issues, not only software failures.
我的收藏