MERpsychophysics (beta release)

The package MERpsychophysics contains a collection of R functions for the analysis of psychophysical data in R.You can download the package by clicking here or on MERpsychophysics R code in the Blogroll. Together with the r-files, you should also receive a copy of the GNU Public License (LICENSE.txt) and the reference manual (MERpsychophysics_Reference_Manual.pdf). In order to load the package on your current R workspace, you should:

  1. Unzip the MERpsychophysics.0 folder, if necessary.
  2. Put the MERpsychophysics.0 folder  in your favorite path (e.g. “/Users/alessandro”)
  3. Open the R session, and type: setwd(“my path/MERpsychophysics.0”) – for example, setwd(“/Users/alessandro/MERpsychophysics.0”)
  4. Type: source(“MERpsychophysics.r”)
  5. Use again the setwd function in order to change the working directory. For example: setwd(“my path/my data folder”). If you don’t change the working directory, all exported file will be saved in MERpsychophysics.0 folder.
  6. Have fun with it! If is the first time you use the package, you might want to open the file MERdemo.r and see some examples.

It is necessary to repeat steps 3-4 at each new working session – or simply write the the two command lines at the beginning of your R script.  The first time you use the MERpsychophysics, remember to install all the R packages indicated in the Reference Manual.

The code provides the following tools for   the analysis of psychophysical data with the Generalized Linear Mixed Model (GLMM):

  • Estimate of PSE and JND and their confidence interval with Bootstrap Method
  • Estimate of PSE and JND and their variance with Delta Method
  • GLMM plotting

The CRAN package lme4.0 is used for GLMM fitting. This package is widely used in the statistical community for the analysis of clustered data. Please, refer to the CRAN and to the lme4 web-page for further details on this package (you will find all the links here).  The MERpsychophysics.0 is compatible with the  version of lme4.0 (not with the the current CRAN version version lme4.1). See here to install lme4.0 (if you are running on OS X Maverick see also here).

Algorithms used in MERpsychophysics for PSE and JND, which are not in the lme4 package, are referenced in the following article:

Moscatelli A, Mezzetti M, Lacquaniti F (2012). Modelling Psychophysical Data at the Population-Level: The Generalized Linear Mixed Model. Journal of Vision, 12(11):26.

The article is OPEN access. In the web site of  the Journal of Vision, you will also find the figures of the article in full-quality and original size. Please, cite the article if using the MERpsychophysics package for your data analysis!

The code is in a beta release, I am considering to write it as CRAN package later on – any feedback is welcome!

Contacts details are in the Blogroll.

Advertisements
Tags: ,

4 Comments to “MERpsychophysics (beta release)”

  1. Thanks for this work and the associated package! I was surprised to see that the interest in GLMMs was so little in psychophysics despite it looking like the most appropriate method of analysis. I only knew of the psyphy package from Ken Knoblauch (which provides additional link functions for the lme4 package).

    That is beyond the point of your recent article and this package, but do you know how the lme4 package could be used on data obtained through adaptive procedures (staircase or more advanced ones) ?

    • Hi Pierre, and thanks for your comment!

      I am not familiar with adaptive procedure, but I think that fitting such data with GLMM (or GLM for the single subject) violates the model assumption. The GLMM assumes that responses are independent (conditional to the fixed and random explanatory variables), and in order to fulfill the assumption we randomize the trials in the method of constant stimuli. This is not the case in an adaptive procedure, and I guess in this case the assumption doesn’t hold…

  2. Hi Dr. Moscatelli, if you are still thinking about updating this code to be compatible with lme4.1 and creating a CRAN package, I just wanted to let you know that there is interest out there in your technique!
    Cheers,
    Kim

    • Hi Kim,
      Absolutely, I am working on it! Actually, updating the code to lme4.1 it is quite easy. It is taking time because at the same time I will introduce new features, such as PSE/JND estimate for a multivariate model with both delta and bootstrap method. I will upload some of them by the end of the next week.

      Also, in order to make the compatibility issue easier to handle in the future, I created a function (called xplode.mer) that will extract the slots from the internal structure of lme4. All other function depends on xplode.mer, this way, I will have to update only xplode.mer as the lme4 changes.

      All best
      Alessandro

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: