Imperative programming

On the importance of imperative programming in psychology

Today, scientific data are usually available in digital form. To evaluate these digital data, they are analyzed with the help of a computer. For this purpose, one writes special computer programs that are tailored precisely to the research question at hand. Such programs are called data analysis scripts.

Computer-assisted data analysis follows a typical structure. First, a digital data set is imported and cleaned in order to correct erroneous or incomplete data and prepare them for analysis. Descriptive statistics are then usually computed and visualized in order to obtain an initial overview of the data. This is often followed by a step of probabilistic modeling and inference, in which models based on probability theory are used to test hypotheses or make predictions. Finally, the results are documented and presented clearly, again with the help of the computer.

The central element of computer-assisted data analysis is the data analysis script, a text file that documents all steps from the raw data to the final data visualization and thus makes data analysis processes transparent and reproducible. A data analysis script enables third parties to reproduce scientific results, which is a cornerstone of good scientific practice. Data analysis scripts are therefore indispensable tools of everyday scientific work and essential components of scientific publications. In the following sections, starting from a discussion of some basic concepts from computer science and structure-forming elements of imperative programming, we will become familiar with the development of data analysis scripts in the programming environment R.

Various digital tools are used to analyze psychological data. Particularly common are freely available programming languages and platforms such as R, which is widely used in data science, statistics, and psychology, and Python, with its broad range of applications in data science, machine learning, and artificial intelligence. The free programming language Julia, which is in fact optimized for data analysis, still occupies more of a niche and currently has not yet found wide adoption, especially in industrial applications. Free programming languages have the advantage that they are often further developed by a broad community of users and can in this way develop a versatile infrastructure.

In addition, commercial programming environments whose source code cannot be inspected continue to be used in psychology. In neuroimaging and engineering applications, for example, the commercial programming environment MATLAB remains popular even today. Some programs that now seem rather old-fashioned also continue to be used, including SPSS, which was very widespread in the social sciences and psychology around the turn of the millennium, JMP, with areas of application in biology and psychology, and STATA, which was popular in medicine and economics, among other fields.

The popularity of digital tools is subject to constant change. One way to measure the current popularity of different programming languages and environments is to quantify Google searches for programming language tutorials. An overview of current trends is provided by the PYPL Index, which is based on the analysis of such search queries.

In summary, digitalization has a lasting impact on science in particular. Effective research data management poses an acute challenge that researchers must face. Programming is increasingly becoming a central craft of scientific work, and basic knowledge of computer science has become indispensable in the modern working world. This applies not least to psychotherapists, for example in the context of online interventions, digitally supported treatment services, or psychotherapy research.