-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: FTestPower always Fails to converge on a solution, wrong names, unclear usage #8646
Comments
Actually, I do get some convergence:
but here the effect is crazy high - |
effectsize for FTestAnovaPower is Cohen's f (sqrt of f2) The effect size for FTestPower is also Cohen's f, (according to the unit test) I don't remember the details for the F-test effect sizes and how to compute Cohen's f. |
doc problem e.g. https://www.statsmodels.org/dev/generated/statsmodels.stats.power.FTestPower.solve_power.html
|
I found a stackoverflow question that uses r_squared from OLS this uses |
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3328081/ also but power classes uses f = sqrt(f2) |
|
Right, so Cohen's f=0.314 for correlation r=0.3 and it should be a valid effect size for
warns |
just guessing, trying out an example. The following seems to be like what the unit test does. nobs is not used.
I need to check later why this is. No time for this right now. |
(I had made a comment here, but I guess I closed the tab without sending it) The stackoverflow mentioned reversing df_num and df_denom. This turns out to be a naming bug. I opened #8651. For backwards compatibility I will change only the docstring for now. using df_denom=1 and solving for df_num = nobs - df_resid, I get
note FTestPower has similar signature as pwr.f2.test with two differences
|
PR #8656 added new class FTestPowerF2 |
edit (josef)
FTestPower mixes up df_num, df_denom names of keywords, meaning is reversed.
Code itself works correctly but not obvious how to use it.
Describe the bug
I am trying to do a power analysis for regression - compute the number of necessary observations.
No matter what parameters I supply, I get
and the return value is
array([3.])
.Code Sample, a copy-pastable example if possible
I assume that the effect size is
f^2=r^2/(1-r^2)
(Cohen's f^2).This is a simple regression, so
df=1
.Expected Output
I expect a single number returned - at least for some inputs, no warnings.
Output of
import statsmodels.api as sm; sm.show_versions()
INSTALLED VERSIONS
Python: 3.10.6.final.0
OS: Linux 6.0.6-76060006-generic #202210290932
166906205022.04~d94609a SMP PREEMPT_DYNAMIC Mon N x86_64byteorder: little
LC_ALL: None
LANG: C.UTF-8
statsmodels
Installed: 0.13.5 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/statsmodels)
Required Dependencies
cython: Not installed
numpy: 1.24.1 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/numpy)
scipy: 1.10.0 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/scipy)
pandas: 1.5.3 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/pandas)
dateutil: 2.8.2 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/dateutil)
patsy: 0.5.3 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/patsy)
Optional Dependencies
matplotlib: 3.6.3 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/matplotlib)
backend: module://matplotlib_inline.backend_inline
cvxopt: Not installed
joblib: 1.2.0 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/joblib)
Developer Tools
IPython: 8.9.0 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/IPython)
jinja2: 3.1.2 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/jinja2)
sphinx: Not installed
pygments: 2.14.0 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/pygments)
pytest: 7.2.1 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/pytest)
virtualenv: 20.17.1 (/home/sds/.virtualenvs/myself/lib/python3.10/site-packages/virtualenv)
The text was updated successfully, but these errors were encountered: