From Active Statistics: Stories, Games, Problems, and Hands-on Demonstrations for Applied Regression and Causal Inference:
Consider the analogy of learning statistics to learning a new language. We tell our students that the class is particularly difficult because they’re learning two foreign languages—statistics and R—both of which can be challenging if you do not have a strong background in math and programming.
The challenge is to learn how to engage in and understand conversations, not merely memorize stock phrases and rules of grammar.
Glad to see this topic. I have always felt that the one class that teaches both languages (statistics and R) shortchanges the latter. The coding part frequently becomes copy and paste.
Kaiser:
True, but I don’t know how to teach statistics without teaching R, so if I’m teaching statistics, I have no choice but to teach R also.
Contrary to everyone else, I prefer the old teach-stats-without-programming approach. Where’s the sense in ruining theoretical statistics with data the way everyone does with applied statistics?
Plus code snippets in stats books age about as well as sequined bell bottoms and platform shoes did after disco died.
I’d be fine with a stats book that had no programming content, but i still think the course should have programming content, and the students should already have some experience programming. Assign two books, “Understanding the world with scientific modeling” (ie. The book I haven’t written yet) and “Introduction to Julia for data analysis” or some such thing which focuses on the code and would change every 4-5 years.
It really depends on which statistics course(s) you are talking about. If it is the general education introduction to statistics, I think it is great to use R with minimal need for the students to learn a lot of it. I currently like coursekata (https://coursekata.org/) a lot for this. Then if they continue they can take a course highly focused on learning R and another course that is less so. But what most folks here are describing is the sequence for statistics majors or graduate students. I think it is great to show college first year students that writing simple code is something that they might find useful, powerful and maybe interesting, same as learning how to do basic things with data.
That said, in our sociology sequence we have chosen to require the first research methods (e.g. data collection, measurement, what’s a research question, sampling) course prior to the first statistics course. This makes sense to me but psychology does the opposite.
Yes it’s two languages or maybe it’s like writing and speaking?
Since I teach statistics using JMP, I have the opposite concern: teaching R can shortchange the teaching of statistics (for many students, the language hurdle limits what can be done with the data – I think this is why so many pre-coded analyses are often used, enabling students to actually do some analysis without having to learn much coding). I know I am in the minority here (to put it mildly) and I see that Andrew is close to the polar opposite as I am.
I agree with the concern that Andrew and Dale bring up, and in my opinion the answer is a prerequisite course in programming and data-munging in a real computer language. Preferably Julia, R, or Python. It would cover things like reading data files, filtering them, fixing data errors and parsing issues, and making plots without concern for what the plots mean just how do you put the lines/points/colors in the figure etc. You could have discussions about what it means, but don’t worry about it too much at this stage. Also defining functions and plotting them as curves, and solving differential equations by describing the derivative to a package that does ODE solving. And simulating discrete time dynamics with random number generation… These are all fundamental tasks for good data analysis. Taking a semester out of your life to learn these basics is not time wasted. Then teach analysis of data and building of models.
I agree with Daniel. During my undergrad I took a course in Numerical Methods that essentially consisted of writing scripts/packages in R to implement various methods that Economists used, most of which I barely understood at the time. I had already programmed in Python/R before, but taking that class really provided a level of comfort with R/Programming that greatly helped me during Graduate School and still helps me today in my work life. Even just having experience installing packages and reading documentation put me a step above my future classmates.
I do wonder though how quickly this will change with ChatGPT and other GPT models. Today you can put in your python code directly into ChatGPT and it will make the corrections/create the plots for you!
In my undergrad, the core sequence for statistics majors involved three classes: statistical programming, probability, and mathematical statistics. Usually, the first two would be taken concurrently then mathematical statistics in the subsequent semester. The statistical programming class was just teaching R assuming no prior programming experience in any language. Probability was just math and did not involve R. Mathematical statistics included only minimal R iirc. Linear regression was only taught at the very end of the course.
This was accurate 5+ years ago. I wonder how things have changed. Before, it was possible (though not necessarily common) to get through the program knowing only minimal R (this was a “top 10” stat department btw) but I’m guessing that’s not the case now.
I think teaching an understanding of what data cleaning is and thinking about what you are aiming for is often missing. A lot of our juniors (in industry) seem to think that data cleaning is simply putting things in a standard form rather than making sure you have thought about your population of interest, a relevant level of aggregation and so on. They find this even harder when clients ask for something that isn’t actually going be very useful.
That can be assessed by giving a group of messy raw CSV files and having students write an R Markdown report explaining what they were given, why it was horrible to work with, what they want to do with it, and the steps they took to get there including code.
Eg You might give
* A table of subjects with professions statistician, data scientist, analyst, lawyer, barrister, solicitor, KC, QC and a record for professional accreditation (which for accountants and barristers is usually given as a job title). Throw in some typos and spelling mistakes for good measure.
* A table of deaths (not including those who are still alive). To be really mean, you could give the lifespan in months for some people and days for others or format it as a string with some trailing spaces.
* A table of hospital appointments.
* A table of treatments A, B, and C with different diseases (which may not be the one you care about), perhaps with different treatments being made by different companies and some treatments.
Then have the students clean the data, do some EDA and recommend a modelling approach to tackle a problem a client has.
I agree with this. I like to teach statistics using JMP too. Then, I think R should be taught in its own class – not just as a tool to do statistics but also include related materials on software development, object-oriented programming, etc. In more advanced classes, we can have both statistics and R assuming the students already know R.
A question about JMP (I don’t have it and don’t use it, this is a real information question): does it allow you to do sampling to show what happens under repeated sampling?
Another question: real data analysis involves pre-processing. E.g., the GUI might need data in wide form but you have it in long form. How is that preprocessing taught when using only a GUI based software? Without data wrangling ability, how do people learn to use what they learned with JMP in real life applications?
1. If I understand your question, most JMP analyses have the built in capability to conduct bootstrap sampling for any of the outputs (with some options regarding the bootstrapping).
2. What I find best about JMP is the ease of manipulating the data files – stacking, splitting, recoding, summarizing, joining are all done quickly, easily, and visually with options to make any reformatted tables into new data files for further analysis. All of these can be done using any number of other programs or languages, of course. But it is the ease of doing so, and visual accessibility of seeing the results that I find most appealing. For students with little background, time, or patience to learn a programming “language” this permits them to focus on the data and manipulate it in innovative ways. As a result, they can go much further than a student with no programming background can in a first course. By the end of a sequence of courses, I would expect most of that difference to be erased.
There is a specific programming language in JMP and it is easily displayed and recorded. I would maintain that the logic of what you want to do with the data (in terms of restructuring the data, for example) is the important logical reasoning, not the rules of any particular programming language (such as where to place (), commas, etc.). The latter does require logic and structure which are important skills, but I don’t think these are necessary to explore data – particularly in a first (and possibly only) course in statistics.
Dale, thanks for this reply. One further question: if there are students who only ever do one course in stats, why are they required to do this course? Is it just to give them a taste of what is possible? Or arethese students expected to actually use stats in real life/research etc?
Looking back on my life, i wish someone had taught me programming, any language, at the first opportunity. Being able to program stuff was life changing. As a teacher, i feel like i need to communicate that magic to these young people. But i see that not everyone wants to engage. I am still trying to convince myself to use a gui for stats, so far not successfully. My main problem is: one needs so little R to do practically useful modeling, one can be up and running in days.
I guess that brings up the question: why do you need coding to learn stats? You don’t need it for any other math class.
I guess this just makes my point from the other day: the material is being watered down and shoved into one class so people who don’t have sufficient skills or background can claim to have taken one course in it – which would be fine, except it gives people the mis-impression that they understand the topic when they don’t.
No doubt, taking a stats class with only theory and equations and paper and pencil would be the epitome of boring for the average journalism student. But if you’re not giving the foundations you’re just entertaining them which, once again, makes my original point.
On one hand, sophisticated statistical analysis could not be common until there were machines to do the repetitive arithmetic. That is why statistical analysis became so much more common in the 20th century (and why older courses often stress seeing if data can be approximated with a normal distribution or a Poisson distribution or some other distribution with properties that are easy to calculate).
OTOH I don’t think my undergrad stats training in the oughties started with coding, it used very small ‘toy’ data sets.
You cannot divine what’s going on in things you have no experience in based on nothing but a curmudgeonly attitude.
You need coding to do numerical analysis.
You need coding to do nonlinear dynamical systems.
Coding is not in statistics to “water it down.” Coding is in statistics because nobody is actually doing nontrivial statistical analyses without computers. Furthermore, there is no reason to believe that implementing a mean function in code is either easier or less amenable to understanding the learning the mean formula on pen and paper.
The idea that adding coding in is somehow making it more approachable is completely laughable—college students are more intimidated by coding than by calculus, since they’re dramatically less likely to know how to do it. In 2021, ~125000 high school students took an AP Calculus BC exam while ~64000 took an AP computer science exam.
But I’m sure things were better when students had the formula for a gaussian memorized but were utterly unable to compute the gaussian log likelihood for any real dataset.
Somebody said:
“nobody is actually doing nontrivial statistical analyses without computers”
The engineers at Boeing aren’t learning how to integrate either. We’re talking about introductory level statistics, where principles are taught, not third year stats.
When people use calculus on real problems, don’t they often plug the integral into a package which applies thousands of rules to solve it automatically? That does not mean that its not valuable for students to begin integrating and differentiating on paper by memorizing some rules and looking up others in the back of the textbook, because that helps them understand what the package is doing and spot any warning signs.
1. I’m not saying that people shouldn’t do things on pen and paper, I’m objecting to the idea that adding in programming is “watering down” the material.
2. Programming doesn’t necessarily mean “using a pre-written package.” In numerical analysis, a common path for the course is to build towards implementing a subset of a numerical integration package. Is drilling the power rule a bunch of times on pen and paper necessarily a better pedagogical experience than writing a small symbolic algebra program that can apply the power rule for a x^k like
def derive_power_rule_term(a, x, k):
return k * a * (x ** k -1)
Indeed, “doing the math” and “writing the program” are essentially equivalent in the Curry-Howard sense.
3. In statistics, many core concepts are expressed and understood more naturally through algorithms than they are through symbolic closed-form expressions. For example, if you try to introduce someone to jackknife, bootstrap, or other resampling methods, you should start by having them implementing them algorithmically rather than giving their asymptotic central limit theorems. Simulations also greatly assist understanding the meaning of the sampling distribution.
Teaching someone about statistics without ever demonstrating sampling procedures is like teaching calculus without ever drawing a graph y = f(x). They will not understand the *meaning* of anything, it’s exactly how you get a bunch of people who can follow a series of arcane rules but cannot think critically as they relate to applications. You can, of course, introduce sampling procedures without programming–in the olden days you might pull a bunch of stuff out of a jar. But while that might be easier, I don’t think it’s any better.
When I was still actively doing lab work on second language acquisition, one of my favorite experimental set-ups was to record EEG at multiple points within a trial: both during the presentation of phrases, and during the behavioral response and feedback phases (our subjects would get feedback about whether they responded according to the rules they were being asked to learn).
Early in the experimental session, there was a large change in signal power over electrodes that probably would have picked up frontal areas, when a person got feedback telling them that their response was wrong. This changed over the course of the session, as they got better at remembering the rules and applying them in real-time.
I suspect that this type of response would also be present when students learning programming language rules get feedback telling them that their script has an error, but I think most of the work that has been done on this has been with behavioral paradigms.
One difference between conversational speech and programming languages is that with speech we are learning to segment a new language (often with new, unfamiliar speech sounds) and also trying to retrieve words from a still-weak memory of the words. But on the plus side, we have some intuitions about how conversations work, and what people typically say for different kinds of scenarios. If you are learning a new programming language, you have more time to understand the program, and you don’t have to segment a speech stream in real time. But maybe it isn’t so obvious to students the conventions that programming language use, until you have experience with some of them.
Better call Sal.
(Yes BB Saul ref – will GPT4 get th ref? We are all unwitting trainers of AI)
“AI & GPT-4 Revolutionize Education With Sal Khan”
https://m.youtube.com/watch?v=CL923loG1G4
I think this analogy to learning a new language is true for introductions to any field. In my intro to econ class, the prof had textbooks called “micro/macroeconomics as a second language”.
Anon:
Agreed. It’s not just statistics. A particular challenge in statistics is that students need to learn two languages: statistics and programming.
Econ is special in its own way in that it has an ideological component that is absent in many other fields. The whole “think like an economist” thing is all about not thinking in other ways. For example, to “think like an economist” and say that “most (if not all!) deaths are to some extent ‘suicides'”, you need to set aside a vast amount of real-world knowledge that tells us that many many deaths could not have been postponed even if more resources had been invested in prolonging life. All fields of science or scholarship involve simplifications of the world, but economics stands out to me in the way it actively defends its simplifications.
A number of comments made seem to deviate from the usual wisdom given when talking about presentations and visual displays: it depends on your audience. So, too, with statistics courses. What is appropriate for an undergrad statistics major (where 30+ credits of coursework will be taken) and what is appropriate for an MBA student (whose sole exposure may be a single course) are not the same thing. I teach almost exclusively working professional graduate students – I’m much more concerned with them understanding what goes into a data analysis and how the results can/should/should not be used than having them struggle with linguistics (coding). For an undergrad statistics major, the priorities will be different – they’d better be. So, coding/programming must be part of the latter, although there is still the pedagogical issue of where in the program it belongs. Most comments seem to suggest it belongs at the very beginning of the major – I’d prefer to start with more applications in the first course and save the programming to the second course. But since I don’t teach in such programs, I’ll only suggest that the appropriate pedagogical approach should carefully consider where the students are coming from – one size does not fit all.
Andrew’s final comment about economics is well put. There is indeed an ideological, and often unstated, component that economists actively defend that is not as present in other subjects. Languages have cultural and sociological components, as well as being means of communication. I object to most of these, particularly if they are hidden from students studying a subject. I’d fault economics – but also finance – as high on the list of offenders. But I also have a hard time reading sociology, philosophy, and history (so many words to say so little) so perhaps those fields are just as guilty.
Dale:
Yes, I’m talking about courses that I teach, or about courses that others will teach to similar audiences.
This reminded me of a talk from an RStudio conference given by Riva Quiroga.
https://www.youtube.com/watch?v=WlSRI22kpdg
Her focus was more narrowly learning R, but I found it insightful. Basically, the idea is that there are elements of successfully learning natural languages that aren’t well represented in courses/textbooks. For example, reveal general rules after a learner knows how to apply in a more narrow context; the reverse is more familiar in math/stats books. A summary:
* Real things for day/page one.
* Build complexity as a spiral.
* Reveal rules after you know how to use them
* Take into account who your learners are.
What is “Active Statistics: Stories, Games, Problems, and Hands-on Demonstrations for Applied Regression and Causal Inference”? A book? A course? An article? A state of mind? A cult? A teaching methodology? A book-to-be? A polemic? Inquiring minds would like to know!
Vladimir:
It’s the book that Aki and I are finishing and should be available in a few months. I’m really excited about it! It’s a companion to Regression and Other Stories.