The proto package is my latest favourite R goodie. It brings prototype-based programming to the R language - a style of programming that lets you do many of the things you can do with classes, but with a lot less up-front work. Louis Kates and Thomas Petzoldt provide an excellent introduction to using proto in the package vignette.

As a learning exercise I concocted the example below involving Bayesian logistic regression. It was inspired by an article on Matt Shotwell's blog about using R environments rather than lists to store the state of a Markov Chain Monte Carlo sampler. Here I use proto to create a parent class-like object (or

First here's an example session...

# Make up some data with a continuous predictor and binary response

nrec <- 500

x <- rnorm(nrec)

y <- rbinom(nrec, 1, plogis(2 - 4*x))

# Predictor matrix with a col of 1s for i…

As a learning exercise I concocted the example below involving Bayesian logistic regression. It was inspired by an article on Matt Shotwell's blog about using R environments rather than lists to store the state of a Markov Chain Monte Carlo sampler. Here I use proto to create a parent class-like object (or

*trait*in proto-ese) to contain the regression functions and create child objects to hold both data and results for individual analyses.First here's an example session...

# Make up some data with a continuous predictor and binary response

nrec <- 500

x <- rnorm(nrec)

y <- rbinom(nrec, 1, plogis(2 - 4*x))

# Predictor matrix with a col of 1s for i…