Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / power simulation multiple ordinal logistic.R
Last active February 8, 2024 00:12
Simulation and power analysis for ordinal logistic regression with covariates
# *-----------------------------------------------------------------
# | PROGRAM NAME: power simulation multiple ordinal logistic.R
# | DATE: 2/3/24
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: R Training
# *----------------------------------------------------------------
# | PURPOSE: power calculations and simulations
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / power simulation ordinal logistic.R
Last active February 8, 2024 00:00
Power and sample size simulation for ordinal regression outcome
# *-----------------------------------------------------------------
# | PROGRAM NAME: power simulation ordinal logistic.R
# | DATE: 2/3/24
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: R Training
# *----------------------------------------------------------------
# | PURPOSE: power calculations and simulations
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / power simulation logistic.R
Created February 3, 2024 18:35
power analysis for logistic regression
# *-----------------------------------------------------------------
# | PROGRAM NAME: power simulation logistic.R
# | DATE: 2/3/24
# | CREATED BY: MATT BOGARD
# | PROJECT FILE: R Training
# *----------------------------------------------------------------
# | PURPOSE: power calculations and simulations
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / calc CI widths.R
Last active October 17, 2022 21:46
Prospectively determine expected CI width (margin of error) based on power calc
# *-----------------------------------------------------------------
# | PROGRAM NAME: calc CI widths
# | DATE: 10/16/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: prespectively determine expected CI width (margin of error) based on power calc
# *----------------------------------------------------------------
# based on: Goodman SN, Berlin JA. The use of predicted confidence intervals when planning experiments and
@BioSciEconomist
BioSciEconomist / basic DID.r
Last active November 2, 2022 21:50
Basic difference in differences in R
# *-----------------------------------------------------------------
# | PROGRAM NAME: basic 2x2 DID.r
# | DATE:
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: simple example of DID and parallel trends
# *----------------------------------------------------------------
rm(list=ls()) # get rid of any existing data
@BioSciEconomist
BioSciEconomist / fun with CIs.r
Created July 23, 2022 01:39
Basic CI simulation
#*-----------------------------------------------------------------
# | PROGRAM NAME: fun with CIs.r
# | DATE: 7/16/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: basic CI simulation
# *----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / CI and TypeMS Errors.r
Created July 19, 2022 20:36
Explore the magnitude and sign of errors when we are underpowered
#*-----------------------------------------------------------------
# | PROGRAM NAME: CI and TypeMS Errors.r
# | DATE: 7/19/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: Explore the magnitude and sign of errors when we are underpowered
# *----------------------------------------------------------------
rm(list=ls()) # get rid of any existing data
@BioSciEconomist
BioSciEconomist / CI Simulation.r
Last active July 19, 2022 15:18
How much confidence can we place in the range of values in a CI vs the point estimate
# *-----------------------------------------------------------------
# | PROGRAM NAME: CI Simulation
# | DATE: 7/16/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: How much confidence can we place in the range of values in a CI vs the point estimate
# *----------------------------------------------------------------
rm(list=ls()) # get rid of any existing data
@BioSciEconomist
BioSciEconomist / ROI CI Simulation.r
Last active July 19, 2022 17:17
How often do CI show values associated with a positive vs negative ROI in a given scenario
# *-----------------------------------------------------------------
# | PROGRAM NAME: ROI CI Simulation.r
# | DATE: 7/16/22
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:
# *----------------------------------------------------------------
# | PURPOSE: How much confidence can we place in the range of values in a CI vs the point estimate
# *----------------------------------------------------------------
rm(list=ls()) # get rid of any existing data
@BioSciEconomist
BioSciEconomist / Power Analysis Binary.py
Created June 7, 2022 00:19
Power Analysis Template for Binary Outcomes
# *-----------------------------------------------------------------
# | PROGRAM NAME: Power Analysis Binary.py
# | DATE: 09/30/21
# | CREATED BY: MATT BOGARD
# | PROJECT FILE:       
# *----------------------------------------------------------------
# | PURPOSE: power calculation and sample size scenarios for binary outcomes
# *----------------------------------------------------------------
 
import pandas as pd