Skip to content

Instantly share code, notes, and snippets.

Mathew Kiang mkiang

  • Center for Population Health Sciences at Stanford University
  • San Francisco, CA
Block or report user

Report or block mkiang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mkiang
mkiang / intro_sir.R
Created Sep 11, 2019
Skeleton code for the DGHS Workshop
View intro_sir.R
## Import packages
library(deSolve)
## Basic SIR using number of people (not proportion of pop)
SIR <- function(t, x, parms){
with(as.list(c(parms, x)), {
N = S + I + R
dS <- -beta*S*I/N
dI <- beta*S*I/N - r*I
dR <- r*I
View packages.R
install.packages("rgdal", dep = TRUE)
install.packages("reshape2", dep = TRUE)
install.packages("viridis", dep = TRUE)
install.packages("rgeos", dep = TRUE)
install.packages("Imap", dep = TRUE)
install.packages("network", dep = TRUE)
install.packages("DT", dep = TRUE)
install.packages("tidyverse", dep = TRUE)
install.packages("deSolve", dep = TRUE)
install.packages("manipulate", dep = TRUE)
@mkiang
mkiang / collab_network.R
Last active May 10, 2019
Code to create your collaboration network in R
View collab_network.R
## Visualizing authorship networks: code for this blog post:
## https://mathewkiang.com/2018/06/17/my-collaboration-network/
library(scholar) # devtools::install_github("jkeirstead/scholar")
library(visNetwork)
library(tidyverse)
## Constants
MIN_TIME <- 60 * 5
MAX_TIME <- 60 * 30
PROJ_WEIGHT <- .8
View 01_get_data.R
## For blog post here: https://mathewkiang.com/2017/12/02/tldr-san-diego-weather-is-better-than-boston-weather/
## Imports ----
library(tidyverse)
library(GSODR)
library(ggmap)
## Define places we are interested in and google maps query ----
city_dict <- list(sandiego = "san diego airport",
View keybase.md

Keybase proof

I hereby claim:

  • I am mkiang on github.
  • I am mkiang (https://keybase.io/mkiang) on keybase.
  • I have a public key ASBcR0WeyXKq1QlGo0lxZxRG2VRNJKIJ8-h6NNFJLDFSYAo

To claim this, I am signing this object:

@mkiang
mkiang / nejm_blog_post.R
Created Oct 9, 2017
NEJM and pre-print policy
View nejm_blog_post.R
## Code for the blog post here:
## https://mathewkiang.com/2017/10/08/using-r-wikipedia-sherparomeo-show-new-england-journal-medicines-pre-print-statement-empirically-false
## You can download the original files from the blogpost.
## If downloading new files, you probably want to change the date in the file names.
## Imports
library(rvest)
library(tidyverse)
## Wiki data
@mkiang
mkiang / SIR.R
Created Jan 27, 2017
Sample SIR code for EPI 501 lab
View SIR.R
#SIR practical from Debarre and Bonhoeffer ("SIR models of epidemics")
library(deSolve)
parms <- c(beta = 0.333, k = 3 , r = 0.333)
inits <- c(S = 499, I = 1, R = 0)
dt <- seq(0, 300, 1)
SIR <- function(t, x, parms){
with(as.list(c(parms, x)), {
@mkiang
mkiang / histogram_legend.R
Created Jan 17, 2017
Code demonstrating how to use a histogram as a legend on a choropleth
View histogram_legend.R
## Code for this blog post: https://mathewkiang.com/2017/01/16/using-histogram-legend-choropleths/
## Download the drug death data from:
## https://blogs.cdc.gov/nchs-data-visualization/drug-poisoning-mortality/
##
## Download the 2013 CB shapefiles (500k will do) for counties and states:
## https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html
## https://www.census.gov/geo/maps-data/data/cbf/cbf_state.html
## Imports ----
@mkiang
mkiang / lunar_phases.py
Created Jan 7, 2017
Download lunar phases from the US National Observatory as a pandas df
View lunar_phases.py
import requests
import errno
import pandas as pd
import os
def mkdir_p(path):
""" If a directory does not exist, create it. """
try:
os.makedirs(path)
@mkiang
mkiang / google_cites.R
Created Oct 8, 2016
A visual tour of my publications
View google_cites.R
## Code for this blog post:
## http://mathewkiang.com/2016/10/08/a-visual-tour-of-my-publications/
## Imports
library(RColorBrewer)
library(ggplot2)
library(dplyr)
library(devtools)
devtools::install_github("jkeirstead/scholar")
library(scholar)
You can’t perform that action at this time.