Press "Enter" to skip to content

Month: December 2015

What programming language should I learn – 2

I recently asked which programming language I should learn next year (i.e., 2016). In this post I will evaluate the alternatives that I have by asking the question in different places around the internet. The post will end with the choice I made and how to install the language

To summarize my earlier post, I mainly use programming for creating Psychology experiments and, thus,  need a powerful language. Furthermore, in Psychological experiments stimuli are typically being presented (e.g., sounds, images, text, or video). Responses need to be collected from the keyboard, mouse and specially built equipment (e.g., via USB; Arduino). For some experiments timing of the presentation and collection of responses might be significant.  The language should, of course, be free, open source, and work on a computer running Windows, Linux, and OS-X. However, mobile platforms such as Smartphones and Tablets might also be interesting in the future. Note that all languages considered are more or less general purpose languages and might, therefore, be attractive to anyone that want to extend their stack and learn a new programming language 2016.

One of the most valuable answers I got was that I should look for a functional language.

TrialHandler – a PsychoPy tutorial

In this tutorial you will get to know how to use the PsychoPy function TrialHandler to create trials and correct responses to your targets in these trials. PsychoPy is an application for creating experiments for Psychology experiments. The application is written in Python, an easy programming language to learn. You can learn more about PsychoPy in my two previous posts (Free and Useful software – PsychoPy and Python apps and libraries…”).

R from Python – an rpy2 tutorial

Rpy2 Tutorial: How to Run R in Python

In this post, we are going to answer the question can you run R in Python? Of course, the answer is yes!; using the Python package rpy2. This package offers a Python interface to R.

In this tutorial, we will learn how to use rpy2 to install r packages, and run r functions to carry out data analysis and data visualization. More specifically, we will learn how to sue the r packages r-packages ‘afex‘ and ‘emmeans‘,  usin Python, and rpy2.  Finally, we will also learn how to display R plots in Jupyter notebooks using rpy2, using two different methods.

Obviously; rpy2 requires that we have both R (version +3.2.x) and Python (versions 2.7 and 3.X) installed. There are pre-compiled binaries available for Linux and Windows (unsupported and unofficial, however).

R books for Psychologists

R is a free and open-source statistical programming environment. Being open-source and free it has a large and helpful online community (for instance, see StackOverflow).  When I went from carrying out analysis in SPSS to do them in R, I searched for good books targeted to Psychologists.   The following 4 R books are useful and good for Psychologists that want to learn R.
The first book, Discovering Statistics Using R, may be a really good start if you are an undergraduate and have no experience of programming or statistics. The next two books are from intermediate to advanced level. The last book is, at the moment,  free and is also a great introduction to statistics.

Papaja – APA manuscripts made easy

Do you also find it time-consuming to make your manuscripts follow American Psychological Associations (APA) guidelines? Have you searched the internet for a good .docx/.doc APA template? After reading this post, you might not have to search any more. Papaja is an r-package that makes your manuscript conform to APA guidelines! In this post I am briefly going to describe the package and what I think of it.

Some good Python Blogs and Resources

In this post you will find some really good Python Blogs and Resources. Most of these really helped me when moving from proprietary software to free and Open Source software (e.g., PsychoPy written in Python).  The links are divided into two categories: general and research. In the ‘general’ category you will find good Python resources that might be more general and introducing. That is, more helpful for general problems and you might want to start here. In the ‘research’ category there are links to good Python resources that are more specific to use in research (e.g., PsychoPy and data analysis). The links in the ‘research’ category mainly contains links to Python blogs.

Python apps and libraries for creating experiments

In this post, I will describe the existing free Python applications and libraries for creating experiments.  So far, I have only used PsychoPy but I plan to test most of them. At least the ones that seem to still be maintained. All applications and libraries are open-source which makes it possible to download the source code and add your own stuff to it.

Reverse Scoring using R Statistical Environment

This post is my first on R and it will describe a method on how to reverse scores using R.

Reverse scoring in R

Many instruments (i.e., questionnaires) contain items are phrased so that a strong agreement indicates something negative (e.g., “When there is music in the room I find it hard to concentrate on reading”). These items need to be reversed so that the data will be correct later for statistical analysis.

For more information on reverse scoring, please see my earlier post: Reverse scoring in Python.  Since I was more  familiar with Python  compared to R, and I had no a clue on how to do this in SPSS, I wrote a Python script. The Python script used a function that used Pandas DataFrame and it reversed the scores nice and quickly.

Questionnaire data to be reversed