Our results suggest that while professor gender has little impact on male students, it has a powerful effect on female students' performance in math and science classes, their likelihood of taking future math and science courses, and their likelihood of graduating with a STEM degree... Indeed, the gender gap in course grades and STEM majors is eradicated when high performing female students' introductory math and science classes are taught by female professors.
Here's the working paper.
When we presented this paper and a few others in a study on same-gender effects, it was hard to keep the discussion on research and methodology without throwing in a little anecdotal evidence. The truth is, I am a math major and I adored my first math professor in college. And at the time, she was the sole woman in the department. It's pretty easy to use the role model argument here, but as Carrell et all discuss, it could just as easily be that women who choose to teach STEM courses in college have certain shared positive characteristics (dynamic, comprehensible, inspiring).
I'd say my Calc 122 professor had all of them (and I might have chosen my major for strange reasons, like getting back at Barbie) but its just as likely that I pursued math because I admired someone who looked a little more like me.