Skip to content

Commit

Permalink
Updated Ransom additions
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleransom committed Mar 30, 2016
1 parent 790140e commit ac2ff2f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
6 changes: 5 additions & 1 deletion dataframes_examples.ipynb
Expand Up @@ -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"
]
},
{
Expand Down
66 changes: 35 additions & 31 deletions jump_optimization.ipynb
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -73,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {
"collapsed": false,
"slideshow": {
Expand All @@ -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"
]
},
Expand Down
6 changes: 5 additions & 1 deletion regression_models.ipynb
Expand Up @@ -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"
]
},
{
Expand Down

0 comments on commit ac2ff2f

Please sign in to comment.