Thursday, April 4, 2013

R 3.0 released; ggplot2 stat_summary bug fixed!

The new version of R was released yesterday. As I understand it, the numbering change to 3.0 represents the recognition that R had evolved enough to justify a new number rather than the addition of many new features. There are some important new features, but I am not sure they will affect me very much. 

For me, the much bigger change occurred in the update of the ggplot2 package to version 0.9.3.1, which actually happened about a month ago, but I somehow missed it. This update is a big deal for me because it fixes a very unfortunate bug from version 0.9.3 that broke one of my favorite features: stat_summary(). As I mentioned in my previous post, one of the great features of ggplot is that allows you to compute summary statistics "on the fly". The bug had broken this feature for certain kinds of summary statistics computed using stat_summary(). A workaround was developed relatively quickly, which I think is a nice example of open-source software development working well, but it's great to have it fixed in the packaged version.

Saturday, March 2, 2013

Why I use ggplot


For the last few years I have been using the ggplot2 package to make all of my figures. I had used Matlab previously and ggplot takes some getting used to, so this was not an easy switch for me. Joe Fruehwald's Penn R work group was a huge help (and more recently, he posted this excellent tutorial). Now that I've got the hang of it, there are two features of ggplot that I absolutely can't live without.

Friday, February 8, 2013

Using R to get h5-index for a list of journals

In my last blog post I wrote about impact factors and h-index for different journals. That got me wondering about what the h5 index is for all of the journals that I read and may want to publish in. I could look them all up individually, but that sounds boring and monotonous. I'd much rather figure out how to get R to do it for me. I've never done this kind of thing with R before, so it took a little while, but I wrote a simple function that takes a journal name and returns its h5-index. 

Thursday, February 7, 2013

Impact factor vs. H-index

I've been thinking about journal rankings and impact factors lately, partly because I noticed that impact factors and H-index sometimes give quite different rankings for journals. To pick one example, Neuropsychologia and Cortex are two very good cognitive neuroscience journals that publish similar sorts of articles, but the impact factor for Cortex is substantially higher than for Neuropsychologia (6.08 vs. 3.636), whereas the H-index is substantially higher for Neuropsychologia than for Cortex (67 vs. 41). In case you are unfamiliar with these measures, impact factor is basically the mean number of citations to articles that were published in the past 2 years; H-index is the largest number h such that h articles have at least h citations each. So the articles published in Cortex have been cited an average of about 6 times and there are 41 articles that have been cited at least 41 times; the articles in Neuropsychologia have been cited an average of about 3.6 times and there are 67 articles that have been cited at least 67 times. Since both measures are based on citation rates, why do they give different rankings? 

Friday, January 18, 2013

Using R to create visual illusions

This brings together two of my favorite (professional) things: R and visual illusions. Aside from being an extremely impressive application of R, it's a cool way of making it clear that the illusion is, in fact, an illusion. Here's a simple example:

library(grid)
grid.newpage()
grid.rect(c(1,3,1,3)/4, c(3,3,1,1)/4, 1/2, 1/2, 
          gp = gpar(col = NA, fill = gray(1:4/5)))
grid.rect(c(1,3,1,3)/4, c(3,3,1,1)/4, 1/6, 1/6, 
          gp = gpar(col = NA, fill = gray(0.5)))

Which creates the image below. The first call to grid.rect makes a set of four squares of different shades of gray, the second call inserts smaller squares inside those larger squares. The smaller squares are all the same shade of gray - which is obvious from the R code - but they appear to be different: the one in the upper left appears lightest and the one in the lower right appears darkest.


Monday, December 17, 2012

Gender equality in science

An interesting post over at BishopBlog takes on the lack of men in Psychology. One of the reasons BishopBlog is a favorite of mine is that you get real data along with interpretations and opinions. Two points in the post strongly resonated with my experience. 

One is the decline of women in science by career stage. A few years ago, the NSF did a major study of women and minorities in science and identified attrition as a key reason for the under-representation of women in science. Following Dr. Bishop's example, a little complementary data (from 2010; these and lots more data are available here): in Neuroscience, the graduate student population was slightly biased toward women (52.7% are female), but the postdoctoral fellow population was biased toward men (only 45.7% were female). Given the fairly large sample sizes (2798 graduate students and 818 postdocs), this difference was highly reliable (chi-square test of independence, p < 0.001). 

