Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / ex DID vs repeated measures.R
Last active September 11, 2020 22:17
compare repeated measures model with random effects with DID
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex DID vs repeated measures
# | DATE: 9/9/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: https://gist.github.com/BioSciEconomist
# *----------------------------------------------------------------
# | PURPOSE: compare repeated measures model with random effects with DID
# *----------------------------------------------------------------
# see also: http://econometricsense.blogspot.com/2018/02/intuition-for-random-effects.html
@BioSciEconomist
BioSciEconomist / ex ITT vs IV CACE LATE.R
Created June 4, 2020 15:41
Toy data and example of ITT vs instrumental variables/complier average causal effects
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex ITT vs IV CACE LATE.R
# | DATE: 6/4/20
# | 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
# *----------------------------------------------------------------
# reference: Matering Metrics. Angrist and Pishke. 2015 (p.110)
@BioSciEconomist
BioSciEconomist / addition problems.py
Last active May 9, 2020 18:54
Generate 4 digit addition problems for home school/quiz
#------------------------------------------------------------------
# PROGRAM NAME: addition problems.py
# DATE: 5/9/20
# CREATED BY: MATT BOGARD
# PROJECT FILE: /Users/amandabogard/Google Drive/Python Scripts
#----------------------------------------------------------------
# PURPOSE: generate basic addition problems
# ---------------------------------------------------------------
# references: modified from: https://codereview.stackexchange.com/questions/106464/generating-arithmetic-quiz-questions
@BioSciEconomist
BioSciEconomist / ex bank marketing predictive model.py
Created May 1, 2020 20:32
Predictive model training, validation, and scoring basic example
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex bank marketing predictive model.py
# | DATE: 5/1/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: basic example of predictive modeling, evaluation, and scoring
# *----------------------------------------------------------------
# Import numpy and pandas
@BioSciEconomist
BioSciEconomist / Power Analysis for ITT.py
Last active November 14, 2021 22:23
Power analysis for intent to treat
# *-----------------------------------------------------------------
# | PROGRAM NAME: Power Analysis for ITT.py
# | DATE: 4/14/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: examples of power calculations considering ITT analysis
# *----------------------------------------------------------------
# reference: https://blogs.worldbank.org/impactevaluations/power-calculations-101-dealing-with-incomplete-take-up
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex cluster analysis.R
# | DATE: 3/6/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: basic mechanics of cluster analysis
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex factor analysis.R
Last active March 11, 2020 15:36
Basic factor analysis examples
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex factor analysis.R
# | DATE: 3/6/20
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: basic mechanics of factor analysis
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / percentiles.R
Last active February 27, 2020 20:05
Percentile based scorecard for predictive model
# ------------------------------------------------------------------
# |PROGRAM NAME: percentiles.R
# |DATE: 2/25/20
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: quickly divide predicted probabilities into groups based on percentiles
# | and assess model performance
# |------------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / dc customer segmentation.py
Created February 27, 2020 15:57
dc customer segmentation
# *-----------------------------------------------------------------
# | PROGRAM NAME: dc customer segmentation
# | DATE: 5/17/19
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:/Users/amandabogard/Google Drive/Python Scripts
# *----------------------------------------------------------------
# | PURPOSE: code from Data Camp course
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / sample size for LATE.R
Created February 18, 2020 20:34
IV/LATE/CACE Power Analysis
# ------------------------------------------------------------------
# |PROGRAM NAME: sample size for LATE.R
# |DATE: 1/30/19
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: M:\Matt B\MB Coders Corner
# |----------------------------------------------------------------
# | PURPOSE: sample size and power calculations for LATE in instrumental variables analysis
# |----------------------------------------------------------------
# based on: Kirk Bansak. "A Generalized Framework for the Estimation of Causal Moderation Effects with
# Randomized Treatments and Non-Randomized Moderators." (Under Review) https://arxiv.org/pdf/1610.08580.pdf