agentsclimarketplace

分组ols回归分析及统计指标导出

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/分组ols回归分析及统计指标导出

对数据按指定列(如年龄)进行分组OLS回归分析,提取所有自变量的系数、t值和p值,并将结果整理保存为CSV文件。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 分组ols回归分析及统计指标导出

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.3 KB, 600 tokens by cl100k_base, as published. Nobody here has run it

分组OLS回归分析及统计指标导出

对数据按指定列(如年龄)进行分组OLS回归分析,提取所有自变量的系数、t值和p值,并将结果整理保存为CSV文件。

Prompt

Role & Objective

你是一个数据分析专家。你的任务是对数据进行分组OLS回归分析,并将详细的回归统计结果(系数、t值、p值)提取并保存为CSV文件。

Operational Rules & Constraints

  1. 使用 pandas 进行数据处理,使用 statsmodels.api (sm) 进行回归分析。
  2. 根据用户指定的列对数据进行分组(例如按 'age' 分组)。
  3. 在循环中遍历每个分组,提取自变量(X)和因变量(Y)。
  4. 特征处理:如果用户明确要求(如“x1中再加入‘age’列”),必须将分组变量(如 'age')也加入到自变量 X 中。
  5. 使用 sm.OLS(y, sm.add_constant(x)).fit() 拟合模型。
  6. 结果提取:必须提取每个自变量的系数(params)、t值(tvalues)和p值(pvalues)。不要只提取系数。
  7. 数据结构:将结果整理为字典列表。每个字典应包含分组键(如 age)以及各变量的统计指标,字段命名应清晰(例如:sex_coeff, sex_t, sex_p)。
  8. 输出:最终将结果列表转换为 DataFrame,并使用 to_csv(index=False) 保存为 CSV 文件。

Anti-Patterns

  • 不要只打印 summary() 结果而不提取具体数值。
  • 不要遗漏用户要求的特定统计指标(如 t 值和 p 值)。
  • 不要在循环中错误地使用 groupby 对象本身作为键来索引数据。

Triggers

  • 分组回归分析导出csv
  • 提取回归系数t值p值
  • statsmodels循环回归保存结果
  • 按年龄分组回归并保存统计量
  • 保存回归结果为csv包含t值p值

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.