微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Statsmodels 功效分析观察次数

如何解决Statsmodels 功效分析观察次数

我对 TTestIndPower 类的 statsmodels API 感到困惑。

--- AlignConsecutiveMacros: 'true' AlignConsecutiveAssignments: 'true' AlignConsecutiveDeclarations: 'true' AlignTrailingComments: 'true' AllowAllConstructorInitializersOnNextLine: 'false' AllowAllParametersOfDeclarationOnNextLine: 'false' AllowShortBlocksOnASingleLine: 'false' AllowShortCaseLabelsOnASingleLine: 'false' AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: Inline AllowShortLoopsOnASingleLine: 'true' BinPackArguments: 'false' BinPackParameters: 'false' BreakBeforeBraces: Allman IndentWidth: '4' SpaceAfterCStyleCast: 'true' SpaceBeforeCpp11BracedList: 'true' SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: 'true' SpaceInEmptyParentheses: 'false' SpacesInAngles: 'false' SpacesInCStyleCastParentheses: 'false' SpacesInContainerLiterals: 'false' SpacesInParentheses: 'false' Standard: Latest TabWidth: '0' UseTab: Never Pointeralignment: Left ColumnLimit: 0 ... 函数中,绘制的观察数是样本总数还是每组的样本数?

解决方法

每组。

这是我用 statsmodels 生成的 power_plot

from statsmodels.stats.power import TTestIndPower

panalysis = TTestIndPower()

panalysis.plot_power(
    dep_var="nobs",nobs=np.arange(5,101),effect_size=np.arange(0.5,1.5,.2),alpha=0.01,ax=ax,)

enter image description here

这是对 R 的确认,效果大小 (es) 为 0.7

> library(pwr)
> pwr.t.test(power = 0.8,sig.level = 0.01,d = 0.7)

 Two-sample t test power calculation 

          n = 49.35336
          d = 0.7
  sig.level = 0.01
      power = 0.8
  alternative = two.sided

 NOTE: n is number in *each* group

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。