Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / ex microsynth.R
Last active April 23, 2019 23:41
Example code for synthetic controls using micro-level data
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex microsynth
# | DATE: 4/7/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: /Google Drive/R Training
# *----------------------------------------------------------------
# | PURPOSE: work through of code snippets and excerpts for synthetic controls for
# | micro level data from: https://cran.r-project.org/web/packages/microsynth/vignettes/introduction.html
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex LATE and IV.R
Last active April 19, 2019 12:37
Demonstrate how an IV captures the treatment effect of the compliers or LATE
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex LATE and IV.R
# | DATE: 4/18/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: /Google Drive/R Training
# *----------------------------------------------------------------
# | PURPOSE: demonstrate how an IV captures the treatment effect of the compliers, or LATE
# *----------------------------------------------------------------
# see companion blog post: https://econometricsense.blogspot.com/2019/04/intent-to-treat-instrumental-variables.html
@BioSciEconomist
BioSciEconomist / ex toy synthetic controls.R
Last active October 6, 2021 17:24
Intuition for how synthetic control methods work
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex toy synthetic controls.R
# | DATE: 4/23/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: Macintosh HD ▸ ⁨Users⁩ ▸ ⁨amandabogard⁩ ▸ ⁨Google Dive⁩ ▸ ⁨R Training⁩
# *----------------------------------------------------------------
# | PURPOSE: intuition for how sytnthetic control methods work
# *----------------------------------------------------------------
library(Synth) # load Synth package
@BioSciEconomist
BioSciEconomist / power sim means.R
Created April 29, 2019 21:53
compare simulated power analysis for difference in means from egap.org to results from the 'pwr' function in R
# ------------------------------------------------------------------
# |PROGRAM NAME: power sim means.R
# |DATE: 4/29/18
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: compare simulated power analysis for difference in means from egap.org
# | to results from the 'pwr' function in R
# |----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / power sim logit.R
Created April 30, 2019 00:23
simulated power analysis for difference in proportions
# ------------------------------------------------------------------
# |PROGRAM NAME: power sim logit.R
# |DATE: 4/29/18
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: /Users/amandabogard/Google Drive/R Training
# |----------------------------------------------------------------
# | PURPOSE: compare modified simulated power analysis for difference in proportions from egap.org
# | to results from the 'pwr' function in R
# |----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / simulate poisson.R
Last active April 30, 2019 23:01
simulate basic data for poisson regression
# ------------------------------------------------------------------
# |PROGRAM NAME: simulate poisson.R
# |DATE: 4/29/18
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: /Users/amandabogard/Google Drive/R Training
# |----------------------------------------------------------------
# | PURPOSE: simulate data for poisson regression
# |----------------------------------------------------------------
# this can be modified to generate data for any glm model
@BioSciEconomist
BioSciEconomist / power sim poisson.R
Last active May 1, 2019 00:02
simulated power analysis for difference in counts modifed code originally from egap.org
# ------------------------------------------------------------------
# |PROGRAM NAME: power sim poisson.R
# |DATE: 4/29/18
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: /Users/amandabogard/Google Drive/R Training
# |----------------------------------------------------------------
# | PURPOSE: simulated power analysis for difference in counts modifed code originally from egap.org
# |----------------------------------------------------------------
# reference: http://egap.org/content/power-analysis-simulations-r
@BioSciEconomist
BioSciEconomist / simulate negbin.R
Last active September 7, 2019 21:43
simulate data for negative binomial count regression
# ------------------------------------------------------------------
# |PROGRAM NAME: simulate negbin.R
# |DATE: 4/29/18
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: /Users/amandabogard/Google Drive/R Training
# |----------------------------------------------------------------
# | PURPOSE: example:simulate data for negative binomial count model
# |----------------------------------------------------------------
##########################################################
##########################################################
######### under construction #############
##########################################################
##########################################################
# see: http://econometricsense.blogspot.com/2019/01/modeling-claims-with-linear-vs-non.html?_sm_au_=iVV3RHk1r75TjsfM
# this is also the approach taken in Jonk: Yvonne Jonk, Karen Lawson, Heidi O'Connor, Kirsten S. Riise, David
# Eisenberg, Bryan Dowd, Mary J. KreitzerMed Care. 2015 Feb; 53(2): 133–140. doi: 10.1097/MLR.0000000000000287
@BioSciEconomist
BioSciEconomist / randomization inference demo.R
Last active October 15, 2019 01:37
Example of basic randomization inference in R
# *-----------------------------------------------------------------
# | PROGRAM NAME: randomization inference demo.R
# | DATE: 10/14/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demo of randomization inference based on 'Field Experimetns: Design, Analysis, and Interpretation
# | by Alan S. Gerber and Donald P. Green (Ch3)
# *----------------------------------------------------------------