Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / MatchIt demo.R
Last active March 7, 2019 14:36
Demo with bootstrapped standard errors and power analysis
# *-----------------------------------------------------------------
# | PROGRAM NAME: MatchIt demo.R
# | DATE: 3/6/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demo of R matchit based on: Matching as Nonparametric Preprocessing for
# | Reducing Model Dependence in Parametric Causal Inference by Ho,Imai,King,and Stuart
# | Political Analysis (2007) 15:199-236 See also: http://www.biostat.jhsph.edu/~estuart/
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / DiD demo.R
Last active October 9, 2019 01:12
Example of difference in differences in a regression context with clustered SEs
# *-----------------------------------------------------------------
# | PROGRAM NAME: DiD demo.R
# | DATE: 2/5/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demo of difference-in-difference estimation
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ivreg demo.R
Created January 29, 2019 20:35
Instrumental Variables Demo Using ivreg
# *-----------------------------------------------------------------
# | PROGRAM NAME: ivreg demo.R
# | DATE: 1/29/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demo of ivreg
# *----------------------------------------------------------------
# make up data (this took some thought)
@BioSciEconomist
BioSciEconomist / MatchIt intro.R
Last active January 18, 2019 01:41
demo of R matchit based on: Matching as Nonparametric Preprocessing for Reducing Model Dependence in Parametric Causal Inference by Ho,Imai,King,and Stuart Political Analysis (2007) 15:199-236
# *-----------------------------------------------------------------
# | PROGRAM NAME: MatchIt intro.R
# | DATE: 1/12/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: /Google Drive/R Training
# *----------------------------------------------------------------
# | PURPOSE: demo of R matchit based on: Matching as Nonparametric Preprocessing for
# | Reducing Model Dependence in Parametric Causal Inference by Ho,Imai,King,and Stuart
# | Political Analysis (2007) 15:199-236
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / python examples iii.py
Created December 6, 2018 01:26
Examples of processing data in python
# make a data frame manually
data = {'GARST' :[150,140,145,137,141,145,149,153,157,161],
'PIO':[160,150,146,138,142,146,150,154,158,162],
'MYC':[137,148,151,139,143,120,115,136,130,129],
'DEK':[150,149,145,140,144,148,152,156,160,164],
'PLOT':[1,2,3,4,5,6,7,8,9,10],
'BT': ['Y','Y', 'N','N','N','N','Y','N','Y','Y'],
'RR':['Y','N','Y','N','N','N','N','Y','Y','N'],
'ID':[1,2,3,4,5,6,7,8,9,10]
}
@BioSciEconomist
BioSciEconomist / ex_logit_analytics_R.R
Created December 4, 2018 01:48
Logistic Regression and Traffic Lighting
# *------------------------------------------------------------------
# | PROGRAM NAME: ex_logit_analytics_R
# | DATE: 3/14/11
# | CREATED BY: Matt Bogard
# | PROJECT FILE:Desktop/R Programs
# *----------------------------------------------------------------
# | PURPOSE: example of predictive model and reporting
# | from blog post: from http://econometricsense.blogspot.com/2011/03/predictive-modeling-and-custom.html
# |
# *------------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex banking model.R
Created August 2, 2018 16:38
Example Predictive Modeling Project in R
# ------------------------------------------------------------------
# |PROGRAM NAME: ex banking model
# |DATE: 4/5/18
# |CREATED BY: MATT BOGARD
# |UPDATED: 5/8/18
# |PROJECT FILE: C:\Users\mtb2901\Documents\Tools and References\R References
# |----------------------------------------------------------------
# | PURPOSE: predictive modeling example
# |------------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex fibonacci.R
Last active June 27, 2018 00:08
Example Fibonacci Retracement Levels
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex fibonacci.R
# | DATE:6/26/18
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: /Users/amandabogard/Google Drive/
# *----------------------------------------------------------------
# | PURPOSE: code based on http://mindymallory.com/R-Companion-Price-Analysis/chapter-2-getting-started.html#working-with-apis
# *----------------------------------------------------------------
library(RCurl) # necessary for reading data from url
@BioSciEconomist
BioSciEconomist / ex commodity analysis 21apr18.r
Last active April 26, 2019 22:28
Basic technical analysis (code excerpt)
# *-----------------------------------------------------------------
# | PROGRAM NAME: corn technical analysis
# | DATE: 4/21/18
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE:
# *----------------------------------------------------------------
library(TTR)
@BioSciEconomist
BioSciEconomist / poisson reg.py
Last active March 11, 2017 22:37
Basic econometrics of counts
#-----------------------------------
# poisson regression basic example
#-----------------------------------
# see also: http://econometricsense.blogspot.com/2017/03/count-model-regressions.html
# this code is adapted from a more extensive GEE application
# set up to allow for repeated measures
http://nbviewer.jupyter.org/urls/umich.box.com/shared/static/ir0bnkup9rywmqd54zvm.ipynb