Wordscores/JFreq with Long Manifestos

Today I run into an unexpected error when using Wordscores in R. I used JFreq 0.5.4 to calculate the word frequencies from 35 parties with rather long party manifestos. This resulted in a 3.4M CSV file with 42462 columns. R would throw up an error regarding read.table when I called Austin‘s (0.2) wfm function to import the word frequencies: “Error in read.table(file = file, header = header, sep = sep, quote = quote, : more columns than column names”. Well, the file seems too wide to open.

The solution I found was to use the old JFreq 0.2.5, which produces the output the other way around (rows/columns switched). Even if it is a bit slower than the newer JFreq, having a rather long (as opposed to wide) CSV with the word frequencies does not seem to pose problems.

Moving Averages in R

To the best of my knowledge, R does not have a built-in function to calculate moving averages. Using the filter function, however, we can write a short function for moving averages:

mav <- function(x,n=5){stats::filter(x,rep(1/n,n), sides=2)}

We can then use the function on any data: mav(data), or mav(data,11) if we want to specify a different number of data points than the default 5; plotting works as expected: plot(mav(data)).

In addition to the number of data points over which to average, we can also change the sides argument of the filter functions: sides=2 uses both sides, sides=1 uses past values only.

No Syntax Highlighting for R in Notepad++

Notepad++ is a versatile text editor for Windows. Unfortunately in the current version, some themes do not offer syntax highlighting for R scripts. This can be fixed relatively easily by adding the relevant entry from a theme that does include it. In Windows > Program Files > Notepad++, open the theme that does not work (e.g. vim Dark Blue.xml), and one that does work (e.g. the stylers.model.xml). Simply copy over the relevant bits, and change the colours to match those of your theme.

You might have to start Notepad++ as administrator (right-click on the program entry in the start menu). Let’s hope the next release has this bug fixed…

Individual Representation

My article on individual representation has now been published. In the article I develop a new measure of political representation. It is based on a new conceptualization, complementing existing approaches. The focus is on the individual (in society), and an individual representation score is calculated to express how well the individual is represented by the legislature. These scores involve a double comparison, first with the positions of other individuals in society, and then with the positions of the members of parliament. R-code to calculate these individual representation scores is available from R-Forge.

Representation of Women in National Legislatures

After a considerable time as an on-line paper, my article on the political representation of women in national legislatures finally appeared in print. I use a large cross-national sample of all free and partly-free countries (according to Freedom House). Like some recent contributions, I find that attitudes toward women as political leaders are a powerful predictor for the share of women in the national legislature. This link was already established by Pippa Norris and Ronald Inglehart, amongst others, but in this article I also consider the role of gender quotas. Once controlling for regional or cultural/attitudinal differences, voluntary party quotas and legislative quotas do not appear to be significant. Obviously there are often implementation issues, but we need to think more carefully about the underlying mechanisms: I argue that cultural variables are probably behind both the share of women in legislatures and the (successful) implementation of quotas.

Norris, P., and R. Inglehart. 2001. “Cultural obstacles to equal representation.” Journal of Democracy 12(3): 126–40.