[英]Statsmodels Confidence Interval for Difference in Means
I wanted to find the confidence interval for the difference between two means (Male vs Female).我想找到两种平均值(男性与女性)之间差异的置信区间。 I browsed on the index for statsmodels and found the function below.
我浏览了 statsmodels 的索引,在下面找到了 function。 However it didn't explain where should I specify the Male and Female series.
但是它没有解释我应该在哪里指定男性和女性系列。 Please advise.
请指教。
Function: Function:
CompareMeans.tconfint_diff(alpha=0.05, alternative='two-sided', usevar='pooled')
Documentation: https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.CompareMeans.tconfint_diff.html文档: https://www.statsmodels.org/stable/generated/statsmodels.stats.weightstats.CompareMeans.tconfint_diff.html
The descriptive statistics of the two series should be passed to the CompareMeans
class in DescrStatsW
format.两个系列的描述性统计应以
DescrStatsW
格式传递给CompareMeans
class。 After that you can use the tconfint_diff
method of the CompareMeans
class to obtain the confidence interval for the difference in means.之后,您可以使用
CompareMeans
class 的tconfint_diff
方法来获取均值差异的置信区间。
import pandas as pd
import numpy as np
from statsmodels.stats.weightstats import DescrStatsW, CompareMeans
df = pd.DataFrame({
'Male': np.random.normal(loc=50, scale=5, size=100),
'Female': np.random.normal(loc=50, scale=25, size=100),
})
cm = CompareMeans(d1=DescrStatsW(data=df['Male']), d2=DescrStatsW(data=df['Female']))
lower, upper = cm.tconfint_diff(alpha=0.05, alternative='two-sided', usevar='unequal')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.