Skip to content

Instantly share code, notes, and snippets.

View affans's full-sized avatar

AffanA affans

View GitHub Profile
## Affan's reproduce
library(distributions3)
library(ggplot2)
library(tidyverse)
library(R.utils)
library(zoo)
library(tictoc)
#load("formatted_US_death_data.rds")
rm(list = ls())
library(nimble)
library(coda) # For manipulation of MCMC results.
library(mgcv)
library(ggplot2)
library(ggpubr)
#library(tidyverse) # not on the cluster
library(ggmcmc)
function get_agedist(st)
grps = (0:4, 5:16, 17:49, 50:65, 66:99)
_data = CSV.File("sc-est2019.csv") |> DataFrame!
# select only the relevant columns
select!(_data, Not(8:17))
# filter to include both male/female, state
filter!(r -> r[:SEX] == 0 && r[:NAME] == st && r[:AGE] <= 99, _data)
# calculate the the age groups
transform!(_data, :AGE => ByRow(x -> findfirst(grp -> x in grp, grps)) => :AGEGRP)
@affans
affans / gist:8a82537629bfe99860110e692d9c8d29
Created April 5, 2021 19:18
Julia string parse and evaluate
julia> a = "test"; expr = "$a = zeros(Float64, 10)" # note the string is interpolated, easier to read
"test = zeros(Float64, 10)"
julia> julia_expr = Meta.parse(expr)
:(test = zeros(Float64, 10))
julia> dump(julia_expr) # see the Abstract Syntax Tree of the expression (only for informational purposes)
Expr
head: Symbol =
args: Array{Any}((2,))
@affans
affans / covid19 - basic dynamical system
Last active March 9, 2021 17:00
COVID-19 Model Implemention
# Affan Shoukat
# Center for Infectious Disease Modelling and Analysis
# Yale University, Dec 2020
# Repository: https://gist.github.com/affans/f529f8cd727989143c979afd9174b984
module covid19ode
using OrdinaryDiffEq
using Parameters
using LinearAlgebra
using ForwardDiff
using ProgressMeter
@affans
affans / SIR.ipynb
Created January 29, 2020 22:46 — forked from mschauer/SIR.ipynb
SIR
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@affans
affans / startup.jl
Created July 29, 2019 17:55
My Julia `startup.jl`
## push local working path for all code.
push!(LOAD_PATH, "$(homedir())/Documents/Repository")
## load packages
using BenchmarkTools
using Logging
# remove from production
logger = SimpleLogger(stdout, Logging.Debug)
global_logger(logger)
@info "Debug Logging is on for this session."
@affans
affans / cdiffcosts.md
Last active December 18, 2018 21:34
cdiff costs

Data Table for Cost-Effectiveness

Column Name Description
mc Sim Number
uid Patient unique ID
duration.stay.days ?
isolation.days ?
symptom.days ?
is.symptomatic T/F if patient is symptomatic
using srun from command line
srun -J $jobname -n $np -o "job%4t.out" -D $exehome $(srunargs) $exename $exeflags $worker_arg
or sbatch script
#!/bin/sh
#SBATCH --partition=defq
#SBATCH --nodes=16
#SBATCH --ntasks=512