Posts

Showing posts with the label Programming

Arranging Multiple Plots in R

Image
Arranging several plots in R as part of a grid isn't always straightforward. Imagine you had three plots and wanted one to stretch along the bottom row and place the other two above (i.e. Figure 1). Figure 1: Sketch of intended placement Using grid.arrange , it is possible to plot several outputs, but the function will automatically place them into a default grid structure (Figure 2). grid.arrange(p1, p2, p3, p4, p5, p6, p7, p8, p9) Figure 2: Using grid.arrange This may be perfectly adequate if they are to be of equal size. However, this isn't always ideal. For example, when aligning the plots below, the result becomes cluttered (Figure 3). grid.arrange(p3, p4, p5) Figure 3: Work in progress As per my original sketch, I want the top plot (with no legend) to run along the bottom row and the other two plots to be positioned side by side above. The following example shows how this can be accomplished. First, a new layout is created, here a...

Why are we still paying for statistical software?

' What programme should I use to analyse this data? ' About ten  years ago there was little choice and expensive software would have arrived in a box containing a CD-ROM! I still have SPSS and MATLAB in my applications folder. They don't come on CDs anymore, but from a central university server. Like CDs however, these programmes are on the verge of becoming a redundant medium.  Given the choice of free tools available today, how are commercial alternatives going to survive?  IBM acquired SPSS a few years back  for $1.2 billion, which I am not convinced was a particularly smart move.  Psychologists typically want to test  predictions,  visualise data and produce models. That said, additional functionality can often be required quickly and unexpectedly as a research project or idea develops. An open-source community allows for flexibility that paid alternatives do not offer (yet). The ba...

Kernel Density Plots: Has the histogram had its day?

Image
Simple statistical concepts include the mean, median, standard deviation, and percentiles. These are useful for summarising data. Except these summary statistics are only useful under certain circumstances. When basic assumptions are not met, then any conclusions based on simple summary statistics are likely to be inaccurate. Unable to give a hint as to what is wrong, the numbers can often look perfectly reasonable. Lets consider a sample of 64 reaction time observations (in milliseconds): Mean = 387ms Median = 340ms These look ok, until you view the distribution, which is not unimodal.  Despite being a staple in data visualisation, histograms can often be a poor method for determining the shape of a given distribution because they are strongly affected by the number of bins used. For example, visualising the same data with only four bins can make the same observations appear normally distributed. Similarly, a box-plot can also hide data irregulari...