@pikaa-ai/pikaa 0.3.22 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/brand/orbit-logo-option4-whale.jpg +0 -0
- package/assets/brand/orbit-logo.jpg +0 -0
- package/assets/brand/orbit-logo.png +0 -0
- package/assets/brand/orbit-logo.svg +3 -0
- package/dist/cli.js +448 -181
- package/dist/index.js +22 -2
- package/package.json +1 -2
- package/skills/adaptyv/SKILL.md +0 -240
- package/skills/aeon/SKILL.md +0 -402
- package/skills/analytical-method-validation/SKILL.md +0 -299
- package/skills/anndata/SKILL.md +0 -431
- package/skills/arbor/SKILL.md +0 -152
- package/skills/arboreto/SKILL.md +0 -267
- package/skills/astropy/SKILL.md +0 -353
- package/skills/autoskill/SKILL.md +0 -233
- package/skills/benchling-integration/SKILL.md +0 -229
- package/skills/bgpt-paper-search/SKILL.md +0 -75
- package/skills/bids/SKILL.md +0 -237
- package/skills/biopython/SKILL.md +0 -472
- package/skills/bioservices/SKILL.md +0 -399
- package/skills/bulk-rnaseq/SKILL.md +0 -198
- package/skills/cellxgene-census/SKILL.md +0 -283
- package/skills/cirq/SKILL.md +0 -370
- package/skills/citation-management/SKILL.md +0 -329
- package/skills/clinical-decision-support/SKILL.md +0 -238
- package/skills/clinical-decision-support/references/README.md +0 -62
- package/skills/clinical-reports/SKILL.md +0 -248
- package/skills/clinical-reports/references/README.md +0 -34
- package/skills/cobrapy/SKILL.md +0 -496
- package/skills/consciousness-council/SKILL.md +0 -151
- package/skills/dask/SKILL.md +0 -482
- package/skills/database-lookup/SKILL.md +0 -386
- package/skills/datamol/SKILL.md +0 -200
- package/skills/deepchem/SKILL.md +0 -244
- package/skills/deepspot-m/SKILL.md +0 -175
- package/skills/deeptools/SKILL.md +0 -412
- package/skills/depmap/SKILL.md +0 -301
- package/skills/dhdna-profiler/SKILL.md +0 -184
- package/skills/diffdock/SKILL.md +0 -488
- package/skills/dnanexus-integration/SKILL.md +0 -325
- package/skills/docx/SKILL.md +0 -99
- package/skills/esm/SKILL.md +0 -334
- package/skills/etetoolkit/SKILL.md +0 -327
- package/skills/exa-search/SKILL.md +0 -102
- package/skills/executing-plans/SKILL.md +0 -14
- package/skills/experimental-design/SKILL.md +0 -234
- package/skills/exploratory-data-analysis/SKILL.md +0 -280
- package/skills/flowio/SKILL.md +0 -310
- package/skills/fluidsim/SKILL.md +0 -279
- package/skills/frontend-design/SKILL.md +0 -100
- package/skills/generate-image/SKILL.md +0 -304
- package/skills/geniml/SKILL.md +0 -310
- package/skills/genomic-coordinates/SKILL.md +0 -189
- package/skills/genomic-intelligence/SKILL.md +0 -243
- package/skills/geomaster/README.md +0 -105
- package/skills/geomaster/SKILL.md +0 -366
- package/skills/geopandas/SKILL.md +0 -250
- package/skills/get-available-resources/SKILL.md +0 -260
- package/skills/gget/SKILL.md +0 -153
- package/skills/ginkgo-cloud-lab/SKILL.md +0 -106
- package/skills/glycoengineering/SKILL.md +0 -339
- package/skills/gtars/SKILL.md +0 -282
- package/skills/guardian-rails/SKILL.md +0 -54
- package/skills/histolab/SKILL.md +0 -243
- package/skills/hugging-science/SKILL.md +0 -132
- package/skills/hypogenic/SKILL.md +0 -290
- package/skills/hypothesis-generation/SKILL.md +0 -264
- package/skills/imaging-data-commons/SKILL.md +0 -496
- package/skills/infographics/SKILL.md +0 -315
- package/skills/iso-standards-readiness/SKILL.md +0 -352
- package/skills/lab-hardware-cad/SKILL.md +0 -372
- package/skills/labarchive-integration/SKILL.md +0 -216
- package/skills/lamindb/SKILL.md +0 -408
- package/skills/latchbio-integration/SKILL.md +0 -227
- package/skills/latex-posters/SKILL.md +0 -369
- package/skills/latex-posters/references/README.md +0 -439
- package/skills/liteparse/SKILL.md +0 -295
- package/skills/literature-review/SKILL.md +0 -263
- package/skills/markdown-mermaid-writing/SKILL.md +0 -322
- package/skills/market-research-reports/SKILL.md +0 -337
- package/skills/markitdown/SKILL.md +0 -264
- package/skills/matchms/SKILL.md +0 -276
- package/skills/matlab/SKILL.md +0 -274
- package/skills/matplotlib/SKILL.md +0 -378
- package/skills/medchem/SKILL.md +0 -321
- package/skills/modal/SKILL.md +0 -468
- package/skills/molecular-dynamics/SKILL.md +0 -458
- package/skills/molfeat/SKILL.md +0 -348
- package/skills/ncats-arax/SKILL.md +0 -178
- package/skills/networkx/SKILL.md +0 -440
- package/skills/neurokit2/SKILL.md +0 -323
- package/skills/neuropixels-analysis/SKILL.md +0 -412
- package/skills/nextflow/SKILL.md +0 -195
- package/skills/omero-integration/SKILL.md +0 -222
- package/skills/onekgpd/SKILL.md +0 -371
- package/skills/ontology-term-resolution/SKILL.md +0 -147
- package/skills/open-notebook/SKILL.md +0 -297
- package/skills/openpiv/SKILL.md +0 -469
- package/skills/opentrons-integration/SKILL.md +0 -322
- package/skills/optimize-for-gpu/SKILL.md +0 -176
- package/skills/owasp-top10/SKILL.md +0 -48
- package/skills/pacsomatic/LICENSE +0 -21
- package/skills/pacsomatic/SKILL.md +0 -150
- package/skills/paper-lookup/SKILL.md +0 -263
- package/skills/paperclip/SKILL.md +0 -413
- package/skills/paperzilla/SKILL.md +0 -159
- package/skills/parallel-web/SKILL.md +0 -128
- package/skills/pathml/SKILL.md +0 -222
- package/skills/pathogen-variant-surveillance/SKILL.md +0 -208
- package/skills/pathway-enrichment/SKILL.md +0 -194
- package/skills/pdf/SKILL.md +0 -322
- package/skills/peer-review/SKILL.md +0 -288
- package/skills/penetration-testing/SKILL.md +0 -31
- package/skills/pennylane/SKILL.md +0 -240
- package/skills/phylogenetics/SKILL.md +0 -409
- package/skills/pi-agent/SKILL.md +0 -83
- package/skills/pkpd-modeling/SKILL.md +0 -381
- package/skills/polars/SKILL.md +0 -393
- package/skills/polars-bio/SKILL.md +0 -379
- package/skills/ponytail/SKILL.md +0 -31
- package/skills/ponytail-audit/SKILL.md +0 -18
- package/skills/pptx/SKILL.md +0 -246
- package/skills/pptx-posters/SKILL.md +0 -258
- package/skills/primekg/SKILL.md +0 -99
- package/skills/protocolsio-integration/SKILL.md +0 -236
- package/skills/pufferlib/SKILL.md +0 -328
- package/skills/pydeseq2/SKILL.md +0 -369
- package/skills/pydicom/SKILL.md +0 -381
- package/skills/pyhealth/SKILL.md +0 -124
- package/skills/pylabrobot/SKILL.md +0 -216
- package/skills/pymatgen/SKILL.md +0 -404
- package/skills/pymc/SKILL.md +0 -310
- package/skills/pymoo/SKILL.md +0 -276
- package/skills/pyopenms/SKILL.md +0 -179
- package/skills/pysam/SKILL.md +0 -330
- package/skills/pytdc/SKILL.md +0 -297
- package/skills/pytorch-lightning/SKILL.md +0 -191
- package/skills/pyzotero/SKILL.md +0 -137
- package/skills/qiskit/SKILL.md +0 -259
- package/skills/qutip/SKILL.md +0 -317
- package/skills/rdkit/SKILL.md +0 -94
- package/skills/relsa-severity-assessment/SKILL.md +0 -354
- package/skills/research-grants/SKILL.md +0 -296
- package/skills/research-grants/references/README.md +0 -287
- package/skills/research-lookup/README.md +0 -106
- package/skills/research-lookup/SKILL.md +0 -338
- package/skills/rowan/SKILL.md +0 -398
- package/skills/scanpy/SKILL.md +0 -303
- package/skills/scholar-evaluation/SKILL.md +0 -296
- package/skills/scientific-brainstorming/SKILL.md +0 -282
- package/skills/scientific-critical-thinking/SKILL.md +0 -180
- package/skills/scientific-schematics/SKILL.md +0 -370
- package/skills/scientific-slides/SKILL.md +0 -379
- package/skills/scientific-visualization/SKILL.md +0 -285
- package/skills/scientific-writing/SKILL.md +0 -356
- package/skills/scikit-bio/SKILL.md +0 -470
- package/skills/scikit-learn/SKILL.md +0 -324
- package/skills/scikit-survival/SKILL.md +0 -313
- package/skills/scvelo/SKILL.md +0 -328
- package/skills/scvi-tools/SKILL.md +0 -201
- package/skills/seaborn/SKILL.md +0 -254
- package/skills/security-auditor/SKILL.md +0 -37
- package/skills/shap/SKILL.md +0 -282
- package/skills/simpy/SKILL.md +0 -283
- package/skills/stable-baselines3/SKILL.md +0 -325
- package/skills/statistical-analysis/SKILL.md +0 -446
- package/skills/statistical-power/SKILL.md +0 -200
- package/skills/statsmodels/SKILL.md +0 -238
- package/skills/sympy/SKILL.md +0 -354
- package/skills/systematic-debugging/SKILL.md +0 -35
- package/skills/tamarind/SKILL.md +0 -285
- package/skills/tdd/SKILL.md +0 -26
- package/skills/tiledbvcf/SKILL.md +0 -456
- package/skills/timesfm-forecasting/SKILL.md +0 -408
- package/skills/timesfm-forecasting/examples/global-temperature/README.md +0 -178
- package/skills/torch-geometric/SKILL.md +0 -458
- package/skills/torchdrug/SKILL.md +0 -241
- package/skills/transformers/SKILL.md +0 -195
- package/skills/treatment-plans/SKILL.md +0 -174
- package/skills/treatment-plans/references/README.md +0 -19
- package/skills/umap-learn/SKILL.md +0 -488
- package/skills/uncertainty-and-units/SKILL.md +0 -384
- package/skills/usfiscaldata/SKILL.md +0 -171
- package/skills/vaex/SKILL.md +0 -204
- package/skills/venue-templates/SKILL.md +0 -269
- package/skills/verification-before-completion/SKILL.md +0 -22
- package/skills/waypoint-bio/SKILL.md +0 -273
- package/skills/what-if-oracle/SKILL.md +0 -184
- package/skills/writing-plans/SKILL.md +0 -15
- package/skills/xlsx/SKILL.md +0 -110
- package/skills/zarr-python/SKILL.md +0 -241
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: statsmodels
|
|
3
|
-
description: Statistical models library for Python. Use when you need specific model classes (OLS, GLM, mixed models, ARIMA) with detailed diagnostics, residuals, and inference. Best for econometrics, time series, rigorous inference with coefficient tables. For guided statistical test selection with APA reporting use statistical-analysis.
|
|
4
|
-
allowed-tools: Read Write Edit Bash
|
|
5
|
-
compatibility: Requires Python 3.9+ and statsmodels 0.14.6-compatible dependencies. Use `uv pip install statsmodels==0.14.6`; optional predictive-metric examples also need scikit-learn.
|
|
6
|
-
license: BSD-3-Clause license
|
|
7
|
-
metadata:
|
|
8
|
-
version: "1.2"
|
|
9
|
-
skill-author: K-Dense Inc.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Statsmodels: Statistical Modeling and Econometrics
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
|
|
16
|
-
Statsmodels is Python's premier library for statistical modeling, providing tools for estimation, inference, and diagnostics across a wide range of statistical methods. Apply this skill for rigorous statistical analysis, from simple linear regression to complex time series models and econometric analyses.
|
|
17
|
-
|
|
18
|
-
## Current Compatibility
|
|
19
|
-
|
|
20
|
-
Examples target statsmodels 0.14.6, released Dec 5, 2025. For reproducible environments, pin the primary package:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
uv pip install statsmodels==0.14.6
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Use `statsmodels.api` and `statsmodels.formula.api` for stable high-level imports, and direct module imports when examples require newer or specialized classes such as `HurdleCountModel`.
|
|
27
|
-
|
|
28
|
-
## When to Use This Skill
|
|
29
|
-
|
|
30
|
-
This skill should be used when:
|
|
31
|
-
- Fitting regression models (OLS, WLS, GLS, quantile regression)
|
|
32
|
-
- Performing generalized linear modeling (logistic, Poisson, Gamma, etc.)
|
|
33
|
-
- Analyzing discrete outcomes (binary, multinomial, count, ordinal)
|
|
34
|
-
- Conducting time series analysis (ARIMA, SARIMAX, VAR, forecasting)
|
|
35
|
-
- Running statistical tests and diagnostics
|
|
36
|
-
- Testing model assumptions (heteroskedasticity, autocorrelation, normality)
|
|
37
|
-
- Detecting outliers and influential observations
|
|
38
|
-
- Comparing models (AIC/BIC, likelihood ratio tests)
|
|
39
|
-
- Estimating causal effects
|
|
40
|
-
- Producing publication-ready statistical tables and inference
|
|
41
|
-
|
|
42
|
-
## Quick Start, Capabilities, and Model Selection
|
|
43
|
-
|
|
44
|
-
- [references/quick_start_guide.md](references/quick_start_guide.md): minimal worked
|
|
45
|
-
examples for OLS, logistic regression, ARIMA, and GLM, and how to read the summary.
|
|
46
|
-
- [references/modeling_capabilities.md](references/modeling_capabilities.md): linear
|
|
47
|
-
models, GLMs, discrete choice, time series, and the statistical tests and diagnostics.
|
|
48
|
-
- [references/model_selection.md](references/model_selection.md): the R-style formula API
|
|
49
|
-
and model comparison.
|
|
50
|
-
- Per-topic detail: [references/linear_models.md](references/linear_models.md),
|
|
51
|
-
[references/glm.md](references/glm.md),
|
|
52
|
-
[references/discrete_choice.md](references/discrete_choice.md),
|
|
53
|
-
[references/time_series.md](references/time_series.md), and
|
|
54
|
-
[references/stats_diagnostics.md](references/stats_diagnostics.md).
|
|
55
|
-
|
|
56
|
-
statsmodels is for *inference* — standard errors, confidence intervals, and hypothesis
|
|
57
|
-
tests. Reach for scikit-learn when prediction is the goal and the coefficients do not
|
|
58
|
-
need interpreting.
|
|
59
|
-
|
|
60
|
-
## Best Practices
|
|
61
|
-
|
|
62
|
-
### Data Preparation
|
|
63
|
-
|
|
64
|
-
1. **Always add constant**: Use `sm.add_constant()` unless excluding intercept
|
|
65
|
-
2. **Check for missing values**: Handle or impute before fitting
|
|
66
|
-
3. **Scale if needed**: Improves convergence, interpretation (but not required for tree models)
|
|
67
|
-
4. **Encode categoricals**: Use formula API or manual dummy coding
|
|
68
|
-
|
|
69
|
-
### Model Building
|
|
70
|
-
|
|
71
|
-
1. **Start simple**: Begin with basic model, add complexity as needed
|
|
72
|
-
2. **Check assumptions**: Test residuals, heteroskedasticity, autocorrelation
|
|
73
|
-
3. **Use appropriate model**: Match model to outcome type (binary→Logit, count→Poisson)
|
|
74
|
-
4. **Consider alternatives**: If assumptions violated, use robust methods or different model
|
|
75
|
-
|
|
76
|
-
### Inference
|
|
77
|
-
|
|
78
|
-
1. **Report effect sizes**: Not just p-values
|
|
79
|
-
2. **Use robust SEs**: When heteroskedasticity or clustering present
|
|
80
|
-
3. **Multiple comparisons**: Correct when testing many hypotheses
|
|
81
|
-
4. **Confidence intervals**: Always report alongside point estimates
|
|
82
|
-
|
|
83
|
-
### Model Evaluation
|
|
84
|
-
|
|
85
|
-
1. **Check residuals**: Plot residuals vs fitted, Q-Q plot
|
|
86
|
-
2. **Influence diagnostics**: Identify and investigate influential observations
|
|
87
|
-
3. **Out-of-sample validation**: Test on holdout set or cross-validate
|
|
88
|
-
4. **Compare models**: Use AIC/BIC for non-nested, LR test for nested
|
|
89
|
-
|
|
90
|
-
### Reporting
|
|
91
|
-
|
|
92
|
-
1. **Comprehensive summary**: Use `.summary()` for detailed output
|
|
93
|
-
2. **Document decisions**: Note transformations, excluded observations
|
|
94
|
-
3. **Interpret carefully**: Account for link functions (e.g., exp(β) for log link)
|
|
95
|
-
4. **Visualize**: Plot predictions, confidence intervals, diagnostics
|
|
96
|
-
|
|
97
|
-
## Common Workflows
|
|
98
|
-
|
|
99
|
-
### Workflow 1: Linear Regression Analysis
|
|
100
|
-
|
|
101
|
-
1. Explore data (plots, descriptives)
|
|
102
|
-
2. Fit initial OLS model
|
|
103
|
-
3. Check residual diagnostics
|
|
104
|
-
4. Test for heteroskedasticity, autocorrelation
|
|
105
|
-
5. Check for multicollinearity (VIF)
|
|
106
|
-
6. Identify influential observations
|
|
107
|
-
7. Refit with robust SEs if needed
|
|
108
|
-
8. Interpret coefficients and inference
|
|
109
|
-
9. Validate on holdout or via CV
|
|
110
|
-
|
|
111
|
-
### Workflow 2: Binary Classification
|
|
112
|
-
|
|
113
|
-
1. Fit logistic regression (Logit)
|
|
114
|
-
2. Check for convergence issues
|
|
115
|
-
3. Interpret odds ratios
|
|
116
|
-
4. Calculate marginal effects
|
|
117
|
-
5. Evaluate classification performance (AUC, confusion matrix)
|
|
118
|
-
6. Check for influential observations
|
|
119
|
-
7. Compare with alternative models (Probit)
|
|
120
|
-
8. Validate predictions on test set
|
|
121
|
-
|
|
122
|
-
### Workflow 3: Count Data Analysis
|
|
123
|
-
|
|
124
|
-
1. Fit Poisson regression
|
|
125
|
-
2. Check for overdispersion
|
|
126
|
-
3. If overdispersed, fit Negative Binomial
|
|
127
|
-
4. Check for excess zeros (consider ZIP/ZINB)
|
|
128
|
-
5. Interpret rate ratios
|
|
129
|
-
6. Assess goodness of fit
|
|
130
|
-
7. Compare models via AIC
|
|
131
|
-
8. Validate predictions
|
|
132
|
-
|
|
133
|
-
### Workflow 4: Time Series Forecasting
|
|
134
|
-
|
|
135
|
-
1. Plot series, check for trend/seasonality
|
|
136
|
-
2. Test for stationarity (ADF, KPSS)
|
|
137
|
-
3. Difference if non-stationary
|
|
138
|
-
4. Identify p, q from ACF/PACF
|
|
139
|
-
5. Fit ARIMA or SARIMAX
|
|
140
|
-
6. Check residual diagnostics (Ljung-Box)
|
|
141
|
-
7. Generate forecasts with confidence intervals
|
|
142
|
-
8. Evaluate forecast accuracy on test set
|
|
143
|
-
|
|
144
|
-
## Reference Documentation
|
|
145
|
-
|
|
146
|
-
This skill includes comprehensive reference files for detailed guidance:
|
|
147
|
-
|
|
148
|
-
### references/linear_models.md
|
|
149
|
-
Detailed coverage of linear regression models including:
|
|
150
|
-
- OLS, WLS, GLS, GLSAR, Quantile Regression
|
|
151
|
-
- Mixed effects models
|
|
152
|
-
- Recursive and rolling regression
|
|
153
|
-
- Comprehensive diagnostics (heteroskedasticity, autocorrelation, multicollinearity)
|
|
154
|
-
- Influence statistics and outlier detection
|
|
155
|
-
- Robust standard errors (HC, HAC, cluster)
|
|
156
|
-
- Hypothesis testing and model comparison
|
|
157
|
-
|
|
158
|
-
### references/glm.md
|
|
159
|
-
Complete guide to generalized linear models:
|
|
160
|
-
- All distribution families (Binomial, Poisson, Gamma, etc.)
|
|
161
|
-
- Link functions and when to use each
|
|
162
|
-
- Model fitting and interpretation
|
|
163
|
-
- Pseudo R-squared and goodness of fit
|
|
164
|
-
- Diagnostics and residual analysis
|
|
165
|
-
- Applications (logistic, Poisson, Gamma regression)
|
|
166
|
-
|
|
167
|
-
### references/discrete_choice.md
|
|
168
|
-
Comprehensive guide to discrete outcome models:
|
|
169
|
-
- Binary models (Logit, Probit)
|
|
170
|
-
- Multinomial models (MNLogit, Conditional Logit)
|
|
171
|
-
- Count models (Poisson, Negative Binomial, Zero-Inflated, Hurdle)
|
|
172
|
-
- Ordinal models
|
|
173
|
-
- Marginal effects and interpretation
|
|
174
|
-
- Model diagnostics and comparison
|
|
175
|
-
|
|
176
|
-
### references/time_series.md
|
|
177
|
-
In-depth time series analysis guidance:
|
|
178
|
-
- Univariate models (AR, ARIMA, SARIMAX, Exponential Smoothing)
|
|
179
|
-
- Multivariate models (VAR, VARMAX, Dynamic Factor)
|
|
180
|
-
- State space models
|
|
181
|
-
- Stationarity testing and diagnostics
|
|
182
|
-
- Forecasting methods and evaluation
|
|
183
|
-
- Granger causality, IRF, FEVD
|
|
184
|
-
|
|
185
|
-
### references/stats_diagnostics.md
|
|
186
|
-
Comprehensive statistical testing and diagnostics:
|
|
187
|
-
- Residual diagnostics (autocorrelation, heteroskedasticity, normality)
|
|
188
|
-
- Influence and outlier detection
|
|
189
|
-
- Hypothesis tests (parametric and non-parametric)
|
|
190
|
-
- ANOVA and post-hoc tests
|
|
191
|
-
- Multiple comparisons correction
|
|
192
|
-
- Robust covariance matrices
|
|
193
|
-
- Power analysis and effect sizes
|
|
194
|
-
|
|
195
|
-
**When to reference:**
|
|
196
|
-
- Need detailed parameter explanations
|
|
197
|
-
- Choosing between similar models
|
|
198
|
-
- Troubleshooting convergence or diagnostic issues
|
|
199
|
-
- Understanding specific test statistics
|
|
200
|
-
- Looking for code examples for advanced features
|
|
201
|
-
|
|
202
|
-
**Search patterns:**
|
|
203
|
-
```bash
|
|
204
|
-
# Find information about specific models
|
|
205
|
-
rg "Quantile Regression" references/
|
|
206
|
-
|
|
207
|
-
# Find diagnostic tests
|
|
208
|
-
rg "Breusch-Pagan" references/stats_diagnostics.md
|
|
209
|
-
|
|
210
|
-
# Find time series guidance
|
|
211
|
-
rg "SARIMAX" references/time_series.md
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
## Common Pitfalls to Avoid
|
|
215
|
-
|
|
216
|
-
1. **Forgetting constant term**: Always use `sm.add_constant()` unless no intercept desired
|
|
217
|
-
2. **Ignoring assumptions**: Check residuals, heteroskedasticity, autocorrelation
|
|
218
|
-
3. **Wrong model for outcome type**: Binary→Logit/Probit, Count→Poisson/NB, not OLS
|
|
219
|
-
4. **Not checking convergence**: Look for optimization warnings
|
|
220
|
-
5. **Misinterpreting coefficients**: Remember link functions (log, logit, etc.)
|
|
221
|
-
6. **Using Poisson with overdispersion**: Check dispersion, use Negative Binomial if needed
|
|
222
|
-
7. **Not using robust SEs**: When heteroskedasticity or clustering present
|
|
223
|
-
8. **Overfitting**: Too many parameters relative to sample size
|
|
224
|
-
9. **Data leakage**: Fitting on test data or using future information
|
|
225
|
-
10. **Not validating predictions**: Always check out-of-sample performance
|
|
226
|
-
11. **Comparing non-nested models**: Use AIC/BIC, not LR test
|
|
227
|
-
12. **Ignoring influential observations**: Check Cook's distance and leverage
|
|
228
|
-
13. **Multiple testing**: Correct p-values when testing many hypotheses
|
|
229
|
-
14. **Not differencing time series**: Fit ARIMA on non-stationary data
|
|
230
|
-
15. **Confusing prediction vs confidence intervals**: Prediction intervals are wider
|
|
231
|
-
|
|
232
|
-
## Getting Help
|
|
233
|
-
|
|
234
|
-
For detailed documentation and examples:
|
|
235
|
-
- Official docs: https://www.statsmodels.org/stable/
|
|
236
|
-
- User guide: https://www.statsmodels.org/stable/user-guide.html
|
|
237
|
-
- Examples: https://www.statsmodels.org/stable/examples/index.html
|
|
238
|
-
- API reference: https://www.statsmodels.org/stable/api.html
|
package/skills/sympy/SKILL.md
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: sympy
|
|
3
|
-
description: Use when you need exact symbolic math in Python — algebra, calculus, equation solving, symbolic linear algebra, or code generation via lambdify/LaTeX. Prefer NumPy or SciPy when floating-point approximations are sufficient.
|
|
4
|
-
license: https://github.com/sympy/sympy/blob/master/LICENSE
|
|
5
|
-
allowed-tools: Read Write Edit Bash
|
|
6
|
-
compatibility: Requires Python 3.9+ and SymPy 1.14+. Optional NumPy/SciPy/Matplotlib for lambdify examples; C/Fortran compiler for autowrap/codegen.
|
|
7
|
-
metadata:
|
|
8
|
-
version: "1.2"
|
|
9
|
-
skill-author: K-Dense Inc.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# SymPy - Symbolic Mathematics in Python
|
|
13
|
-
|
|
14
|
-
## Overview
|
|
15
|
-
|
|
16
|
-
SymPy is a Python library for symbolic mathematics that enables exact computation using mathematical symbols rather than numerical approximations. This skill provides comprehensive guidance for performing symbolic algebra, calculus, linear algebra, equation solving, physics calculations, and code generation using SymPy.
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
Tested against **SymPy 1.14.0** (stable; April 2025). Requires **Python 3.9+**.
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Install SymPy using uv
|
|
24
|
-
uv pip install "sympy>=1.14"
|
|
25
|
-
|
|
26
|
-
# Optional: for lambdify and plotting examples
|
|
27
|
-
uv pip install numpy scipy matplotlib
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Check your version:
|
|
31
|
-
|
|
32
|
-
```python
|
|
33
|
-
import sympy
|
|
34
|
-
print(sympy.__version__)
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## When to Use This Skill
|
|
38
|
-
|
|
39
|
-
Use this skill when:
|
|
40
|
-
- Solving equations symbolically (algebraic, differential, systems of equations)
|
|
41
|
-
- Performing calculus operations (derivatives, integrals, limits, series)
|
|
42
|
-
- Manipulating and simplifying algebraic expressions
|
|
43
|
-
- Working with matrices and linear algebra symbolically
|
|
44
|
-
- Doing physics calculations (mechanics, quantum mechanics, vector analysis)
|
|
45
|
-
- Number theory computations (primes, factorization, modular arithmetic)
|
|
46
|
-
- Geometric calculations (2D/3D geometry, analytic geometry)
|
|
47
|
-
- Converting mathematical expressions to executable code (Python, C, Fortran)
|
|
48
|
-
- Generating LaTeX or other formatted mathematical output
|
|
49
|
-
- Needing exact mathematical results (e.g., `sqrt(2)` not `1.414...`)
|
|
50
|
-
|
|
51
|
-
## Core Capabilities
|
|
52
|
-
|
|
53
|
-
Seven capability areas are documented in
|
|
54
|
-
[references/core_capabilities.md](references/core_capabilities.md):
|
|
55
|
-
|
|
56
|
-
1. **Symbolic computation basics** — symbols, expressions, simplification, substitution.
|
|
57
|
-
2. **Calculus** — differentiation, integration, limits, series.
|
|
58
|
-
3. **Equation solving** — `solve`, `solveset`, linear and nonlinear systems, ODEs.
|
|
59
|
-
4. **Matrices and linear algebra** — see
|
|
60
|
-
[references/matrices-linear-algebra.md](references/matrices-linear-algebra.md).
|
|
61
|
-
5. **Physics and mechanics** — see
|
|
62
|
-
[references/physics-mechanics.md](references/physics-mechanics.md).
|
|
63
|
-
6. **Advanced mathematics** — see
|
|
64
|
-
[references/advanced-topics.md](references/advanced-topics.md).
|
|
65
|
-
7. **Code generation and output** — see
|
|
66
|
-
[references/code-generation-printing.md](references/code-generation-printing.md).
|
|
67
|
-
|
|
68
|
-
Deeper treatment of the first three is in
|
|
69
|
-
[references/core-capabilities.md](references/core-capabilities.md).
|
|
70
|
-
|
|
71
|
-
## Working with SymPy: Best Practices
|
|
72
|
-
|
|
73
|
-
### 1. Always Define Symbols First
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
from sympy import symbols
|
|
77
|
-
x, y, z = symbols('x y z')
|
|
78
|
-
# Now x, y, z can be used in expressions
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### 2. Use Assumptions for Better Simplification
|
|
82
|
-
|
|
83
|
-
```python
|
|
84
|
-
x = symbols('x', positive=True, real=True)
|
|
85
|
-
sqrt(x**2) # Returns x (not Abs(x)) due to positive assumption
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Common assumptions: `real`, `positive`, `negative`, `integer`, `rational`, `complex`, `even`, `odd`
|
|
89
|
-
|
|
90
|
-
### 3. Use Exact Arithmetic
|
|
91
|
-
|
|
92
|
-
```python
|
|
93
|
-
from sympy import Rational, S
|
|
94
|
-
# Correct (exact):
|
|
95
|
-
expr = Rational(1, 2) * x
|
|
96
|
-
expr = S(1)/2 * x
|
|
97
|
-
|
|
98
|
-
# Incorrect (floating-point):
|
|
99
|
-
expr = 0.5 * x # Creates approximate value
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### 4. Numerical Evaluation When Needed
|
|
103
|
-
|
|
104
|
-
```python
|
|
105
|
-
from sympy import pi, sqrt
|
|
106
|
-
result = sqrt(8) + pi
|
|
107
|
-
result.evalf() # 5.96371554103586
|
|
108
|
-
result.evalf(50) # 50 digits of precision
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### 5. Convert to NumPy for Performance
|
|
112
|
-
|
|
113
|
-
```python
|
|
114
|
-
# Slow for many evaluations:
|
|
115
|
-
for x_val in range(1000):
|
|
116
|
-
result = expr.subs(x, x_val).evalf()
|
|
117
|
-
|
|
118
|
-
# Fast:
|
|
119
|
-
f = lambdify(x, expr, 'numpy')
|
|
120
|
-
results = f(np.arange(1000))
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 6. Use Appropriate Solvers
|
|
124
|
-
|
|
125
|
-
- `solveset`: Algebraic equations (primary)
|
|
126
|
-
- `linsolve`: Linear systems
|
|
127
|
-
- `nonlinsolve`: Nonlinear systems
|
|
128
|
-
- `dsolve`: Differential equations
|
|
129
|
-
- `solve`: General purpose (legacy, but flexible)
|
|
130
|
-
|
|
131
|
-
## Reference Files Structure
|
|
132
|
-
|
|
133
|
-
This skill uses modular reference files for different capabilities:
|
|
134
|
-
|
|
135
|
-
1. **`core-capabilities.md`**: Symbols, algebra, calculus, simplification, equation solving
|
|
136
|
-
- Load when: Basic symbolic computation, calculus, or solving equations
|
|
137
|
-
|
|
138
|
-
2. **`matrices-linear-algebra.md`**: Matrix operations, eigenvalues, linear systems
|
|
139
|
-
- Load when: Working with matrices or linear algebra problems
|
|
140
|
-
|
|
141
|
-
3. **`physics-mechanics.md`**: Classical mechanics, quantum mechanics, vectors, units
|
|
142
|
-
- Load when: Physics calculations or mechanics problems
|
|
143
|
-
|
|
144
|
-
4. **`advanced-topics.md`**: Geometry, number theory, combinatorics, logic, statistics
|
|
145
|
-
- Load when: Advanced mathematical topics beyond basic algebra and calculus
|
|
146
|
-
|
|
147
|
-
5. **`code-generation-printing.md`**: Lambdify, codegen, LaTeX output, printing
|
|
148
|
-
- Load when: Converting expressions to code or generating formatted output
|
|
149
|
-
|
|
150
|
-
## Common Use Case Patterns
|
|
151
|
-
|
|
152
|
-
### Pattern 1: Solve and Verify
|
|
153
|
-
|
|
154
|
-
```python
|
|
155
|
-
from sympy import symbols, solve, simplify
|
|
156
|
-
x = symbols('x')
|
|
157
|
-
|
|
158
|
-
# Solve equation
|
|
159
|
-
equation = x**2 - 5*x + 6
|
|
160
|
-
solutions = solve(equation, x) # [2, 3]
|
|
161
|
-
|
|
162
|
-
# Verify solutions
|
|
163
|
-
for sol in solutions:
|
|
164
|
-
result = simplify(equation.subs(x, sol))
|
|
165
|
-
assert result == 0
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Pattern 2: Symbolic to Numeric Pipeline
|
|
169
|
-
|
|
170
|
-
```python
|
|
171
|
-
# 1. Define symbolic problem
|
|
172
|
-
x, y = symbols('x y')
|
|
173
|
-
expr = sin(x) + cos(y)
|
|
174
|
-
|
|
175
|
-
# 2. Manipulate symbolically
|
|
176
|
-
simplified = simplify(expr)
|
|
177
|
-
derivative = diff(simplified, x)
|
|
178
|
-
|
|
179
|
-
# 3. Convert to numerical function
|
|
180
|
-
f = lambdify((x, y), derivative, 'numpy')
|
|
181
|
-
|
|
182
|
-
# 4. Evaluate numerically
|
|
183
|
-
results = f(x_data, y_data)
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Pattern 3: Document Mathematical Results
|
|
187
|
-
|
|
188
|
-
```python
|
|
189
|
-
# Compute result symbolically
|
|
190
|
-
integral_expr = Integral(x**2, (x, 0, 1))
|
|
191
|
-
result = integral_expr.doit()
|
|
192
|
-
|
|
193
|
-
# Generate documentation
|
|
194
|
-
print(f"LaTeX: {latex(integral_expr)} = {latex(result)}")
|
|
195
|
-
print(f"Pretty: {pretty(integral_expr)} = {pretty(result)}")
|
|
196
|
-
print(f"Numerical: {result.evalf()}")
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Integration with Scientific Workflows
|
|
200
|
-
|
|
201
|
-
### With NumPy
|
|
202
|
-
|
|
203
|
-
```python
|
|
204
|
-
import numpy as np
|
|
205
|
-
from sympy import symbols, lambdify
|
|
206
|
-
|
|
207
|
-
x = symbols('x')
|
|
208
|
-
expr = x**2 + 2*x + 1
|
|
209
|
-
|
|
210
|
-
f = lambdify(x, expr, 'numpy')
|
|
211
|
-
x_array = np.linspace(-5, 5, 100)
|
|
212
|
-
y_array = f(x_array)
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### With Matplotlib
|
|
216
|
-
|
|
217
|
-
```python
|
|
218
|
-
import matplotlib.pyplot as plt
|
|
219
|
-
import numpy as np
|
|
220
|
-
from sympy import symbols, lambdify, sin
|
|
221
|
-
|
|
222
|
-
x = symbols('x')
|
|
223
|
-
expr = sin(x) / x
|
|
224
|
-
|
|
225
|
-
f = lambdify(x, expr, 'numpy')
|
|
226
|
-
x_vals = np.linspace(-10, 10, 1000)
|
|
227
|
-
y_vals = f(x_vals)
|
|
228
|
-
|
|
229
|
-
plt.plot(x_vals, y_vals)
|
|
230
|
-
plt.show()
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### With SciPy
|
|
234
|
-
|
|
235
|
-
```python
|
|
236
|
-
from scipy.optimize import fsolve
|
|
237
|
-
from sympy import symbols, lambdify
|
|
238
|
-
|
|
239
|
-
# Define equation symbolically
|
|
240
|
-
x = symbols('x')
|
|
241
|
-
equation = x**3 - 2*x - 5
|
|
242
|
-
|
|
243
|
-
# Convert to numerical function
|
|
244
|
-
f = lambdify(x, equation, 'numpy')
|
|
245
|
-
|
|
246
|
-
# Solve numerically with initial guess
|
|
247
|
-
solution = fsolve(f, 2)
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## Quick Reference: Most Common Functions
|
|
251
|
-
|
|
252
|
-
```python
|
|
253
|
-
# Symbols
|
|
254
|
-
from sympy import symbols, Symbol
|
|
255
|
-
x, y = symbols('x y')
|
|
256
|
-
|
|
257
|
-
# Basic operations
|
|
258
|
-
from sympy import simplify, expand, factor, collect, cancel
|
|
259
|
-
from sympy import sqrt, exp, log, sin, cos, tan, pi, E, I, oo
|
|
260
|
-
|
|
261
|
-
# Calculus
|
|
262
|
-
from sympy import diff, integrate, limit, series, Derivative, Integral
|
|
263
|
-
|
|
264
|
-
# Solving
|
|
265
|
-
from sympy import solve, solveset, linsolve, nonlinsolve, dsolve
|
|
266
|
-
|
|
267
|
-
# Matrices
|
|
268
|
-
from sympy import Matrix, eye, zeros, ones, diag
|
|
269
|
-
|
|
270
|
-
# Logic and sets
|
|
271
|
-
from sympy import And, Or, Not, Implies, FiniteSet, Interval, Union
|
|
272
|
-
|
|
273
|
-
# Output
|
|
274
|
-
from sympy import latex, pprint, lambdify, init_printing
|
|
275
|
-
|
|
276
|
-
# Utilities
|
|
277
|
-
from sympy import evalf, N, nsimplify
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
## Getting Started Examples
|
|
281
|
-
|
|
282
|
-
### Example 1: Solve Quadratic Equation
|
|
283
|
-
```python
|
|
284
|
-
from sympy import symbols, solve, sqrt
|
|
285
|
-
x = symbols('x')
|
|
286
|
-
solution = solve(x**2 - 5*x + 6, x)
|
|
287
|
-
# [2, 3]
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### Example 2: Calculate Derivative
|
|
291
|
-
```python
|
|
292
|
-
from sympy import symbols, diff, sin
|
|
293
|
-
x = symbols('x')
|
|
294
|
-
f = sin(x**2)
|
|
295
|
-
df_dx = diff(f, x)
|
|
296
|
-
# 2*x*cos(x**2)
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### Example 3: Evaluate Integral
|
|
300
|
-
```python
|
|
301
|
-
from sympy import symbols, integrate, exp
|
|
302
|
-
x = symbols('x')
|
|
303
|
-
integral = integrate(x * exp(-x**2), (x, 0, oo))
|
|
304
|
-
# 1/2
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### Example 4: Matrix Eigenvalues
|
|
308
|
-
```python
|
|
309
|
-
from sympy import Matrix
|
|
310
|
-
M = Matrix([[1, 2], [2, 1]])
|
|
311
|
-
eigenvals = M.eigenvals()
|
|
312
|
-
# {3: 1, -1: 1}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### Example 5: Generate Python Function
|
|
316
|
-
```python
|
|
317
|
-
from sympy import symbols, lambdify
|
|
318
|
-
import numpy as np
|
|
319
|
-
x = symbols('x')
|
|
320
|
-
expr = x**2 + 2*x + 1
|
|
321
|
-
f = lambdify(x, expr, 'numpy')
|
|
322
|
-
f(np.array([1, 2, 3]))
|
|
323
|
-
# array([ 4, 9, 16])
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
## Troubleshooting Common Issues
|
|
327
|
-
|
|
328
|
-
1. **"NameError: name 'x' is not defined"**
|
|
329
|
-
- Solution: Always define symbols using `symbols()` before use
|
|
330
|
-
|
|
331
|
-
2. **Unexpected numerical results**
|
|
332
|
-
- Issue: Using floating-point numbers like `0.5` instead of `Rational(1, 2)`
|
|
333
|
-
- Solution: Use `Rational()` or `S()` for exact arithmetic
|
|
334
|
-
|
|
335
|
-
3. **Slow performance in loops**
|
|
336
|
-
- Issue: Using `subs()` and `evalf()` repeatedly
|
|
337
|
-
- Solution: Use `lambdify()` to create a fast numerical function
|
|
338
|
-
|
|
339
|
-
4. **"Can't solve this equation"**
|
|
340
|
-
- Try different solvers: `solve`, `solveset`, `nsolve` (numerical)
|
|
341
|
-
- Check if the equation is solvable algebraically
|
|
342
|
-
- Use numerical methods if no closed-form solution exists
|
|
343
|
-
|
|
344
|
-
5. **Simplification not working as expected**
|
|
345
|
-
- Try different simplification functions: `simplify`, `factor`, `expand`, `trigsimp`
|
|
346
|
-
- Add assumptions to symbols (e.g., `positive=True`)
|
|
347
|
-
- Use `simplify(expr, force=True)` for aggressive simplification
|
|
348
|
-
|
|
349
|
-
## Additional Resources
|
|
350
|
-
|
|
351
|
-
- Official Documentation: https://docs.sympy.org/
|
|
352
|
-
- Tutorial: https://docs.sympy.org/latest/tutorials/intro-tutorial/index.html
|
|
353
|
-
- API Reference: https://docs.sympy.org/latest/reference/index.html
|
|
354
|
-
- Examples: https://github.com/sympy/sympy/tree/master/examples
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: systematic-debugging
|
|
3
|
-
description: "Disciplined root-cause debugging methodology. Mandatory 4-phase investigation before attempting code fixes."
|
|
4
|
-
risk: low
|
|
5
|
-
source: built-in
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Systematic Debugging
|
|
9
|
-
|
|
10
|
-
## Core Principle
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Random trial-and-error fixes waste time and create regressions. Always isolate the root cause before editing code.
|
|
17
|
-
|
|
18
|
-
## The 4 Phases of Debugging
|
|
19
|
-
|
|
20
|
-
### Phase 1: Root Cause Investigation
|
|
21
|
-
1. **Read errors and logs completely**: Analyze stack traces, line numbers, error codes, and symptoms.
|
|
22
|
-
2. **Reproduce the bug reliably**: Formulate a minimal reproduction test or shell command.
|
|
23
|
-
3. **Trace data flow end-to-end**: Trace inputs from entry boundary to failure point.
|
|
24
|
-
|
|
25
|
-
### Phase 2: Hypothesis & Verification
|
|
26
|
-
1. Formulate a specific hypothesis explaining why the failure occurs.
|
|
27
|
-
2. Test the hypothesis using logs, asserts, or focused diagnostics.
|
|
28
|
-
|
|
29
|
-
### Phase 3: Surgical Fix
|
|
30
|
-
1. Fix the underlying root cause at the source, not just the symptom.
|
|
31
|
-
2. Ensure the fix is minimal and edge-case correct.
|
|
32
|
-
|
|
33
|
-
### Phase 4: Regression Prevention
|
|
34
|
-
1. Run the reproduction test and confirm it now passes.
|
|
35
|
-
2. Run the entire test suite to ensure zero collateral breakage.
|