Usually R snippets, with explanation

Most of these are going to be from this gitlab repo. I also post over at the R Club blog.

• Brief MLM tutorial

September 20, 2016

Updated: plotting estimates from real data using predict.

This is a brief description of how to think about multi-level models, especially the link between the formal expression of these models and how that looks in lme4. The data set consists of 4 observations per day over 2 days of cortisol in a developmental sample. The relevant theoretical questions are: what individual-level predictors are related to cortisol intercepts and slopes.

• Plotting using predict

September 12, 2016

fork this on gitlab

One of my favorite functions in R is predict, and so in response to this recent question on SlackRs#plots (“Anyone know how to plot an interaction at a moderators mean, +1SD, and -1SD?”) I thought I’d write up a quick demo of it’s usefulness.

• Power to detect mediation and other problems

September 2, 2016

fork this on gitlab

I was reminded of this old R Club post recently by Rose, and decided to flesh it out a bit. The first part is about power to detect mediation in the standard 3 variable model people use. The second part examines how model misspecification gives rise to significant statistical tests of mediation when there is actually no mediation going on. Since publishing a paper (in press now, but written in ~2013) in which longitudinal data was subjected to a test of mediation, I’ve become increasingly skeptical of these kinds of analyses (including my own).

• Intro to Bootstrapping

November 14, 2014

“It just works”

All of the information you have about the population is in your sample – you can learn something about the ‘empirical sampling distribution’ of your parameters by estimating them in new samples drawn, with replacement, from your sample. Replacement is crucial – your bootstrap samples will be the same size as your observed sample, but will be comprised of observations from your sample at a rate proportional to the frequency in the sample. Note: There are several different methods for producing replicates.

• Simulation Example

November 12, 2014

The motivation for this example has to do with different ways one can calculate individual differences with regard to the effect of some manipulation that pushes around cortisol levels.

As a general resource for simulation in R, I highly recommend Hadley Wickham’s simulation presntation. Also, the psych package has some great tools for generating data (with great support in this helpful guide by William Revelle).

• Using fMRI to study child and adolescent development

September 11, 2014

Every other year, The Society for Research in Child Development hosts a series of smaller, special topic conferences. This year I was lucky to go to the Developmental Methodology conference. I was blown away by what I saw there, and left very inspired.

My contribution was to present the DSN lab’s guide to best practices both for our fellow imagers, as well as for those reading the literature without much background. Here it is:

Flournoy, J. C., Moore III, W. E., & Pfeifer, J. H. (2014, September 11). Using fMRI to study child and adolescent development: Thoughts from the trenches. Presented at Developmental Methodology, San Diego, CA.

Blog - John C. Flournoy