Jeromy Anglim's Blog: Psychology and Statistics


Monday, February 21, 2011

R Optimisation Tips using Optim and Maximum Likelihood

This post summarises some R modelling tips I picked up at AMPC2011.

I got some tips from a tutorial on parameter estimation put on by Scott Brownfrom the Newcastle Cognition Lab. The R code used in the tutorial is available directly here or from the conference website.

The main tips I took from the tutorial were:

  • Consider using BIC as a model comparison criterion.
  • When modelling reaction times, consider modelling data as a mixture model of two processes. One process is the main process of experimental interest and another is a secondary process that otherwise contributes noise. The secondary process is used to capture what would otherwise be outliers that flow, particularly, from very slow reaction times observed when participants get distracted. Probability assigned to the two processes can be specified a priori based on knowledge of the experimental phenomena. In the specific example that Scott showed, the outlier process was given a probability of 0.03 and this was treated as a uniform distribution between 0 and the trial time-out time.
  • Consider transformations model parameters for the purpose of estimation and then converting the transformed parameters back to their original scale. This can facilitate estimation and also assist in enforcing psychologically meaningful constraints on parameter values (e.g., ensuring that asymptotic reaction time is greater than zero).
  • The combination of the R function optim and a custom created objective function, such as a minus log-likelihood function provides a powerful tool for parameter estimation of custom models.
  • I also got the impression that it will soon be time to dive into WinBUGS.