0todd0000 / power1d Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
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
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
JA, JB, Q = 55, 55, 101 # J(X) = No of subjects; Q= time points;
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)
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 = power1d.geom.Continuum1D(m_data1)
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)
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
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))
n = results['nstar']
print(f'Estimate sample size = {n}')
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
######################################################
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. 1101 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.
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!
This thread contains a collection of feature requests that will (or may) be implemented in a future version of power1d:
Requested features:
Hi Todd,
I'm wondering if there are additional considerations for extending the One-way ANOVA Example for repeated measures?
Best,
Jereme
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.