Skip to content

Commit

Permalink
DOC recipes: group-level analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Feb 9, 2017
1 parent 0187cde commit 0878b75
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,44 @@
Recipes
*******

.. contents:: Contents
:local:


^^^^^^^^^^^^^^^^^^^^
Group Level Analysis
^^^^^^^^^^^^^^^^^^^^

To do group level analysis one usually wants to construct a :class:`Dataset`
that contains results for each participants along with condition and subhect
labels. Assuming a function that computes the result for a single subject and
condition as :class:`NDVar`, ``result_for(subject, condition)`` this is easy to
achieve::

# create lists to collect data and labels
>>> ndvars = []
>>> subjects = []
>>> conditions = []
# collect data and labels
>>> for subject in ('s1', 's2', 's3', ...):
... for condition in ('c1, 'c2', ...):
... ndvar = result_for(subject, condition)
... ndvars.append(ndvar)
... subjects.append(subject)
... conditions.append(condition)
...
# create a Dataset and convert the collected lists to appropriate format
>>> ds = Dataset()
>>> ds['subject'] = Factor(subjects, random=True) # treat as random effect
>>> ds['condition'] = Factor(conditions)
>>> ds['y'] = combine(ndvars)


Now this Dataset can be used for statistical analysis, for example, ANOVA:

>>> res = testnd.anova('y', 'condition * subject', ds=ds)


.. _recipe-regression:

^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 0878b75

Please sign in to comment.