Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / sim multiple tests.py
Created March 16, 2021 13:33
Demonstrate the impact of multiple tests and false discovery rates
# *-----------------------------------------------------------------
# | PROGRAM NAME: sim multiple tests.py
# | DATE: 3/12/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: demonstrate the impact of multiple tests and false discovery rates
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex logit marginal effects.py
Created March 5, 2021 01:23
example code for getting marginal effects from logistic regression using python
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex logit marginal effects.py
# | DATE: 3/4/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example code for getting marginal effects from logistic regression
# *----------------------------------------------------------------
import pandas as pd
@BioSciEconomist
BioSciEconomist / ex RDD logistic.py
Created March 5, 2021 00:30
Regression discontinuity model with binary outcome comparison of logistic regression and linear probability model
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 4 17:23:08 2021
@author: mattbogard
"""
#*-----------------------------------------------------------------
# | PROGRAM NAME: ex RDD logistic.py
@BioSciEconomist
BioSciEconomist / ex RDD logistic.R
Created March 5, 2021 00:23
Example comparing logistic regression to linear probability model in regression discontinuity model
# *-----------------------------------------------------------------
# | PROGRAM NAME:ex RDD logistic.R
# | DATE: 3/4/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: RDD with binary outcomes
# *----------------------------------------------------------------
library(dplyr)
@BioSciEconomist
BioSciEconomist / simulate claims cost data.R
Created March 3, 2021 23:41
Simulate claims cost data for treatment and control experiment scenario
# *-----------------------------------------------------------------
# | PROGRAM NAME: simulate claims cost data.R
# | DATE: 3/2/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: simualte example treatment and control claims cost data
# *----------------------------------------------------------------
# https://data.library.virginia.edu/assessing-type-s-and-type-m-errors/
@BioSciEconomist
BioSciEconomist / sim total allowed.py
Created March 3, 2021 23:39
Simulate health care costs using the gamma distribution
# ------------------------------------------------------------------
# |PROGRAM NAME: sim total allowed.py
# |DATE: 2/26/21
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: simulate total allowed costs
# |----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex typeMS.R
Created March 3, 2021 23:36
Type M and S errors with simulation
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex typeMS.R
# | DATE: 3/2/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example estimate type M and S error using simulated data
# *----------------------------------------------------------------
# References:
@BioSciEconomist
BioSciEconomist / ex marginal effects.R
Last active March 8, 2023 16:55
Example marginal effects for logistic regression
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex marginal effects.R
# | DATE: 2/26/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example calculations of marginal effects
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / ex RDD2.py
Last active March 1, 2021 18:47
Example of regression discontinuity design in python (compared to R)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 26 20:16:01 2021
@author: mattbogard
"""
#*-----------------------------------------------------------------
# | PROGRAM NAME: ex RDD2.py
@BioSciEconomist
BioSciEconomist / ex RDD.R
Last active March 1, 2021 18:47
Basic regression discontinuity in R
# *-----------------------------------------------------------------
# | PROGRAM NAME: ex RDD.R
# | DATE: 2/26/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: example RDD estimates & visualization vs OLS regressions near the cutoff
# *----------------------------------------------------------------