Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / DID LPM Power.py
Last active May 17, 2022 21:14
Back of the Envelope Difference in Differences Simulation and Power Analysis for a Linear Probability Model
# *-----------------------------------------------------------------
# | PROGRAM NAME: DID LPM Power.py
# | DATE: 1/6/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: simulate data mimicking hypothesized DID scenario and assess power (2x2 DID)
# *----------------------------------------------------------------
# !!!!!! WARNING - UNDER CONSTRUCTION - THIS DOES NOT ACCOUNT FOR CORRELATION STRUCTURES
@BioSciEconomist
BioSciEconomist / ex EValues.R
Last active January 6, 2022 20:23
explore using e-values for sensitifity to confounding in the context of OLS
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex EValues.R
# | DATE: 1/6/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: explore using e-values for sensitifity to confounding in the context of OLS
# *----------------------------------------------------------------
# references:
@BioSciEconomist
BioSciEconomist / ex basic econometrics.py
Created November 14, 2021 22:35
Example calculations of marginal effects for LOGIT vs LPM VIFs and robust SEs
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex basic econometrics.py
# | DATE: 11/14/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example calculate ME for LOGIT vs LPM VIFs and robust SEs
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex basic econometrics.R
Created November 14, 2021 22:27
Example calculations of VIFs and robust SEs
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex basic econometrics.R
# | DATE: 11/14/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example calculate VIFs and robust SEs
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / toy SHAP.py
Last active October 15, 2021 12:54
toy example using shap values
# *-----------------------------------------------------------------
# | PROGRAM NAME: toy SHAP.py
# | DATE: 10/14/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: toy example using shap values
# *----------------------------------------------------------------
import numpy as np
@BioSciEconomist
BioSciEconomist / beyond SHAP.py
Last active October 15, 2021 02:05
Simulate data where SHAP values are not causal
# *-----------------------------------------------------------------
# | PROGRAM NAME: beyond SHAP.py
# | DATE: 10/14/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: simulate SHAP values that are not causal
# *----------------------------------------------------------------
# this code is based on: Be Careful When Interpreting Predictive Models in Search of Causal Insights
@BioSciEconomist
BioSciEconomist / ex matching.py
Created June 26, 2021 19:17
Very basic propensity score matching and IPTW analysis with balance diagnostics
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex matching.py
# | DATE: 6/25/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: very basic matching and IPTW analysis with balance diagnostics
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex marginal effects and divide by 4.R
Created June 1, 2021 14:27
Simulating logistic regression marginal effects and divide by 4 rule
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex marginal effects and divide by 4.R
# | DATE: 6/1/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example calculations of marginal effects and divide by 4 rule
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex sample size.py
Last active April 9, 2021 02:02
demonstrate the impact of small samples and errors in sign and magnitude
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex sample size.py
# | DATE: 4/8/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demonstrate the impact of small samples and errors in sign and magnitude
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex kmeans.py
Created March 17, 2021 18:54
Example k-means clustering
## *-----------------------------------------------------------------
# | PROGRAM NAME: ex kmeans.py
# | DATE: 3/17/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example code based on: https://realpython.com/k-means-clustering-python/
# *----------------------------------------------------------------
df = pd.read_csv('/Users/mattbogard/Google Drive/Python Scripts/german_reunification.csv')