1
$\begingroup$

In order to help interpret fitted models — especially those with interaction terms and non-linear components — I've found it useful to plot predicted values of a dependent variables for what we might think of as prototypical individuals. I would like to know if there are existing R modules that help do this.

The idea behind these plots of prototypical individuals is to use parameter estimates from a model to plot the predicted values of some dependent variable across a range of an independent variables (often the x-asis is time in the context of longitudinal models) for different values of a (usually categorical) variable while holding everything at the sample mean or median.

This is a technique discussed in depth by Judith Singer and John Willett in their book on Applied Longitudinal Data Analysis (see slide 20 in this presentation (PPT) by the authors) Another example might be this figure (Figure 2) from this paper (PubMedCentral) on development trajectories or this plot (PNG) from a recent paper of my own.

I have written R code that takes a series of different model objects along with a long list of optional arguments that let you specify a wide variety of options for creating these plots. My module then gives you back a data frame that you can use with ggplot2 or your plotting software of choice. As I invest more time into my own code, I'm wondering if its worth continuing development of this and the release of a package in CRAN or if there is an existing system I might use and build upon.

The only similar module I know about is visreg which is great but which, as far as I can tell, is designed to visualize the fit of model rather than creating plots of prototypical individuals from fitted models that one might use in publications.

$\endgroup$
  • 1
    $\begingroup$ It seems to me the novelty of your work will lie in how you define "prototypical" (of which I am not aware of anything directly related). It reminds me a bit of Gelman and Pardoe (2007) in which they use Mahalanobis distances to define "average" effect sizes. Those same distances can be used to construct potential "protypical" individuals. $\endgroup$ – Andy W May 17 '13 at 17:26
  • $\begingroup$ Thanks Andy! I'm not thinking of this a paper. I've written code already. I'm just wondering if I should release this code into CRAN or if I should contribute to another project that is doing something. Great suggestion about Gelman and Pardoe! I have run into that before I think I should absolutely build that in! $\endgroup$ – Benjamin Mako Hill May 17 '13 at 17:33
1
$\begingroup$

The closest thing I've found so far is John Fox's Effects Package. The package is both actively maintained and extremely mature — you can read this 2003 paper about it in the Journal of Statistical Software. I was able to use it recently to do most of what I had been doing in my own little package. The code to use it is less fragile and more clear.

With the package, you construct a list and set the xlevels so that they include a range across your x-axis variable while holding the rest at the values of the prototypical individual(s). The effect() function will return an object that contains both predicted values and 95% confidence intervals for a variety of different types of model objects.

The package includes a good deal of plotting code. Although these plots are instructive and useful, they are rather "old-school R" and not publication quality. That said, the eff (or effpoly) object includes all the data necessary to construct a dataset to render beautifully with ggplot2 or similar.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.