Skip to content

Instantly share code, notes, and snippets.

@marsja
Created July 3, 2017 09:39
Show Gist options
  • Save marsja/c44c35a08c783007db99d2e00ceb660f to your computer and use it in GitHub Desktop.
Save marsja/c44c35a08c783007db99d2e00ceb660f to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "import numpy as np\nnp.__version__",
"execution_count": 1,
"outputs": [
{
"execution_count": 1,
"output_type": "execute_result",
"data": {
"text/plain": "'1.11.0'"
},
"metadata": {}
}
]
},
{
"metadata": {
"collapsed": true,
"trusted": true
},
"cell_type": "code",
"source": "import pyvttbl as pt\nfrom collections import namedtuple\n\nN = 40\nP = [\"noise\",\"quiet\"]\nrts = [998,511]\nmus = rts*N\n\nSub = namedtuple('Sub', ['Sub_id', 'rt','condition']) \ndf = pt.DataFrame()\nfor subid in xrange(0,N):\n for i,condition in enumerate(P):\n df.insert(Sub(subid+1,\n np.random.normal(mus[i], scale=112., size=1)[0],\n condition)._asdict()) \n",
"execution_count": 2,
"outputs": []
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "aov = df.anova('rt', sub='Sub_id', wfactors=['condition'])\nprint(aov)",
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "rt ~ condition\n\nTESTS OF WITHIN SUBJECTS EFFECTS\n\nMeasure: rt\n Source Type III eps df MS F Sig. et2_G Obs. SE 95% CI lambda Obs. \n SS Power \n=====================================================================================================================================================\ncondition Sphericity Assumed 6094043.697 - 1 6094043.697 800.926 1.308e-27 8.887 40 14.233 27.897 821.462 1 \n Greenhouse-Geisser 6094043.697 1 1 6094043.697 800.926 1.308e-27 8.887 40 14.233 27.897 821.462 1 \n Huynh-Feldt 6094043.697 1 1 6094043.697 800.926 1.308e-27 8.887 40 14.233 27.897 821.462 1 \n Box 6094043.697 1 1 6094043.697 800.926 1.308e-27 8.887 40 14.233 27.897 821.462 1 \n-----------------------------------------------------------------------------------------------------------------------------------------------------\nError(condition) Sphericity Assumed 296741.276 - 39 7608.751 \n Greenhouse-Geisser 296741.276 1 39 7608.751 \n Huynh-Feldt 296741.276 1 39 7608.751 \n Box 296741.276 1 39 7608.751 \n\nTABLES OF ESTIMATED MARGINAL MEANS\n\nEstimated Marginal Means for condition\ncondition Mean Std. Error 95% Lower Bound 95% Upper Bound \n=====================================================================\nnoise 1028.422 15.749 997.555 1059.290 \nquiet 476.424 13.840 449.298 503.550 \n\n\n"
},
{
"output_type": "stream",
"name": "stderr",
"text": "/home/erik/Documents/Programming/Python/pyvttbl_env/local/lib/python2.7/site-packages/pyvttbl/stats/_anova.py:1240: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future\n return list(array(list(zeros((p-len(b))))+b)+1.)\n"
}
]
},
{
"metadata": {
"collapsed": true,
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "pyvttbl_env",
"display_name": "pyvttbl_env",
"language": "python"
},
"language_info": {
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"name": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12",
"file_extension": ".py",
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"version_major": 1,
"version_minor": 0,
"state": {}
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment