Skip to content

Commit 0ce20b1

Browse files
committed
Update example.
1 parent 4ccace9 commit 0ce20b1

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

examples/02_meta-analysis/plot_meta-analysis_walkthrough.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,24 @@ def var_to_ci(y, v, n):
145145
# The two combination models in PyMARE are Stouffer's and Fisher's Tests.
146146
#
147147
# Notice that these models don't use :class:`pymare.core.Dataset` objects.
148-
stouff = pymare.estimators.Stouffers(input='z')
149-
stouff.fit(y=z[:, None])
150-
stouff_summary = stouff.summary()
148+
stouff = pymare.estimators.StoufferCombinationTest()
149+
stouff.fit(z[:, None])
151150
print('Stouffers')
152-
print('z: {}'.format(stouff_summary.z))
153-
print('p: {}'.format(stouff_summary.p))
151+
print('p: {}'.format(stouff.params_["p"]))
154152
print()
155153

156-
fisher = pymare.estimators.Fishers(input='z')
157-
fisher.fit(y=z[:, None])
158-
fisher_summary = fisher.summary()
154+
fisher = pymare.estimators.FisherCombinationTest()
155+
fisher.fit(z[:, None])
159156
print('Fishers')
160-
print('z: {}'.format(fisher_summary.z))
161-
print('p: {}'.format(fisher_summary.p))
157+
print('p: {}'.format(fisher.params_["p"]))
162158

163159
###############################################################################
164160
# Now we have a fixed effects model
165161
# `````````````````````````````````````````````````````````````````````````````
166162
# This estimator does not attempt to estimate between-study variance.
167163
# Instead, it takes ``tau2`` (:math:`\tau^{2}`) as an argument.
168164
wls = pymare.estimators.WeightedLeastSquares()
169-
wls.fit(dset)
165+
wls.fit_dataset(dset)
170166
wls_summary = wls.summary()
171167
results['Weighted Least Squares'] = wls_summary.to_df()
172168
print('Weighted Least Squares')
@@ -184,31 +180,31 @@ def var_to_ci(y, v, n):
184180
# can use either maximum-likelihood (ML) or restricted maximum-likelihood (REML)
185181
# to iteratively estimate it.
186182
dsl = pymare.estimators.DerSimonianLaird()
187-
dsl.fit(dset)
183+
dsl.fit_dataset(dset)
188184
dsl_summary = dsl.summary()
189185
results['DerSimonian-Laird'] = dsl_summary.to_df()
190186
print('DerSimonian-Laird')
191187
print(dsl_summary.to_df().T)
192188
print()
193189

194190
hedge = pymare.estimators.Hedges()
195-
hedge.fit(dset)
191+
hedge.fit_dataset(dset)
196192
hedge_summary = hedge.summary()
197193
results['Hedges'] = hedge_summary.to_df()
198194
print('Hedges')
199195
print(hedge_summary.to_df().T)
200196
print()
201197

202198
vb_ml = pymare.estimators.VarianceBasedLikelihoodEstimator(method='ML')
203-
vb_ml.fit(dset)
199+
vb_ml.fit_dataset(dset)
204200
vb_ml_summary = vb_ml.summary()
205201
results['Variance-Based with ML'] = vb_ml_summary.to_df()
206202
print('Variance-Based with ML')
207203
print(vb_ml_summary.to_df().T)
208204
print()
209205

210206
vb_reml = pymare.estimators.VarianceBasedLikelihoodEstimator(method='REML')
211-
vb_reml.fit(dset)
207+
vb_reml.fit_dataset(dset)
212208
vb_reml_summary = vb_reml.summary()
213209
results['Variance-Based with REML'] = vb_reml_summary.to_df()
214210
print('Variance-Based with REML')
@@ -219,15 +215,15 @@ def var_to_ci(y, v, n):
219215
# using ``y`` and ``n``, but assumes within-study variance is homogenous
220216
# across studies.
221217
sb_ml = pymare.estimators.SampleSizeBasedLikelihoodEstimator(method='ML')
222-
sb_ml.fit(dset)
218+
sb_ml.fit_dataset(dset)
223219
sb_ml_summary = sb_ml.summary()
224220
results['Sample Size-Based with ML'] = sb_ml_summary.to_df()
225221
print('Sample Size-Based with ML')
226222
print(sb_ml_summary.to_df().T)
227223
print()
228224

229225
sb_reml = pymare.estimators.SampleSizeBasedLikelihoodEstimator(method='REML')
230-
sb_reml.fit(dset)
226+
sb_reml.fit_dataset(dset)
231227
sb_reml_summary = sb_reml.summary()
232228
results['Sample Size-Based with REML'] = sb_reml_summary.to_df()
233229
print('Sample Size-Based with REML')

0 commit comments

Comments
 (0)