The second is the effect of sub-field. I am particularly sensitive to this because I seem to work in two of the most gender-biased sub-fields: computational modeling seems strongly male-dominated, but cognitive neuropsychology seems strongly female-dominated. I couldn't find data for those fields exactly, but the APA membership data that Dr. Bishop mentioned show a huge disparity: women make up only about 25% of the members in Experimental Psychology and Behavioral Neuroscience, close to half in Clinical Neuropsychology, and about 70% in Developmental Psychology.

This issue is certainly complex and there is no simple solution. That said, there are some strategies that we know would help and can be implemented relatively easily. For example, we know that there is bias in the review process (e.g., Peters & Ceci, 1982), so why not make it double-blind? This is already the standard in some fields, but remains generally optional or unavailable in cognitive science and cognitive neuroscience. It is true that reviewers may be able to guess the identity of the author(s) some of the time, but isn't guessing correctly some of the time better than knowing all of the time? This would (partially) level the playing field between genders as well as between junior and senior scientists and should lead to a more fair system.


References
Peters, D. P., & Ceci, S. J. (1982). Peer-review practices of psychological journals: The fate of published articles, submitted again. Behavioral and Brain Sciences, 5, 187-255.

Friday, December 14, 2012

Lateralization of word and face processing

A few weeks ago I was at the annual meeting of the Psychonomic Society where, among other interesting talks, I heard a great one by Marlene Behrmann about her recent work showing that lateralization of visual word recognition drives lateralization of face recognition. Lateralization of word and face processing are among the most classic findings in cognitive neuroscience: in adults, regions in the inferior temporal lobe in the left hemisphere appear to be specialized for recognizing visual (i.e., printed) words and the same regions in the right hemisphere appear to be specialized for recognizing faces. Marlene and her collaborators (David Plaut, Eva Dundas, Adrian Nestor, and others) have shown that these specializations are linked and that the left hemisphere specialization for words seems to drive the right hemisphere specialization for faces. It's a nice combination of: 
  1. Behavioral experiments showing that lateralization for words develops before lateralization for faces, and that reading ability predicts degree of lateralization for faces (Dundas, Plaut, & Behrmann, 2012).
  2. ERP evidence also showing earlier development of lateralization for words than for faces.
  3. Computational modeling showing how this specialization could emerge without pre-defined modules (Plaut & Behrmann, 2011).
  4. Functional imaging evidence that the lateralization is relative: the right fusiform gyrus is more involved in face processing, but the left is involved also (Nestor, Plaut, & Behrmann, 2011).
It's a beautiful example of how different methods can come together to provide a more complete picture of cognitive and neural function.

UPDATE
Less than one week after I posted this, there is a new paper by Behrmann and Plaut (in press, Cerebral Cortex, doi:10.1093/cercor/bhs390) reporting further evidence, this time from cognitive neuropsychology, that lateralization of face and word processing is relative. They tested a group of individuals with left hemisphere damage and deficits in word recognition ("pure alexia") and a group of individuals with right hemisphere damage and deficits in face recognition ("prosopagnosia"). The individuals with pure alexia exhibited mild but reliable face recognition deficits and the individuals with prosopagnosia exhibited mild but reliable word recognition deficits.

ResearchBlogging.orgDundas EM, Plaut DC, & Behrmann M (2012). The Joint Development of Hemispheric Lateralization for Words and Faces. Journal of Experimental Psychology: General. PMID: 22866684. DOI: 10.1037/a0029503.

Nestor A, Plaut DC, & Behrmann M (2011). Unraveling the distributed neural code of facial identity through spatiotemporal pattern analysis. Proceedings of the National Academy of Sciences, 108(24), 9998-10003 PMID: 21628569

Plaut DC, & Behrmann M (2011). Complementary neural representations for faces and words: a computational exploration. Cognitive Neuropsychology, 28(3-4), 251-275 PMID: 22185237