Skip to content

Instantly share code, notes, and snippets.

@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
# |----------------------------------------------------------------
@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 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 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 / 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 / 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 / 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 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 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
# *----------------------------------------------------------------
@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/
# *----------------------------------------------------------------