Skip to content

Instantly share code, notes, and snippets.

View shabbychef's full-sized avatar
tcb

Steven Pav shabbychef

tcb
View GitHub Profile
@shabbychef
shabbychef / install_github2.r
Created May 30, 2015 18:47
install_github only once ever.
library(git2r)
library(devtools)
library(drat)
install_github2 <- function(repo) {
dest <- tempfile()
dir.create(dest, recursive=TRUE)
# download
repo <- git2r::clone(paste0('https://github.com/',repo,'.git'),dest)
@shabbychef
shabbychef / server.R
Last active February 23, 2016 17:52
Cramer Rao bound on Markowitz portfolio Monte Carlo shiny app.
# Created: 2015.05.18
# Copyright: Steven E. Pav, 2015
# Author: Steven E. Pav <shabbychef@gmail.com>
# Comments: Steven E. Pav
library(shiny)
library(ggplot2)
library(reshape2)
library(hypergeo)

Keybase proof

I hereby claim:

  • I am shabbychef on github.
  • I am shabbychef (https://keybase.io/shabbychef) on keybase.
  • I have a public key whose fingerprint is 69BF 8752 A716 023A 02D4 2C42 6F6D BA6E 505E FB13

To claim this, I am signing this object:

@shabbychef
shabbychef / Dockerfile
Last active August 29, 2015 14:04
Pyro4 nameserver
# Pyro4 nameserver MWE
# This appears to be properly configured.
# preamble
FROM orchardup/python:2.7
MAINTAINER Steven E. Pav, shabbychef@gmail.com
USER root
# setup
RUN pip install -qq Pyro4
@shabbychef
shabbychef / conque_tweak.vim
Created November 13, 2013 17:11
code to place in .vimrc to make Conque play nicely with R.
" code to place in .vimrc to make Conque play nicely with R
" (or other languages, though you would have to generalize the
" commands to allow different syntax and filetypes)
"
" to use, place in .vimrc, resource, and issue
"
" :RConque
"
" this will give you a screen session named 'r';
" use R in this session;
@shabbychef
shabbychef / se.ipynb
Created September 30, 2013 05:24
standard error computation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# see
# http://climateecology.wordpress.com/2013/08/19/r-vs-python-speed-comparison-for-bootstrapping/
# first version#FOLDUP
set.seed(101)
# generate data
x <- 0:100
y <- 2*x + rnorm(101, 0, 10)
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 12 columns, instead of 2. in line 8.
Entity Name Title Base Overtime Other (vacation, sick, bonus, etc) Medical/Dental/Visual Employeer Contribution to Pension Employee Contribution to Pension Paid By Employer Employer Contribution to Deferred Compensation (401k) Misc Total Cost of Employment
Bay Area Rapid Transit Dugger, Dorothy General Mgr 298700 0 34500 14951 39521 23324 1869 6796 419661
Bay Area Rapid Transit Crunican, Grace General Mgr 312461 0 3846 19141 37513 17500 1869 7591 399921
Bay Area Rapid Transit Tietz, Forrest Police Sergeant 136746 111902 33921 18200 60630 156 0 1107 362662
Bay Area Rapid Transit Pangilinan, Edgardo Asst Controller 107785 0 214322 10903 13017 7650 1869 5734 361279
Bay Area Rapid Transit Lucarelli, Frank Police Lieutenant 173811 46280 33422 23364 76427 233 0 5019 358556
Bay Area Rapid Transit Collier, Roberta Asst Treasurer 33971 0 289534 1797 4072 2378 1869 4897 338518
Bay Area Rapid Transit Parker, Thomas Exec Mgr Transit System Compl 136544 0 145633 19139 16863 9923 1869 5584 335554
Bay Area Rapid Transit Rai
@shabbychef
shabbychef / replicating_google_trends.ipynb
Created June 18, 2013 20:17
iPython notebook to replicate the paper 'Quantifying Trading Behavior in Financial Markets Using Google Trends.'
@shabbychef
shabbychef / realworld_hotelling.R
Last active December 12, 2015 06:28
check out SPY, TLT, GLD, AAPL...
require(quantmod)
getSymbols(c("SPY","TLT","GLD","AAPL"))
allofem <- merge(SPY[,"SPY.Adjusted"],TLT[,"TLT.Adjusted"],GLD[,"GLD.Adjusted"],AAPL[,"AAPL.Adjusted"])
mo.pry <- to.monthly(allofem,OHLC=FALSE)
mo.ret <- diff(log(mo.pry))
sub.ret <- mo.ret[(dim(mo.ret)[1]-59):dim(mo.ret)[1],]
mu <- apply(sub.ret,2,mean,na.rm=TRUE)
Sg <- cov(sub.ret,use="complete.obs")
w <- solve(Sg,mu)
n <- dim(sub.ret)[1]