问题描述
我对 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,)
这是对 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