Skip to content

Instantly share code, notes, and snippets.

View EconometricsBySimulation's full-sized avatar

Francis Smart EconometricsBySimulation

View GitHub Profile
@EconometricsBySimulation
EconometricsBySimulation / gist:9757105
Created March 25, 2014 08:09
Excel summary exporter
####### Excel summary exporter #######
## Modified from Smart, Francis ##
## Jean P. Gibert, 2014 ##
lmOut <- function(res, file="test.csv", ndigit=3, writecsv=T) {
# If summary has not been run on the model then run summary
if (length(grep("summary", class(res)))==0) res <- summary(res)
co <- res$coefficients
nvar <- nrow(co)
ncoll <- ncol(co)
@EconometricsBySimulation
EconometricsBySimulation / gist:9958775
Created April 3, 2014 17:20
List of Stata packages/commands
_grmedf,_gstd01,actest,addest,addtxt,adjust,adodev,adoedit,adolist,adoupdate,aipe,akdensity,allpossible,alt,amcmc,an16_1,anovacontrast,anovalator,apc,apcd,apch,areastack,arimafit,array,art,ashell,atkplot,atsinst,attrib,avplot3,backrasch,backup,bayesmlogit,bcii,bcoeff,betafit,betaprior,bic,bicdrop1,binary_mediation,bincoverage,biplotvlab,birthsim,blist,blogit2,bmjcip,bpmedian,bronch,bs4rw,bspline,bstut,bsweights,bugsdat,bxmodel,bygap,bynote,bys,bystore,byvar,calibest,canred,catdev,catenate,cb2html,ccinter,cctable,cellgr,cem,cf2,chardef,charlist,charlson,checkrob,checkvar,chidemo,china_map,china_spatdwm,ci_marg_mu,cidemo,cidemo2,cij,circular,cistat,ciw,ckvar,clarify,cleanchars,cleanlog,clrbound,clstop_lbt,clt,clustpop,clustsens,cmp,cns,cnsrsig,codci,codebook2,coefplot,cohend,collapse2,collapseunique,collin,colortrans,compado,conddens,condivreg,confirmdir,contrast,copypkg,coranal,cordemo,corrsq,corrtex,cpr,cprplots,cqiv,crib10,crib11,crib12,crib13,crib9,csgof,csinter,csjl,cstable,csvconvert,cureregr,datelist,de2
<NotepadPlus>
<UserLang name="Julia" ext="jl">
<Settings>
<Global caseIgnored="no" />
<TreatAsSymbol comment="no" commentLine="yes" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">&quot;00&quot;00</Keywords>
<Keywords name="Folder+">begin function type for while if</Keywords>
@EconometricsBySimulation
EconometricsBySimulation / gist:0b54b14d3040d3e89709
Created July 20, 2014 02:33
Graphical Anlaysis of Trends in Name Data
require(plyr)
require(ggplot2)
require(scales)
# Download data from:
# http://www.ssa.gov/oact/babynames/names.zip
setwd("C:/Data/SS-names/")
files<-list.files()
files<-files[grepl(".txt",files)]
@EconometricsBySimulation
EconometricsBySimulation / readGoogleSheet.R
Last active August 29, 2015 14:06
Read Google Spreadsheet into R
# This set of functions comes entirely form Andrie on stackoverflow
# http://stackoverflow.com/questions/22873602/importing-data-into-r-from-google-spreadsheet
readGoogleSheet <- function(url, na.string="", header=TRUE){
stopifnot(require(XML))
# Suppress warnings because Google docs seems to have incomplete final line
suppressWarnings({
doc <- paste(readLines(url), collapse=" ")
})
if(nchar(doc) == 0) stop("No content found")
@EconometricsBySimulation
EconometricsBySimulation / ebola.R
Last active August 29, 2015 14:06
Analysis of Ebola data
# First let's load some libraries
require('XML'); require('reshape2'); require('ggplot2')
require('magrittr') # See
# http://goo.gl/Wj5F87
# I have borrowed Andrie's code from stackoverflow
# http://goo.gl/noYVo7
source("http://goo.gl/w64gfp")
# Load in the google spreadsheet
# adapted from John Fox's numbers2words function
require(magrittr); require(Rmpfr)
make.digits <- function(x) {
# This is a function breaks an input number x into the positive (left)
# and negative(right) elements and returns these as numbers
x <- toString(x)
negative <- substr(x,1,1)=="-"
if (negative) x <- substring(x,2)
@EconometricsBySimulation
EconometricsBySimulation / cubes.R
Created September 10, 2014 00:25
Easy Bordered Cubes in R
library('rgl'); library('magrittr')
cube <- function(x=0,y=0,z=0, bordered=TRUE,
filled = TRUE, lwd=2, scale=1,
fillcol = gray(.95),
bordercol ='black', ...) {
mycube <- cube3d()
# Reduce size to unit
shinyServer(function(input, output) {
output$main_plot <- renderPlot(width = 400, height = 300, {
hist(faithful$eruptions,
probability = TRUE,
breaks = as.numeric(input$n_breaks),
xlab = "Duration (minutes)",
main = "Geyser eruption duration")
sex ageYear ageMonth heightIn weightLb
f 11.91667 143 56.3 85
f 12.91667 155 62.3 105
f 12.75 153 63.3 108
f 13.41667 161 59 92
f 15.91667 191 62.5 112.5
f 14.25 171 62.5 112
f 15.41667 185 59 104
f 11.83333 142 56.5 69
f 13.33333 160 62 94.5