Nested vs. Non-nested (crossed) Random Effects in R
The R script below illustrates the nested versus non-nested (crossed) random effects functionality in the R packates lme4 and nlme. Note that crossed random effects are difficult to specify in the nlme...
View ArticleRecipe for Centered Horizontal Stacked Barplots (Useful for Likert scale...
There is a nice package and paper about this here: http://www.jstatsoft.org/v57/i05/paper. However, the associated code is complex and uses lattice. Here's a brief recipe using base graphics that...
View ArticleRecipe for Computing and Sampling Multivariate Kernel Density Estimates (and...
The code snippet below creates the above graphic: ## radially symmetric kernel (Gussian kernel) RadSym
View ArticleNotes on Multivariate Gaussian Quadrature (with R Code)
Statisticians often need to integrate some function with respect to the multivariate normal (Gaussian) distribution, for example, to compute the standard error of a statistic, or the likelihood...
View ArticleDelta Method Confidence Bands for Gaussian Density
During one of our Department's weekly biostatistics "clinics", a visitor was interested in creating confidence bands for a Gaussian density estimate (or a Gaussian mixture density estimate). The mean,...
View ArticleDelta Method Confidence Bands for Gaussian Mixture Density (Can Behave Badly)
This post follows from a previous post (2798), in which the delta method was used to create an approximate pointwise 95% confidence band for a Gaussian density estimate. Note that the quality of this...
View ArticleReference Chart for Precision of Wilson Binomial Proportion Confidence Interval
I am often asked about the number of subjects needed to study a binary outcome, which usually leads to a discussion of confidence intervals for binary proportions, and the associated precision....
View ArticleMy Poster at Rocky 2015: Estimating parameters of the Hodgkin-Huxley cardiac...
I'm recently returned from the 2015 Rocky Mountain Bioinformatics Conference, where I presented the above poster. This is work with a colleague, Rick Gray, at the FDA. He and I collaborate on our NIH...
View ArticlePrincipal curves example (Elements of Statistical Learning)
The bit of R code below illustrates the principal curves methods as described in The Elements of Statistical Learning, by Hastie, Tibshirani, and Friedman (Ch. 14; the book is freely available from the...
View ArticleRound values while preserve their rounded sum in R
After an embarrassing teleconference in which I presented a series of percentages that did not sum to 100 (as they should have), I found some R code on stackoverflow.com to help me to avoid this in the...
View ArticleQuick illustration of Metropolis and Metropolis-in-Gibbs Sampling in R
The code below gives a simple implementation of the Metropolis and Metropolis-in-Gibbs sampling algorithms, which are useful for sampling probability densities for which the normalizing constant is...
View ArticleOne-arm Bayesian Adaptive Trial Simulation Code
I had an opportunity recently to design a Bayesian adaptive trial with several interim analyses that allow for early stopping due to efficacy or futility. The code below implements the one-arm, binary...
View Article"Increase sample size until statistical significance is reached" is not a...
TLDR: Begin with N of 10, increase by 10 until p < 0.05 or max N reached. This design has inflated type-I error. Lower p-value threshold needed to ensure specified type-I error rate. The number of...
View Article