{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to mathematical statistics \n", "\n", "Welcome to the lecture 13 in 02403\n", "\n", "During the lectures we will present both slides and notebooks. \n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import scipy.stats as stats\n", "import statsmodels.api as sm\n", "import statsmodels.formula.api as smf\n", "import statsmodels.stats.power as smp\n", "import statsmodels.stats.proportion as smprop" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
valuetreatment
0271
1221
2181
3261
4241
5322
6222
7322
8252
9252
10293
11253
12303
13303
14243
\n", "
" ], "text/plain": [ " value treatment\n", "0 27 1\n", "1 22 1\n", "2 18 1\n", "3 26 1\n", "4 24 1\n", "5 32 2\n", "6 22 2\n", "7 32 2\n", "8 25 2\n", "9 25 2\n", "10 29 3\n", "11 25 3\n", "12 30 3\n", "13 30 3\n", "14 24 3" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = pd.DataFrame({\n", " 'value': [27,22,18,26,24,32,22,32,25,25,29,25,30,30,24], \n", " 'treatment': np.repeat([1, 2, 3], 5)})\n", "data[\"treatment\"] = pd.Categorical(data[\"treatment\"])\n", "data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fit = smf.ols(\"Nload ~ month + vmp\", data=SkiveAvg).fit()\n", "sm.stats.anova_lm(fit,typ=3)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.16" } }, "nbformat": 4, "nbformat_minor": 2 }