Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / ex VAR.py
Created February 23, 2021 18:05
Example VAR model for python
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex VAR.py
# | DATE: 2/23/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: source: https://www.machinelearningplus.com/time-series/vector-autoregression-examples-python/
# *----------------------------------------------------------------
# see also my blog post: http://econometricsense.blogspot.com/2011/05/vector-autoregressions-and-bayesian.html
@BioSciEconomist
BioSciEconomist / ex synthetic controls.py
Last active February 20, 2021 17:56
Intuition for the application of synthetic control methods in python
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex synthetic controls.py
# | DATE: 2/13/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: intuition for the application of synthetic control methods in python
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex_synth_states.csv
Created February 13, 2021 23:51
Simulated state level toy panel data for synthetic control scripts
ID state years UN college fastfood cost
1 CA 1990 0.032392552299425 0.24544457978569 2.4977055855561 1950.83661026321
1 CA 1991 0.0318986003333703 0.256238439888693 2.08406292251311 1643.05610202369
1 CA 1992 0.033461097353138 0.256421657577157 2.22463607857935 1749.31302200537
1 CA 1993 0.0370203721290454 0.257437539133243 2.76596341095865 2157.34212906682
1 CA 1994 0.0388986587245017 0.248881499939598 2.01657752273604 1594.10284639918
1 CA 1995 0.0252047811541706 0.258736467873678 2.19277501036413 1721.8677653186
1 CA 1996 0.0260166791034862 0.251568139037117 2.95559096685611 2292.5935994531
1 CA 1997 0.0363858704548329 0.2518281813059 2.19790341798216 1729.57754404051
1 CA 1998 0.0210772675042972 0.250085048945621 2.80991377192549 2180.49522493267
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BioSciEconomist
BioSciEconomist / ex state level synthetic controls.R
Last active February 17, 2021 02:09
Example state level synthetic controls
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex state level synthetic controls.R
# | DATE: 2/12/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: This code builds some intuition for how synthetic control methods work
# | using simulated data synthetic controls are created for a treatment state
# | placebo plots visualize uncertainty/rarity of the treatment
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / python basics.py
Last active January 26, 2021 01:33
examples of data munging and analysis in python
# *-----------------------------------------------------------------
# | PROGRAM NAME: python basics.py
# | DATE: 1/25/21 (original: 12/28/18)
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: examples of data munging and analysis in python
# *----------------------------------------------------------------
# see also: https://pandas.pydata.org/pandas-docs/stable/getting_started/comparison/comparison_with_r.html
@BioSciEconomist
BioSciEconomist / Regression_and_IV.py
Created December 31, 2020 23:11
Demonstrate basic concepts related to to selection bias, regression, and instrumental variables
# *-----------------------------------------------------------------
# | PROGRAM NAME: Regression_and_IV.py
# | DATE: 12/31/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demonstrate basic concepts related to to selection bias, regression, and instrumental variables
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex bootstrapped inference.py
Created October 16, 2020 23:38
Example of bootstrapped inference for comparing two sample means
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex bootstrapped inference.py
# | DATE: 10/16/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example of bootstrapped inference for comparing two sample means
# *----------------------------------------------------------------
import numpy as np
@BioSciEconomist
BioSciEconomist / ex mean bootstrap CI.py
Created October 16, 2020 21:03
Python bootstrapped confidence interval
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex mean bootstrap CI.py
# | DATE: 10/16/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example calculation of bootstrapped confidence interval for mean
# *----------------------------------------------------------------
import numpy as np
@BioSciEconomist
BioSciEconomist / ex power sim repeated measures anova.R
Last active October 8, 2020 21:08
ex power simulation for repeated measures
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex power sim repeated measures anova.R
# | DATE: 10/10/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: https://gist.github.com/BioSciEconomist
# *----------------------------------------------------------------
# | PURPOSE: annotated code based on reference cited below
# *----------------------------------------------------------------
# reference: https://www.r-bloggers.com/2012/01/power-and-sample-size-for-repeated-measures-anova-with-r/