Monthly Archives: May 2017

Potentially of interest: summary of a workshop on reproducibility

Statistical Challenges in Assessing and Fostering the Reproducibility of Scientific Results:
Summary of a Workshop (2016)

http://www.nap.edu/catalog/21915/statistical-challenges-in-assessing-and-fostering-the-reproducibility-of-scientific-results

Comments Off on Potentially of interest: summary of a workshop on reproducibility

Filed under Uncategorized

MCMC in Python: Power-posterior calculation with PyMC3

I’ve got a fun little project that has let me check in on the PyMC project after a long time away. Long-time readers of Healthy Algorithms might remember my obsession with PyMC2 from my DisMod days nearly ten years ago, but for those of you joining us more recently… there is a great way to build Bayesian statistical models with Python, and it is the PyMC package. It was completely rewritten for version 3, which is now available, and using it looks like this:

import numpy as np
import matplotlib.pyplot as plt

# Initialize random number generator
np.random.seed(123)

# True parameter values
alpha, sigma = 1, 1
beta = [1, 2.5]

# Size of dataset
size = 100

# Predictor variable
X1 = np.random.randn(size)
X2 = np.random.randn(size) * 0.2

# Simulate outcome variable
Y = alpha + beta[0]*X1 + beta[1]*X2 + np.random.randn(size)*sigma

from pymc3 import Model, Normal, HalfNormal
basic_model = Model()

with basic_model:

    # Priors for unknown model parameters
    alpha = Normal('alpha', mu=0, sd=10)
    beta = Normal('beta', mu=0, sd=10, shape=2)
    sigma = HalfNormal('sigma', sd=1)

    # Expected value of outcome
    mu = alpha + beta[0]*X1 + beta[1]*X2

    # Likelihood (sampling distribution) of observations
    Y_obs = Normal('Y_obs', mu=mu, sd=sigma, observed=Y)

basic_model.logp({'alpha':1,
                 'beta':[1,1],
                 'sigma_log_':0})

What I need is a way to compute the “power-posterior” of a model, which is to say p(\theta\mid y,t) = \frac{p(y\mid \theta)^t p(\theta)}{\mathcal{Z}_t(y)}  .

I’ve figured out a pretty cool way to compute the prior and the likelihood of the model:

from theano import theano, tensor as tt

def logpriort(self):
    """Theano scalar of log-prior of the model"""
    factors = [var.logpt for var in self.free_RVs]
    return tt.add(*map(tt.sum, factors))
def logprior(self):
    """Compiled log probability density function"""
    return self.model.fn(logpriort(self))
def logliket(self):
    """Theano scalar of log-prior of the model"""
    factors = [var.logpt for var in self.observed_RVs] + self.potentials
    return tt.add(*map(tt.sum, factors))
def loglike(self):
    """Compiled log probability density function"""
    return self.model.fn(logliket(self))

Now I just need to put them together, to get the log of the power-posterior. There must be an easy way to do it, but this is not it:

def logpowerpt(self, t):
    return t*loglike(self) + logprior(self)
def logpowerp(self, t):
    return self.model.fn(logpowerpt(self, t))

vals = {'alpha':1,
        'beta':[1,1],
        'sigma_log_':0}
logpowerp(basic_model, 0)(vals)

Any suggestions?

Comments Off on MCMC in Python: Power-posterior calculation with PyMC3

Filed under MCMC

AAUP Forum: The shooting at UW on inagguration day

I moderated a panel discussion of this recent challenging event, and a recording of it is now online:

On January 20, Inauguration Day, self-described anti-fascist activist Josh Dukes was shot and critically injured at a rally at the University of Washington. Milo Yiannopoulos, a high-profile “alt-right” (white supremacist) speaker, had been invited by the College Republicans to speak at Kane Hall on that evening. Hundreds of people opposed to the speaker and his message had rallied outside Kane Hall, where those attending the talk were queued up to enter the hall. Both the UW and the Seattle police were there in force.

In the aftermath of the shooting, information about the incident and the shooter was scarce, and often contradictory. It was reported that someone had turned himself in, but this person was released. Rumors abounded about whether the shooter was a UW student, about whether police had purposefully corralled people from opposing sides in order to create an incident to facilitate arrests, and about whether the shooters were affiliated with individuals who had placed threatening neo-Nazi-style posters on the campus. No arrests were made, and no explanation for the lack of arrests was given. Police and UW administration declined to comment, citing the ongoing investigation as the reason.

Comments Off on AAUP Forum: The shooting at UW on inagguration day

Filed under Uncategorized

Diversity Club: Medical Education and the Minority Tax

Last week the IHME diversity club discussed a recent JAMA viewpoint on “Medical Education and the Minority Tax”. I think this is a good way to frame an important issue:

http://jamanetwork.com/journals/jama/fullarticle/2625322

A Piece of My Mind

May 9, 2017

Medical Education and the Minority Tax

Kali D. Cyrus, MD, MPH1

Author Affiliations Article Information

JAMA. 2017;317(18):1833-1834. doi:10.1001/jama.2017.0196

I sat down at the large conference room table surrounded by the other medical students, some of whom I recognized from earlier stops on the residency interview trail. As they continued their conversations, I looked around, realizing I was once again the only interviewee who is black. I kept gazing around the room, only to find more faces staring back that did not look like me. Hanging grandly from the walls were faces, painted in watercolor, framed in bronze, and undoubtedly of really important men … really important white men.

Comments Off on Diversity Club: Medical Education and the Minority Tax

Filed under Uncategorized

Diversity Club: Transgender Population Size in the United States: a Meta-Regression of Population-Based Probability Samples

Early this month, the IHME Diversity Club discussed the recent paper, Transgender Population Size in the United States: a Meta-Regression of Population-Based Probability Samples, by Meerwijk and Sevelius from AJPH: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5227946/

This helped us dig into trans and non-binary gender and how it relates to our work in health metrics.

Comments Off on Diversity Club: Transgender Population Size in the United States: a Meta-Regression of Population-Based Probability Samples

Filed under Uncategorized