Code Monkey home page Code Monkey logo

power1d's Issues

struggling to install power1d

Hello,

I am new to Python. Managed to download and work it in vscode, but I am not able to install power1d. I installed spm1d, but
it gives me this error when I try to install power1d using either of the below methods:

PS F:> py -m easy_install power1d
WARNING: The easy_install command is deprecated and will be removed in a future version.
Processing power1d
error: Couldn't find a setup script in F:\power1d

PS F:> py -m pip install power1d
ERROR: Could not find a version that satisfies the requirement power1d
ERROR: No matching distribution found for power1d

Your help would be much appreciated.

Thank you.
Mat

Error when running the sample size code

Dr. Pataky, Nice to meet you.
When I ran the sample size calculation code, an error happened when aiming at some signal location (q). I have no idea how to solve it. I would appreciate it if you could help me.

############################################################ The code is

(0) Create geometry and noise models:

JA, JB, Q = 55, 55, 101 # J(X) = No of subjects; Q= time points;

sample I

xata01 = pd.read_csv("D:\Python\learnsample\data1.csv", sep=',', header=None)
m_data1 = np.array(xata01.values)[0]
signal1 = power1d.geom.Continuum1D(m_data1)

Sample II

xata02 = pd.read_csv("D:\Python\learnsample\data2.csv", sep=',', header=None)
m_data2 = np.array(xata02.values)[0]
signal2 = power1d.geom.Continuum1D(m_data2)

Baseline

baseline = power1d.geom.Continuum1D(m_data1)

noise

data03 = pd.read_csv("D:\Python\learnsample\allstd.csv", sep=',', header=None)
std003 = np.array(data03.values)[0]
noise3 = power1d.noise.SmoothGaussian(JB, Q, mu=0, sigma=std003[0], fwhm=28)

Create data sample models:

modelA0 = power1d.models.DataSample(baseline, signal1, noise3, J=JA) # null A
modelB0 = power1d.models.DataSample(baseline, signal1, noise3, J=JB) # null B
modelA1 = power1d.models.DataSample(baseline, signal1, noise3, J=JA) # alternative A
modelB1 = power1d.models.DataSample(baseline, signal2, noise3, J=JB) # alternative B

iteratively simulate for a range of sample sizes:

np.random.seed(0) #seed the random number generator
JJ = [3, 4, 5, 6, 7, 8, 9, 10] #sample sizes
teststat = power1d.stats.t_2sample_fn(JA, JB)
expmodel0 = power1d.models.Experiment([modelA0, modelB0], teststat) #null
expmodel1 = power1d.models.Experiment([modelA1, modelB1], teststat) #alternative
sim = power1d.ExperimentSimulator(expmodel0, expmodel1)
q = 80 # signal location
results = sim.sample_size(power=0.8, alpha=0.05, niter0=200, niter=2000, coi=dict(q=q, r=3))

retrieve estimated sample size:

n = results['nstar']
print(f'Estimate sample size = {n}')

plot:

plt.figure()
ax = plt.axes()
ax.plot( results['n'], results['p'], 'o-')
ax.axhline( results['target_power'] , color='k', linestyle='--')
ax.set_xlabel('Sample size', size=14)
ax.set_ylabel('Power', size=14)
plt.show()

################################################### the error showed
D:\Python\Python312\python.exe "D:\Python\project\pythonProject\samplesize-two sample.py"
Traceback (most recent call last):
File "D:\Python\project\pythonProject\samplesize-two sample.py", line 48, in
results = sim.sample_size(power=0.8, alpha=0.05, niter0=200, niter=2000, coi=dict(q=q, r=3))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python\Python312\Lib\site-packages\power1d\models.py", line 711, in sample_size
ind = np.argwhere( ps > power ).ravel()[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 0 is out of bounds for axis 0 with size 0

Process finished with exit code 1

######################################################

How to make a signal for post-hoc power analysis in paired t-tests

Dr. Pataky, Nice to meet you.
I have a question about the post-hoc power analysis using Power1D.

I am testing the reproducibility of sensor data with 101 time points and I have 2 sessions of data for 30 people.
The data from the first and second session did not differ according to the Paired t-test in SPM1d.

I have performed a posteriori power test for this test using the following code.

#########################
J = 30 # No of subjects
Q = 101 # time points

data0 = np.loadtxt(file)
first_data = data0[:,0] # mean data in 30 subjects. 1101 array
second_data = data0[:,1] # mean data in 30 subjects. 1
101 array
diff_data = data0[:,2] # diff_data: first_data-second_data
diff_sd = data0[0,3] # standard deviation of diff_data

data_bl = power1d.geom.Null( Q ) # baseline
data0_sig0 = power1d.geom.Null( Q ) # null signal - needed for null power model
data0_sig1 = power1d.geom.Continuum1D( diff_data ) #signal
data0_nse = power1d.noise.SmoothGaussian( J , Q , mu = 0 , sigma = diff_sd , fwhm = 20 ) #Noise
data0_mod0 = power1d.models.DataSample( data0_bl, data_sig0, data0_nse, J ) # null for power analysis
data0_mod1 = power1d.models.DataSample( data0_bl, data_sig1, data0_nse, J ) # alternative

power_analysis(data0_mod0,data0_mod1)
########################

According to your papter in J of Biomech.(doi: 10.1016/j.jbiomech.2021.110451.)
and its supplementary code (https://github.com/m-a-robinson/sample-size/blob/main/creating_1d_effects.py),
you made the data_sig1 using GaussianPulse objects.

Since my analysis is a post-hoc power analysis and we already know the mean data to be compared,
I made the data0_sig1 as a Continuum1D objects containing the difference data between 1st and 2nd sessions.
It it appropreate procedure?

I would appreciate it if you could help me.

Hierarchical (two-level) Random Effects Model

Hi Todd,

I'm trying to determine the steps when using power1d for a hierarchical (two-level) random effects model as outlined here in spm1d.

I'm assuming the actual analysis is based on simulating the beta continuum estimates and then running stats.t_1sample( ).

Would the steps here be to create data sample models for the regression, generate the beta coefficients (perhaps with spm1d) and using those in creating the experimental models?

If you had an example matching the data for spm1d I think that would be helpful.

Thanks!

Feature requests

This thread contains a collection of feature requests that will (or may) be implemented in a future version of power1d:



Requested features:

  • Repeated measures designs
  • Automated power parameter estimation from datasets
  • Graphical interface

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.