Skip to content

Instantly share code, notes, and snippets.

@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 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_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 / 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 / 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 / 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 / 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 / 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 / MatchIt custom distance.R
Created March 7, 2019 01:24
Example using Matchit with a custom propensity score metric
# *-----------------------------------------------------------------
# | PROGRAM NAME: MatchIt custom distance.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 / ex synthetic controls.R
Last active November 16, 2023 10:46
R code from An R Package for Synthetic Control Methods in Comparative Case Studies
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex synthetic controls.R
# | DATE: 3/28/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: Macintosh HD ▸ ⁨Users⁩ ▸ ⁨amandabogard⁩ ▸ ⁨Google Dive⁩ ▸ ⁨R Training⁩
# *----------------------------------------------------------------
# | PURPOSE: code based on Synth: An R Package for Synthetic Control Methods in Comparative Case Studies
# | Journal of Statistical Software June 2011, Volume 42, Issue 13
# *----------------------------------------------------------------