This is a place for miscellaneous R and other code I've put together for clients, co-workers or myself for learning and demonstration purposes. The attempt is made to put together some well-commented and/or conceptually clear code from scratch, though most functionality is readily available in any number of well-developed R packages. Typically examples are provided using such packages for comparison of results.
At present I'm now doing these via markdown, so any demo code will typically have an md, Rmd, and html file rather than, or in addition to a (purled) R file. For a quick peek that shows most things in the way intended, one can look at the md file directly within github. Otherwise, one can view the html files here.
Code related to fitting of various models.
standard regression, penalized regression, gradient descent regression (online), one factor random effects (R) (Julia) (Matlab), two factor random effects (R) (Julia) (Matlab), cubic spline, hurdle poisson, hurdle negbin, zero-inflated poisson, zero-inflated negbin, Cox survival, confirmatory factor analysis, EM mixture univariate, EM mixture multivariate, EM probit, EM pca, EM probabilistic pca, EM state space model, Gaussian Process noisy, Gaussian Process noise-free, reproducing kernel hilbert space regression, stochastic volatility, bivariate probit, quantile regression ...
BEST t-test, linear regression (Compare with BUGS version, JAGS), mixed model, mixed model with correlated random effects, beta regression, mixed model with beta response (Stan) (JAGS), mixture model, topic model, multilevel mediation, variational bayes regression, gaussian process, ...
Short courses and technical reports I put together from time to time. This is currently changing from linking to the relevant code to linking to the docs themselves. The docs are or will be (after updating) made for web presentation first, but some will link to pdf.
Introduction to R, Generalized Additive Models, Machine Learning, Mixed Models, generally speaking (files)(pdf), Comparison of mixed models and 'ANOVA' (files) (pdf), Comparison of mixed and additive models (files) (pdf), Comparison of mixed and latent growth curve models (files), ...
Random shenanigans.
FizzBuzz test (R) (julia) (Python), Reverse a string recursively (R) (Python), Recursive Word Wrap (R) (Python), get US Congress roll call data, Scrape xkcd (R) (Python), Shakespearean Insulter, ggplot2 theme, R matrix speedups, ...