stat-fit-linear-model
Fit a linear regression model, report coefficients and model fit, and generate residual diagnostic plots.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- stat-fit-linear-model
- description
- Fit a linear regression model, report coefficients and model fit, and generate residual diagnostic plots.
02 资源文件 3
- 参考文档agents/claude.yaml354 B
- 参考文档agents/openai.yaml355 B
- 参考文档config.yaml287 B
03 SKILL.md 正文
Skill: Linear Regression Modeling
Use When
- User wants to model the linear relationship between a continuous outcome and one or more predictors
- User needs coefficient estimates, confidence intervals, and p-values for each predictor
- User wants to assess model fit (R², adjusted R²) and check regression assumptions
- Use cases include: gene expression vs. age, protein concentration vs. metabolic rate, any dose-response relationship
Inputs
- Required:
- Data table (CSV or TSV) with a numeric response variable and one or more numeric or categorical predictor columns
- Response (outcome) variable name
- Predictor variable name(s)
- Optional:
- Interaction terms (e.g.,
var1:var2) - Standardize predictors:
trueorfalse(default:false) - Output directory (default:
./lm_output)
- Interaction terms (e.g.,
Workflow
- Read data; validate that response and predictor columns exist and are appropriate types.
- Encode categorical predictors as dummy variables (reference level = first alphabetical level).
- Fit the linear model:
response ~ predictorsusing ordinary least squares. - Report for each coefficient: estimate, standard error, t-statistic, p-value, 95% confidence interval.
- Report model fit: R², adjusted R², F-statistic, overall p-value, AIC, BIC.
- Generate residual diagnostic plots: (a) residuals vs. fitted, (b) Q-Q plot of residuals, (c) scale-location, (d) Cook's distance.
- Test regression assumptions: normality of residuals (Shapiro-Wilk), homoscedasticity (Breusch-Pagan), absence of influential points (Cook's distance > 4/n).
- Write results table (TSV), model summary (text), and diagnostic plots (PDF) to output directory.
- Save the executable analysis script (
analysis_code.pyoranalysis_code.R) and software version manifest (session_info.txt) used to produce results.
Output Contract
- Coefficient table (TSV): term, estimate, std_error, t_statistic, p_value, ci_lower, ci_upper
- Model fit summary (TSV): r_squared, adj_r_squared, f_statistic, f_p_value, aic, bic, n
- Residual diagnostic plots (PDF, 4-panel)
- Assumption test results (printed to stdout)
- Reproducibility artifacts:
analysis_code.pyoranalysis_code.R, plussession_info.txt
Limits
- Assumes linearity, independence, homoscedasticity, and normality of residuals — check diagnostic plots.
- Does not handle multicollinearity automatically; check VIF (variance inflation factor) separately if many predictors.
- Not suitable for count data, binary outcomes, or data with heavy censoring — use
stat-fit-glminstead. - Common failure: near-perfect multicollinearity among predictors causes singular matrix error.
04 同仓库更多 Skills
structured-intelligence-skill-creator
Create or update repository skills that conform to local templates, provider metadata requirements, registry rules, and validation workflows.
stat-survival-analysis
Estimate and compare survival functions using Kaplan-Meier curves and log-rank test, with optional Cox proportional hazards regression.
stat-pca
Perform PCA on a numeric data matrix to reduce dimensionality, visualize sample structure, and identify top contributing features.
stat-pairwise-correlation
Compute pairwise correlations and significance tests across all numeric variables, and produce a correlation heatmap.
stat-nonlinear-embedding
Embed high-dimensional data into 2D using t-SNE or UMAP for exploratory visualization of sample or cell relationships.
stat-logistic-regression
Fit a logistic regression model for binary outcomes, report odds ratios and model performance (AUC-ROC, confusion matrix).