Skip to content

Instantly share code, notes, and snippets.

@akelleh
Created August 20, 2016 15:43
Show Gist options
  • Save akelleh/a2a60665693880ddd8de433d33af1e32 to your computer and use it in GitHub Desktop.
Save akelleh/a2a60665693880ddd8de433d33af1e32 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<table class=\"simpletable\">\n",
"<caption>OLS Regression Results</caption>\n",
"<tr>\n",
" <th>Dep. Variable:</th> <td>z</td> <th> R-squared: </th> <td> 0.672</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Model:</th> <td>OLS</td> <th> Adj. R-squared: </th> <td> 0.671</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Method:</th> <td>Least Squares</td> <th> F-statistic: </th> <td> 1021.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Date:</th> <td>Sat, 20 Aug 2016</td> <th> Prob (F-statistic):</th> <td>3.69e-242</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Time:</th> <td>11:42:40</td> <th> Log-Likelihood: </th> <td> -1405.6</td> \n",
"</tr>\n",
"<tr>\n",
" <th>No. Observations:</th> <td> 1000</td> <th> AIC: </th> <td> 2815.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Df Residuals:</th> <td> 998</td> <th> BIC: </th> <td> 2825.</td> \n",
"</tr>\n",
"<tr>\n",
" <th>Df Model:</th> <td> 2</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>x</th> <td> 0.0771</td> <td> 0.044</td> <td> 1.739</td> <td> 0.082</td> <td> -0.010 0.164</td>\n",
"</tr>\n",
"<tr>\n",
" <th>y</th> <td> 0.9550</td> <td> 0.031</td> <td> 30.527</td> <td> 0.000</td> <td> 0.894 1.016</td>\n",
"</tr>\n",
"</table>\n",
"<table class=\"simpletable\">\n",
"<tr>\n",
" <th>Omnibus:</th> <td> 0.995</td> <th> Durbin-Watson: </th> <td> 2.012</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Prob(Omnibus):</th> <td> 0.608</td> <th> Jarque-Bera (JB): </th> <td> 1.035</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Skew:</th> <td>-0.075</td> <th> Prob(JB): </th> <td> 0.596</td>\n",
"</tr>\n",
"<tr>\n",
" <th>Kurtosis:</th> <td> 2.954</td> <th> Cond. No. </th> <td> 2.64</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"<class 'statsmodels.iolib.summary.Summary'>\n",
"\"\"\"\n",
" OLS Regression Results \n",
"==============================================================================\n",
"Dep. Variable: z R-squared: 0.672\n",
"Model: OLS Adj. R-squared: 0.671\n",
"Method: Least Squares F-statistic: 1021.\n",
"Date: Sat, 20 Aug 2016 Prob (F-statistic): 3.69e-242\n",
"Time: 11:42:40 Log-Likelihood: -1405.6\n",
"No. Observations: 1000 AIC: 2815.\n",
"Df Residuals: 998 BIC: 2825.\n",
"Df Model: 2 \n",
"Covariance Type: nonrobust \n",
"==============================================================================\n",
" coef std err t P>|t| [95.0% Conf. Int.]\n",
"------------------------------------------------------------------------------\n",
"x 0.0771 0.044 1.739 0.082 -0.010 0.164\n",
"y 0.9550 0.031 30.527 0.000 0.894 1.016\n",
"==============================================================================\n",
"Omnibus: 0.995 Durbin-Watson: 2.012\n",
"Prob(Omnibus): 0.608 Jarque-Bera (JB): 1.035\n",
"Skew: -0.075 Prob(JB): 0.596\n",
"Kurtosis: 2.954 Cond. No. 2.64\n",
"==============================================================================\n",
"\n",
"Warnings:\n",
"[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
"\"\"\""
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = OLS(X['z'], X[['x','y']])\n",
"result = model.fit()\n",
"result.summary()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"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.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment