Giter Site home page Giter Site logo

sakai-book's People

Contributors

jerome-white avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

sakai-book's Issues

Inaccurate power calculations for this F-test

There are discrepancies between the values statsmodels F-test power calculations produce
and those from R.

Consider the following R program (specifically taken from 2waynorep):

library(pwr)
fstat <- 0.63
m <- 4
n <- 17
alpha <- 0.05
pwr.f2.test(u=m-1, v=(m-1)*(n-1), f2=fstat, sig.level=alpha)$power

Produces 0.9984019. However, the "semantically" equivalent Python program:

from statsmodels.stats.power import FTestPower

(fstat, m, n, alpha) = (0.63, 4, 17, 0.05)
kwargs = {
    'effect_size': fstat / (n - 1),
    'df_num': m - 1,
    'df_denom': (m - 1) * (n - 1),
    'alpha': 0.05,
}

fpow = FTestPower()
print(fpow.solve_power(**kwargs))

Produces 0.05011698892318561.

According to blog post by Josef Perktold (section titled, "F-Test for linear Model"), the correct way to use solve_power is to interpret the arguments differently. When applying the logic laid out in the corresponding section of that post:

import math
from statsmodels.stats.power import FTestPower

(fstat, m, n, alpha) = (0.63, 4, 17, 0.05)
kwargs = {
    'effect_size': math.sqrt(fstat / (n - fstat)),
    'df_denom': m - 1,
    'df_num': (m - 1) * (n - 1),
    'alpha': 0.05,
}

fpow = FTestPower()
print(fpow.solve_power(**kwargs))

Produces 0.18002339044585902, which, although not exactly what is seen in R, is much closer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.