I’ve been working more or less full-time on our app for causal mapping, now called simply “Causal Map” for over a year now. You can find out more on causalmap.app. Mostly that work is just writing computer code, though I’ve also done plenty of “text coding”, i.e. actually using the app to do research for clients, as well as working with Fiona and James on the business plan, interacting on Upwork.com with people who are helping with the code, and so on.
Anyway, writing code can be a pretty lonely process so I thought I’d start to keep an occasional diary of what I’ve been up to. In theory, there is a record of my progress at the corresponding github repository, but this is private at the moment.
So here’s a snapshot of what I did in the last 2-3 days so I don’t feel so lonely!
The most important change is a different layout algorithm. Before, all the factors were laid out in one big diagram, and when you were viewing some subset of it, e.g. because you had applied some filters, you’d still see the factors in the same relative positions. I had thought this was a good idea, and it is great for small networks because you get a feel for where everything is even though you can’t see it all. But for larger networks it is nonsense because “everything” is an enormous hairball.
So now, by default, each subset of the network is laid out afresh, like this (viewing just the causal network around “patronage”, in the middle). It means you have to do a lot less moving around to see what is going on. It is the basic Sugiyama layout with a bit of tweaking. Not perfect but much better. I also added two buttons to increase/decrease font size.
There is a button to get the old one-layout-to-rule-them-all behaviour if you want it. Here is what looks like if you ask for this, and what it would have looked like until yesterday.
845a65bd7674d8d45ad7eb632391941d.png
I most of yesterday tidying and refactoring the code. This led to me fixing a bug in the “conceptual zoom” functionality which had been bugging me for months.
90d01ee1efcb2ee231262f17f20c9ac2.png
The interface allows the user to change, if required, the default strength and “actualisation level” of each causal claim. (I’ve been updating the explanation of what this means in the doc “Coding styles in the app”). As there are only five possibilities for each (High, Low, Zero, -Low and -High) I felt it would be easier to have sets of buttons rather than the existing slider. I spent some of Saturday making button bars for this purpose, only to abandon them again in favour of simplified sliders on which you can just click in the appropriate place. I’ve also added the option “missing” or “unspecified” for each of these, subtly different from zero, which was a bit of a faff. The slider still shows numbers rather than “High” etc, that is the next step.
d4a75f3e404903ae905ee0a185e5a312.png
I did a little bit of work on styling to make the app start to follow the colours in our branding, and added a logo.
I spent a lot of Saturday going back-and-forth with Novica about the task to enable background save to the database. This is by far the biggest thing holding us back from being able to work conveniently online.
Usually I code all the statements one by one. But sometimes you have to jump ahead, e.g. to switch to a different kind of respondent. But then you can get lost as to what you have coded and what you haven’t. There is a button to jump to the furthest statement ever coded, but that won’t help you if you have left gaps in between. So I added two things:
f0c2e9629b23467a64e9dfa88288d453.png
I’m continuing to add explanatory texts for all of these buttons and widgets which are revealed when you mouse over them or when you press the “Guide me” button.
And I keep adding to the “Coding styles” doc.
At the moment I am spending a lot of time thinking about three problems.
This is a big one. At the moment we can do Conceptual Zoom which means removing granularity. So Big theme>Subtheme
and Big theme>Subtheme2
and Big theme
all get sucked up into Big theme
, and their links are transferred too. It works fine.
And, you can remove less frequently mentioned factors with a slider. But what if you have factors B, C and C which all transmit an influence from factor A to factor E: if B, C and D are not mentioned frequently, then they will disappear when you move the slider.
graph LR
A --> B
A --> C
A --> D
B --> E
C --> E
D --> E
Causal Zoom will be a feature which, when you move the slider, combines and relocates the edges in this kind of case, making the most conservative assumptions about the strength, etc of the resulting links. So for example if either of A → B or B → C have strength=0, so does the link which results from combining them.
graph LR
A --> E
A --> E
A --> E
Causal Zoom will enable the user to ask questions like “Show me the aggregated paths from Intervention J to Outcome P”, and get an answer showing say 3-4 “green” paths where all the connections are normal, this-causes-this links, and maybe one or two grey, zero-strength links and one or two weak ones, one or two negative ones, etc.
I am pretty clear on how to do this, I just need to get round to it.
At the moment, you view the statements (and the corresponding network) either one-by-one or all at once. You can only code in the one-by-one view.
So I think the solution is not to make this all-or nothing distinction. Instead, the statement panel will always show something depending on a metadata filter which you set. So it can show text statement-by-statement or respondent-by-respondent, or village-by-village, or question-by-question, optionally filtered by any other filters, and you can keep coding, and you can see the corresponding section of the network. Then you can click to get to the next statement/respondent or whatever.
I think this is do-able and is deliciously general, but would need a lot of rewriting.
At the moment the functionality to search / replace / reorganise factors is great. But not links. We need to be able to do things like “Show me all the links with the hashtag #xx and also with strength=High, and recode them as … “. The only way to systematically search and replace stuff inside links is with the clunky filter table at the top of the UI. I have tried about 10 different ways to do this using different kinds of tables etc but nothing satisfies. Instead, I want to be able to search and replace using the existing panel for coding new links. This would be more intuitive and easier to get at.
It is do-able.
I learned how to make a single-button toggle using shinyWidgets, like this one, which is toggled on:
I moved all the buttons which are just for local use into a separate toolbar.