Skip to content

Instantly share code, notes, and snippets.

@sherdim
Created February 28, 2016 23:31
Show Gist options
  • Save sherdim/e3e17fa715d6d4f5e494 to your computer and use it in GitHub Desktop.
Save sherdim/e3e17fa715d6d4f5e494 to your computer and use it in GitHub Desktop.
regression blog2.ipynb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Test a Basic Linear Regression Model"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"source": [
"%pylab inline"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>attempt</th>\n",
" <th>bukv</th>\n",
" <th>bukv0</th>\n",
" <th>host</th>\n",
" <th>kr</th>\n",
" <th>naextra</th>\n",
" <th>ncextra</th>\n",
" <th>nfscan</th>\n",
" <th>npause</th>\n",
" <th>nscan</th>\n",
" <th>...</th>\n",
" <th>tclast</th>\n",
" <th>texit</th>\n",
" <th>u</th>\n",
" <th>userid</th>\n",
" <th>var</th>\n",
" <th>vt</th>\n",
" <th>cmid</th>\n",
" <th>course</th>\n",
" <th>grade</th>\n",
" <th>result</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1795</td>\n",
" <td>257</td>\n",
" <td>147</td>\n",
" <td>up11</td>\n",
" <td>0.432422</td>\n",
" <td>-3</td>\n",
" <td>-2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>64.556</td>\n",
" <td>66.461</td>\n",
" <td>UP11__4103478780151029</td>\n",
" <td>540</td>\n",
" <td>5</td>\n",
" <td>12.972669</td>\n",
" <td>1706</td>\n",
" <td>9</td>\n",
" <td>0.25</td>\n",
" <td>correct</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1795</td>\n",
" <td>283</td>\n",
" <td>49</td>\n",
" <td>up11</td>\n",
" <td>1.662998</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>158.545</td>\n",
" <td>159.532</td>\n",
" <td>UP11__4106285050151029</td>\n",
" <td>540</td>\n",
" <td>3</td>\n",
" <td>49.889946</td>\n",
" <td>1706</td>\n",
" <td>9</td>\n",
" <td>0.00</td>\n",
" <td>incorrect</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1795</td>\n",
" <td>81</td>\n",
" <td>27</td>\n",
" <td>up11</td>\n",
" <td>1.431508</td>\n",
" <td>-2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>17.633</td>\n",
" <td>18.453</td>\n",
" <td>UP11__4106480830151029</td>\n",
" <td>540</td>\n",
" <td>4</td>\n",
" <td>42.945239</td>\n",
" <td>1706</td>\n",
" <td>9</td>\n",
" <td>0.00</td>\n",
" <td>incorrect</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1795</td>\n",
" <td>251</td>\n",
" <td>21</td>\n",
" <td>up11</td>\n",
" <td>1.870821</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>23.561</td>\n",
" <td>24.441</td>\n",
" <td>UP11__4107136770151029</td>\n",
" <td>540</td>\n",
" <td>4</td>\n",
" <td>56.124639</td>\n",
" <td>1706</td>\n",
" <td>9</td>\n",
" <td>0.25</td>\n",
" <td>correct</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1795</td>\n",
" <td>117</td>\n",
" <td>75</td>\n",
" <td>up11</td>\n",
" <td>0.275338</td>\n",
" <td>-1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>32.652</td>\n",
" <td>33.450</td>\n",
" <td>UP11__4107482870151029</td>\n",
" <td>540</td>\n",
" <td>3</td>\n",
" <td>8.260141</td>\n",
" <td>1706</td>\n",
" <td>9</td>\n",
" <td>0.25</td>\n",
" <td>correct</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 26 columns</p>\n",
"</div>"
],
"text/plain": [
" attempt bukv bukv0 host kr naextra ncextra nfscan npause \\\n",
"0 1795 257 147 up11 0.432422 -3 -2 0 1 \n",
"1 1795 283 49 up11 1.662998 4 0 0 2 \n",
"2 1795 81 27 up11 1.431508 -2 0 0 0 \n",
"3 1795 251 21 up11 1.870821 1 0 0 0 \n",
"4 1795 117 75 up11 0.275338 -1 0 0 1 \n",
"\n",
" nscan ... tclast texit u userid var \\\n",
"0 0 ... 64.556 66.461 UP11__4103478780151029 540 5 \n",
"1 1 ... 158.545 159.532 UP11__4106285050151029 540 3 \n",
"2 0 ... 17.633 18.453 UP11__4106480830151029 540 4 \n",
"3 1 ... 23.561 24.441 UP11__4107136770151029 540 4 \n",
"4 0 ... 32.652 33.450 UP11__4107482870151029 540 3 \n",
"\n",
" vt cmid course grade result \n",
"0 12.972669 1706 9 0.25 correct \n",
"1 49.889946 1706 9 0.00 incorrect \n",
"2 42.945239 1706 9 0.00 incorrect \n",
"3 56.124639 1706 9 0.25 correct \n",
"4 8.260141 1706 9 0.25 correct \n",
"\n",
"[5 rows x 26 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"D=pandas.read_table('..\\StiReac\\D.tsv')\n",
"\n",
"D.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will test a linear regression model for the association between our primary explanatory variable - number of pauses (`npause`) and a response variable - time of exit (`texit`)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we have a quantitative explanatory variable, let us center it so that the mean = 0."
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAENCAYAAAABh67pAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHnRJREFUeJzt3X+QXXWZ5/H3J4L8kE7isCuIOHSNu5bjDkMvbMKiwQQG\n1BFR3FVwKGxbFEaWoFij64CDlFiKNQ7iIBpqMdDR8ScpSY/M8sMxdJImQaNrm7iLCxTiroyBRYEm\nwhB6ePaPc25yCf3jJH3v6T4Pn1dVV5/vt8+95/vpG557+rnccxURmJlZXvNmewFmZtZdLvRmZsm5\n0JuZJedCb2aWnAu9mVlyLvRmZslNW+glzZO0UtKIpPWSXi2pT9KvJK0tv95R7nuOpM2SNko6pZzb\nX9Lq8rY3STq426HMzGwXTff/0Ut6K3BqRLxP0lLgQ8B3gfkRcWXbfocA3wOOBg4ERoBjgOVAT0Rc\nJukM4LiIuLAraczM7DmmPaOPiCHg3HLYCzxCUcDfLGmdpGslHQQsBkYiYjwixoB7gKOAJcAt5e1v\nBk7qbAQzM5tKpR59RDwjaRD4W+BrwA+AD0fEUuA+4FJgPvBY2822AwuAnrb5x8v9zMysJpVfjI2I\nAeCVwJeB2yLiJ+WP1gB9FMW8vYj3UJz9j5XbrblHZ7ZkMzPbE/tMt4Oks4DDI+IzwD8DzwDfkfSB\niNgM/AnwY2Az8ClJLwQOAF4F/AzYCLwJ+FH5fcMkx/FFd8zM9kJEaLodpvyieGH1W8A64A7gVIoz\n+BFgLfB14KBy3/cCP6Qo+qeVcwcA36Yo8P8IvGSS40Rml1566WwvoWsyZ4twvqbLnq+snVPW8WnP\n6CPiCeCMCX60ZIJ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e/htwraRhinbZl6a4f5tDfPVKe94rX1T884g4c7bX0k7Shyk+s3Zw\nttdizeYzerM5SNL1FJ8YdOpsr8Waz2f0ZmbJ+cVYM7PkXOjNzJJzoTczS86F3swsORd6M7PkXOjN\nzJL7/1oWG46ld34uAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x11b100f0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = D.npause\n",
"x = x - x.mean()\n",
"D['x']=x\n",
"x.hist();\n",
"xlabel('Normalized explanatory variable');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us use `statsmodel` module to test a linear regression model."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import statsmodels.api as sm\n",
"import statsmodels.formula.api as smf"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<table class=\"simpletable\">\n",
"<caption>OLS Regression Results</caption>\n",
"<tr>\n",
" <th>Dep. Variable:</th> <td>texit</td> <th> R-squared: </th> <td> 0.485</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Model:</th> <td>OLS</td> <th> Adj. R-squared: </th> <td> 0.485</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Method:</th> <td>Least Squares</td> <th> F-statistic: </th> <td> 6230.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Date:</th> <td>Mon, 29 Feb 2016</td> <th> Prob (F-statistic):</th> <td> 0.00</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Time:</th> <td>02:03:07</td> <th> Log-Likelihood: </th> <td> -28193.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>No. Observations:</th> <td> 6611</td> <th> AIC: </th> <td>5.639e+04</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Df Residuals:</th> <td> 6609</td> <th> BIC: </th> <td>5.640e+04</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Df Model:</th> <td> 1</td> <th> </th> <td> </td> \n",
"</tr>\n",
"<tr>\n",
" <th>Covariance Type:</th> <td>nonrobust</td> <th> </th> <td> </td> \n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <td></td> <th>coef</th> <th>std err</th> <th>t</th> <th>P>|t|</th> <th>[95.0% Conf. Int.]</th> \n",
"</tr>\n",
"<tr>\n",
" <th>Intercept</th> <td> 34.7437</td> <td> 0.212</td> <td> 164.092</td> <td> 0.000</td> <td> 34.329 35.159</td>\n",
"</tr>\n",
"<tr>\n",
" <th>x</th> <td> 27.8682</td> <td> 0.353</td> <td> 78.931</td> <td> 0.000</td> <td> 27.176 28.560</td>\n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <th>Omnibus:</th> <td>2583.402</td> <th> Durbin-Watson: </th> <td> 1.694</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Prob(Omnibus):</th> <td> 0.000</td> <th> Jarque-Bera (JB): </th> <td>14650.850</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Skew:</th> <td> 1.784</td> <th> Prob(JB): </th> <td> 0.00</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Kurtosis:</th> <td> 9.361</td> <th> Cond. No. </th> <td> 1.67</td> \n",
"</tr>\n",
"</table>"
],
"text/plain": [
"<class 'statsmodels.iolib.summary.Summary'>\n",
"\"\"\"\n",
" OLS Regression Results \n",
"==============================================================================\n",
"Dep. Variable: texit R-squared: 0.485\n",
"Model: OLS Adj. R-squared: 0.485\n",
"Method: Least Squares F-statistic: 6230.\n",
"Date: Mon, 29 Feb 2016 Prob (F-statistic): 0.00\n",
"Time: 02:03:07 Log-Likelihood: -28193.\n",
"No. Observations: 6611 AIC: 5.639e+04\n",
"Df Residuals: 6609 BIC: 5.640e+04\n",
"Df Model: 1 \n",
"Covariance Type: nonrobust \n",
"==============================================================================\n",
" coef std err t P>|t| [95.0% Conf. Int.]\n",
"------------------------------------------------------------------------------\n",
"Intercept 34.7437 0.212 164.092 0.000 34.329 35.159\n",
"x 27.8682 0.353 78.931 0.000 27.176 28.560\n",
"==============================================================================\n",
"Omnibus: 2583.402 Durbin-Watson: 1.694\n",
"Prob(Omnibus): 0.000 Jarque-Bera (JB): 14650.850\n",
"Skew: 1.784 Prob(JB): 0.00\n",
"Kurtosis: 9.361 Cond. No. 1.67\n",
"==============================================================================\n",
"\n",
"Warnings:\n",
"[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
"\"\"\""
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"reg1 = smf.ols('texit ~ x', data=D).fit()\n",
"reg1.summary()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The results of the linear regression model indicated that time of exit is proportional to the number of pauses (k=27.9, p<.001). So simple linear model is\n",
"$$ t_{exit} = 34.74 + 27.86 n_{pause}$$\n",
"where $t_{exit}$ - time of exit, $n_{pause}$ - number of pauses\n",
"\n",
"We can conclude that a single pause lasts at average near 28 sec.\n",
"\n",
"To estimate regression fit let us scatter data."
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmYVNW19/HvQgYRENAgRiJoNIiIyqQCijagqICIGocQ\nQqIGh+DAEPXVG5V7k3ifN5EGQUVBQHFAAUVRQTBgAw0yOyGKtKBEDAIyyUzT+/6xu+luLaC6qapz\n6tTv8zz9uLs4Vawj3bVq77UHc84hIiJSpELQAYiISLgoMYiISClKDCIiUooSg4iIlKLEICIipSgx\niIhIKSlJDGZW0czGmNksM5tnZleYWVMz+8bMZhR+XVt4bS8zW2hmc82scyriExGRYpaKdQxm9gfg\nLOdcPzOrDXwI/DdQ0zk3qMR1dYF3gebAUUAu0MI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dWUhR/Nkfi/+1m45P5TQcbjdACNxERKUVDSSIiUooSg4iI\nlKLEICIipSgxiIhIKUoMIiJSihKDiIiUosQgIiKlaIGbyCGY2fnAtUAOfsX2Gc65vwUalEgSqccg\nEr81hZsAnhp0ICLJpMQgcgjOuTnAqc65hWZ2NBHcr1+kJA0liRyCmVWlOBl0AiYXDi/tBroCk/E7\ncm4GmgP/DZwGZOHPaLjQOfeSmXXHbz63DGgFfOecm5LCWxGJixKDyKGdAcwqbG8DGgCfAtuBjfiE\n8L/AMUBDfBL5Dr+Nenvg/cLnNgY24E9CG0o0T7GTCNAmeiLlZGY3AEfhh2SrAvPxPYpx+KTRFp8M\nJgG/AFYAxwN1gKX48zaWpD5ykYNTYhAph8IzdJ/Bbz29Meh4RBJJiUFERErRrCQRESlFiUFEREpR\nYhARkVKUGEREpBQlBhERKUWJQURESlFiEBGRUpQYRESkFCUGEREp5f8A6SQAnnuEH54AAAAASUVO\nRK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x11ed2690>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"y=D.texit\n",
"plot(x, y, '.')\n",
"xx=xlim()\n",
"yy=reg1.predict(dict(x=xx))\n",
"plot(xx,yy,'r')\n",
"text(.8,.9, '$r^2 = {:.2f}$'.format(reg1.rsquared), transform=gca().transAxes);\n",
"xlabel('$n_{pause}$'); ylabel('$t_{exit}$');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Time of exit definitely grows with the number of pauses."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment