Category Archives: Uncategorized

Using R-Shiny to Teach Quantitative Research Methods

What and why

Over the past couple of years I have been developing a small suite of R-Shiny tools for teaching quantitative research methods. R-Shiny is an R library for writing interactive web pages with full access to the power of the R statistical programming language. The tools I have written include demonstrations of ideas, self-teaching exercises and assessments.

If you use R already, writing Shiny web pages is a relatively easy extension, though programming an interactive web page has some important differences from conducting a data analysis. R is very general and very powerful, so there are lots of possibilities. This is both a strength and a weakness: generality means that while lots of things are possible, many require extensive programming. Nonetheless, it is relatively quick and easy to create simple and robust tools.

This (relatively long) blog is based on an early draft of a paper summarising some of the main things I have learnt, and showcasing a handful of examples. I’m putting it out partly just to record and display what I’ve done, but also to solicit feedback, particularly about how best to use apps like this to good pedagogical effect.

Continue reading Using R-Shiny to Teach Quantitative Research Methods

Seminar: R-Shiny for teaching

Department of Sociology Seminar

Weds 27 November, 12:00-13:00, F1030 Foundation Building

Using R-Shiny to create interactive apps for quantitative research methods teaching

Brendan Halpin, Dept of Sociology, University of Limerick

R-Shiny, a library for the R statistical programming language, makes it easy to create interactive web-pages which build on the statistical tools which R provides. In this talk I will discuss my experience using R-Shiny to create:

  • interactive demos
  • self-learning apps and
  • automatically graded assessments

for students on quantitative research methods modules

Demos are apps that demonstrate a statistical concept, allowing students to vary parameters and see what changes. Self-learning apps allow students to undertake a task repeatedly (with fresh numbers each time), and receive instant feedback. Assessments give students questions with individualised numbers but identical structure, store the answers and automatically mark the submission, with detailed feedback.

R-Shiny offers potential for anyone teaching statistics or quantitative research methods, in any substantive area. The talk will consider pedagogical and programming issues, and summarise the experience using this approach with undergraduate and Masters sociology students over the past few years.

Emacs and org-mode for sending mailshots

I use Emacs for reading and sending email, so I’ve been using emacs-lisp to send mailshots for years (but in a rather clunky way).

The big shortcoming is that it is not hugely convenient getting the data (e.g., student names, email addresses, marks, comments) into emacs-lisp data structures, or conveniently writing the emails.

org-mode makes it all easier.

I present an example here: how to send mails giving feedback on performance in a test.

Continue reading Emacs and org-mode for sending mailshots

Webscraping Wikipedia: update

Sunday’s procrastination showed how to webscrape Wikipedia using Emacs.

I’ll quickly present a tidier version here, with Emacs code that scrapes a single page, outputting for each edit in the history the page topic, the user and the time-stamp. Then I’ll show a little bash script that calls the elisp many times.

Unlike the previous version, it just does one random Wikipedia URL at a time, and outputs topic, user and timestamp, not just topic and time-stamp. It uses much of the same code:
Continue reading Webscraping Wikipedia: update

Webscraping Wikipedia with Emacs

Idle hands

For the want of something better to do (okay, because procrastination), a pass at webscraping Wikipedia. For fun. I’m going to use it’s “Random Page” to sample pages, and then extract the edit history (looking at how often edited, and when). Let’s say we’re interested in getting an idea of the distribution of interest in editing pages.

See update: tidier code.

I’m going to use Emacs lisp for the web scraping.

OK, Wikipedia links to a random page from the Random Page link in the lefthand menu. This is a URL:

https://en.wikipedia.org/wiki/Special:Random

How random is this page? See https://en.wikipedia.org/wiki/Wikipedia:FAQ/Technical#random

Continue reading Webscraping Wikipedia with Emacs

Where did Brexit come from and why is it going nowhere?

That's unpossible
Ralph considers revoking A50
Britain is characterised by both a pragmatic able sensibleness, and inward-looking narcissistic post-imperial nostalgia. The latter finds the EU a symbolic humiliation, the former gets on with engaging with its benefits and influencing its development. However, because of the inward-looking nature of British/English exceptionalism, visibility of the advantages of the EU, and an understanding of it and its operations, are distinctly attenuated. Reap the benefit of the single market, but still think Johnny Foreigner is somehow less than the world-straddling Empire Brit.

This means there has long been a persistent pool of resentment about the EU, and a lack of understanding of its benefits.

Calamity strikes when idiot Cameron attempts to placate the monster with a referendum. Not only does the government get a well-deserved kicking for unrelated reasons, but the Remain camp is utterly unable (unwilling?) to communicate the real and symbolic advantages of the EU.
Continue reading Where did Brexit come from and why is it going nowhere?

Simple parallelism in Stata

Speeding up embarrassingly parallel work in Stata

Stata-MP enables parallel processing, but this really kicks in only in estimation commands that are programmed to exploit it. A lot of the time we may have very simply repetitive tasks for Stata to do, that could be packaged for parallel operation very easily. This sort of work is often called embarrassingly parallel, and isn’t automatically catered for by Stata-MP.

The simplest situation is where the same work needs to be done multiple times, with some different details each time but no dependence whatsoever on the other parts. For instance we may have a loop where the work in the body takes a long time but doesn’t depend on the results of the other runs.

I came across this situation the other day: I have data created by running a simulation with different values of two key parameters, and I wanted to create graphs for each combination of the parameters (PNGs rather than Stata graphs, but that’s just a detail). So I wrote code like the following:
Continue reading Simple parallelism in Stata

Triangular colour schemes for 2DF 3-way variables

In my recent blog on three-way referendums, I found myself wanting to represent how a three-way outcome varied across two dimensions. It was easy enough to represent the prevalence of one of the outcomes versus the rest, on a scale of 0-100%, by sampling the two dimensions at discrete intervals, i.e., calculate the Z variable across an X-Y grid. This yields a one-dimensional heatmap, where colour codes the percentage of the outcome (black at 0% to white at 100%).

stv.png

Continue reading Triangular colour schemes for 2DF 3-way variables

Doing away with Daylight Saving Time?

Doing away with DST

The European Commission has started making moves to suggest that countries should stop using daylight saving time, and decide on a year-wide timezone. There is a lot of support for this, particularly for a week or so in late October and late March every year.

Yes, the switches are inconvenient, particularly the spring one, where we lose rather than gain an hour’s sleep. But what are the advantages of DST? The gains that persist through the seasons stand out less than the transient annoyance of the switches. The key idea of DST is that in the summer, dawn is so early that we sleep through lots of daylight. Putting the clocks forward in the spring means one hour of this daylight is shifted to the evening. In Ireland this means we’re on GMT (a little ahead of solar time across the whole country, more so in the west) in the winter, and GMT+1 for the summer.

If DST is abolished, we remain on either GMT+0 or GMT+1 for the whole year. I suspect GMT+1 would be favoured, because it keeps us closer to the continent.

The Irish Department of Justice is seeking feedback on the issue until 30 November 2018. Direct feedback form link

Continue reading Doing away with Daylight Saving Time?

Generating transition-based substitution costs: SADI vs SQ

Sequence analysts often use substitution costs based on transition rates. While I believe that using transition rates to define substitution costs is not always a good strategy, it can be useful and is implemented in SADI (via the trans2subs command). It is also available in SQ (via the subs(meanprobdistance) option).

Continue reading Generating transition-based substitution costs: SADI vs SQ