Julia instead of NetLogo
Simple agent-based models: NetLogo or Julia
I’m idly thinking of putting on a new computational social science module, which lead me to look at Paul Smaldino’s book, Modeling Social Behavior. This looks like a very accessible text on its title-topic. Smaldino uses NetLogo throughout, however, which I’d prefer not to do. My potential students will have been exposed to Julia, so it would be desirable to continue with that. To get an impression of the pedagogical costs of using a general rather than a domain-specific language, I decided to implement Smaldino’s first example, “particles”, from Chapter 2.
…Advent of Code 2024
Here are my solutions to the 2024 Advent of Code, using Julia.
Day 1
using CSV, DataFrames
df = CSV.read("advent1.csv", DataFrame, header=["L1", "L2"], delim=" ")
println("Day1, Answer 1: ", sum(abs.(sort(df.L1) - sort(df.L2))))
println("Day1, Answer 2: ", sum([i*count(x->(x == i), df.L2) for i in df.L1]))
Day 2
Part 1
Read the data
…No, your variable doesn't need to be normally distributed
“I need to test my variables for normality”
I keep encountering students (mostly with former exposure to business or psych stats) who insist on testing their variables for normality as a sine qua non prior to conducting analysis. While it’s clearly a good idea to have a sense of how your variables are distributed, normality is (a) not a general requirement and (b) rarely the case (if your tests tell you the variable is normal, it’s most likely because your N is too small).
…Taming BrightSpace, for Linux users
Making the LMS work for you, not you for the LMS
BrightSpace is our new Learning Management System here in UL, since last semester. I’m trying to use it as a tool, rather than experience it as a constraint. The first thing I wanted to do was to manage content with as little interaction as possible with the BS user interface. The interface is reasonably well designed, but it depends a lot (like most LMSes) on doing things one at a time, with lots of clicking and opening menus and SAVEs and CONFIRMs.
…Simulating Single Transferable Votes in the UK
FPTP vs STV
The UK uses a first-past-the-post voting system (FPTP) that frequently leads to parties supported by significantly less that 50% of the voters forming majority governments. Many other countries use a variety of methods described as PR, proportional representation, which are intended to bring about electoral outcomes (parties’ share of seats) that are much closer to the parties’ share of support among voters. Ireland and a number of other countries use Single Transferable Voting in multi-seat constituencies, which works well and generally leads to more proportional outcomes. There is talk in the UK of moving to PR, but though it might yield better outcomes, it is unlikely to happen, because the two currently largest parties benefit from FPTP.
…Parameterising TWED
Time Warp Edit Distance (TWED) is a measure for comparing categorical time-series such as life-course sequences, that is designed to recognise similarity that may be displaced in time. It is similar to Optimal Matching distance in implementation, but can be thought of as locally compressing and stretching the time dimension, whereas OM deletes and inserts elements. TWED, OM and a range of other sequence comparison tools are implemented for Stata in my SADI package (see Appendix: code). How does TWED compare with other measures, and how does its parameterisation matter?
…The role of indelcost: OM, LCS and Hamming
How do you parameterise Optimal Matching analysis of lifecourse sequence data? A lot of ink has been spilt on how to build the substitution matrix, defining the differences between the states through which sequences move (the cost of substituting elements), but what about the role of indelcost, the cost of inserting or deleting elements? Here is a quick demonstration (using SADI, in Stata) that shows that below a certain threshold OM becomes LCS, the longest-common-subsequence distance measure, that above another threshold (less well-defined) it reverts to Hamming distance, and that in between there is a minimum meaningful indelcost. Let’s look at how this works (for equal-length sequences, since Hamming requires this; OM and LCS can also applied to sequences of unequal lengths).
…