gpt4 book ai didi

python - 查找 ANOVA 第一个线性模型的 F 统计值

转载 作者:行者123 更新时间:2023-11-30 08:53:38 25 4
gpt4 key购买 nike

我正在查看 python 主题的统计数据。我用一只手就震惊了。

问题陈述:

Perform ANOVA on the first linear model obtained while working with mtcars data set. Display the F-statistic value.

我对问题陈述做了什么:

import statsmodels.api as sm    
import statsmodels.formula.api as smf
from statsmodels.stats import anova

mtcars_data = sm.datasets.get_rdataset("mtcars").data
print(mtcars_data.columns)

mt_model1 = smf.ols('mpg ~ cyl', mtcars_data ).fit()
print(anova.anova_lm(mt_model1))

output

如何显示上述问题的F统计数据?

最佳答案

因此,如果您想从 anova 表中获取 cyl 属性的 F 统计值,请像这样

print(anova.anova_lm(mt_model1).F["cyl"])

关于python - 查找 ANOVA 第一个线性模型的 F 统计值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51093906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com