Permalink
Browse files

Updated Ransom additions

  • Loading branch information...
1 parent 790140e commit ac2ff2f93c15898adb5feccc68ff6738e6fa6826 @tyleransom tyleransom committed Mar 30, 2016
Showing with 45 additions and 33 deletions.
  1. +5 −1 dataframes_examples.ipynb
  2. +35 −31 jump_optimization.ipynb
  3. +5 −1 regression_models.ipynb
@@ -15,7 +15,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "By Tyler Ransom, Duke University Social Science Research Institute"
+ "By Tyler Ransom, Duke University Social Science Research Institute\n",
+ "\n",
+ "tyler.ransom@duke.edu\n",
+ "\n",
+ "https://github.com/tyleransom"
]
},
{
@@ -15,7 +15,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "By Tyler Ransom, Duke University Social Science Research Institute"
+ "By Tyler Ransom, Duke University Social Science Research Institute\n",
+ "\n",
+ "tyler.ransom@duke.edu\n",
+ "\n",
+ "https://github.com/tyleransom"
]
},
{
@@ -73,7 +77,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {
"collapsed": false,
"slideshow": {
@@ -87,41 +91,41 @@
"datagen (generic function with 1 method)"
]
},
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function datagen(N,T)\n",
- "\t## Generate data for a linear model to test optimization\n",
- "\tsrand(1234)\n",
- "\t\n",
- "\tN = convert(Int64,N) #inputs to functions such as -ones- need to be integers!\n",
- "\tT = convert(Int64,T) #inputs to functions such as -ones- need to be integers!\n",
- "\tconst n = convert(Int64,N*T) # use -const- as a way to declare a variable to be global (so other functions can access it)\n",
- "\t\n",
- "\t# generate the Xs\n",
- "\tconst X = cat(2,ones(N*T,1),5+3*randn(N*T,1),rand(N*T,1),\n",
- "\t 2.5+2*randn(N*T,1),15+3*randn(N*T,1),\n",
- "\t\t\t .7-.1*randn(N*T,1),5+3*randn(N*T,1),\n",
- "\t\t\t rand(N*T,1),2.5+2*randn(N*T,1),\n",
- "\t\t\t 15+3*randn(N*T,1),.7-.1*randn(N*T,1),\n",
- "\t\t\t 5+3*randn(N*T,1),rand(N*T,1),2.5+2*randn(N*T,1),\n",
- "\t\t\t 15+3*randn(N*T,1),.7-.1*randn(N*T,1));\n",
- "\t\n",
- "\t# generate the betas (X coefficients)\n",
- "\tconst bAns = [ 2.15; 0.10; 0.50; 0.10; 0.75; 1.2; 0.10; 0.50; 0.10; 0.75; 1.2; 0.10; 0.50; 0.10; 0.75; 1.2 ]\n",
- "\t\n",
- "\t# generate the std dev of the errors\n",
- "\tconst sigAns = 0.3\n",
- "\t\n",
- "\t# generate the Ys from the Xs, betas, and error draws\n",
- "\tdraw = 0 + sigAns*randn(N*T,1)\n",
- "\tconst y = X*bAns+draw\n",
- "\t\n",
- "\t# return generated data so that other functions (below) have access\n",
- "\treturn X,y,bAns,sigAns,n\n",
+ " ## Generate data for a linear model to test optimization\n",
+ " srand(1234)\n",
+ " \n",
+ " N = convert(Int64,N) #inputs to functions such as -ones- need to be integers!\n",
+ " T = convert(Int64,T) #inputs to functions such as -ones- need to be integers!\n",
+ " const n = convert(Int64,N*T) # use -const- as a way to declare a variable to be global (so other functions can access it)\n",
+ " \n",
+ " # generate the Xs\n",
+ " const X = cat(2,ones(N*T,1),5+3*randn(N*T,1),rand(N*T,1),\n",
+ " 2.5+2*randn(N*T,1),15+3*randn(N*T,1),\n",
+ " .7-.1*randn(N*T,1),5+3*randn(N*T,1),\n",
+ " rand(N*T,1),2.5+2*randn(N*T,1),\n",
+ " 15+3*randn(N*T,1),.7-.1*randn(N*T,1),\n",
+ " 5+3*randn(N*T,1),rand(N*T,1),2.5+2*randn(N*T,1),\n",
+ " 15+3*randn(N*T,1),.7-.1*randn(N*T,1));\n",
+ " \n",
+ " # generate the betas (X coefficients)\n",
+ " const bAns = [ 2.15; 0.10; 0.50; 0.10; 0.75; 1.2; 0.10; 0.50; 0.10; 0.75; 1.2; 0.10; 0.50; 0.10; 0.75; 1.2 ]\n",
+ " \n",
+ " # generate the std dev of the errors\n",
+ " const sigAns = 0.3\n",
+ " \n",
+ " # generate the Ys from the Xs, betas, and error draws\n",
+ " draw = 0 + sigAns*randn(N*T,1)\n",
+ " const y = X*bAns+draw\n",
+ " \n",
+ " # return generated data so that other functions (below) have access\n",
+ " return X,y,bAns,sigAns,n\n",
"end"
]
},
@@ -15,7 +15,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "By Tyler Ransom, Duke University Social Science Research Institute"
+ "By Tyler Ransom, Duke University Social Science Research Institute\n",
+ "\n",
+ "tyler.ransom@duke.edu\n",
+ "\n",
+ "https://github.com/tyleransom"
]
},
{

0 comments on commit ac2ff2f

Please sign in to comment.