jwhandley / ttwa-detection

1 stars 0 forks source link

Defining the 'X' equation #1

Closed thomashudsonuk closed 11 months ago

thomashudsonuk commented 11 months ago

Hi, I've been following this TTWA repository as I'm in need of reproducing the methodology used for the official TTWAs for a project. You've done some excellent work in this repository, and your code is highly performative thanks to Rust! (a language I have to admit I don't know that well, so this code is a good excuse to better familiarise myself)

I noticed you mentioned that the Newcastle University TTWA methodology hadn't explicitly stated the 'X' equation, which is used to determine if a TTWA is valid or not. Although never explicitly defined, the 'feasible region' in the methodology (Figure 2) can be defined by the following constraints:

  1. y > 2/3
  2. x > 3500
  3. y > m*x + c, where m = (2/3 - 3/4)/(25000 - 3500) and c = 3/4 - m*3500

I've made an interactive version of this feasible region in Desmos.

jwhandley commented 11 months ago

Hi, thanks for this! The tricky bit is going from the indifference curve in Figure 2 to a utility function that we can use to rank the proto-TTWAs. With the help of your Desmos visualisation I think I've been able to reconstruct the implied utility function for the 'X' equation, with the minor exception that the paper is also unclear about how supply-side and demand-side self-containment enter into the equation. Preliminary testing has shown better results than my previous attempts. image

thomashudsonuk commented 11 months ago

Thanks for the reply! I think the methodology could be clearer. My understanding of the process used is that the ${T{ij}}^2$ is an attempt to measure the 'closeness' of two separate areas. Whereas, the 'X' equation can be thought of as the feasible region defined by three inequalities in my original comment. The author's definitions of the ${T{ij}}^2$ and 'X' equation are described in the glossary on page 50 of the methodology.

This would mean the ranking, in step A of the algorithm, would be done on the ${T{ij}}^2$, and the validity check on the TTWAs, in step B1, would be done using the feasible region defined by the 'X' equation_.

(The unfortunate bit about the methodology is that it's not guaranteed to produce contiguous areas, with some post-algorithm process done by hand which won't be easily reproducible.)

jwhandley commented 11 months ago

Looking at the original document, the initial ranking (used for deciding which proto-TTWA to eliminate, not which to assign a node to) is the 'X'-equation:

Step A rank all ‘proto’TTWAs in terms of their size&self-containment* values

  • what is termed the ‘X’equation partially trades-off the size&self-containment values, giving a single index value by which the ‘proto’TTWAs can be ranked

At any rate, tij2 values are only defined for a node, proto-TTWA combination so it is impossible to compute rankings based on tij2 values.

If you just use the supplied curve in Figure 2, you only get a pass/fail ranking of proto-TTWAs which makes the description of the algorithm no longer make sense: there isn't a ranking of proto-TTWAs based on size and self containment, there are only proto-TTWAs that meet the requirements and don't meet the requirements. It is possible to implement the algorithm with just this pass/fail but it becomes much slower. This is why it was necessary to convert the indifference curve shown in figure 2 into a utility function, visualized as a contour plot and a 3d plot in the attached figures.

image image

thomashudsonuk commented 11 months ago

Apologies, I think the poor definition of the 'X' equation and the fact that Figure 2 from the original methodology implies a pass/ fail criteria confused me and caused me to have some 'tunnel vision'. Especially with the official ONS methodology guidance, when compared to the Newcastle University 2007 review paper, not helping to clarify this for me.

I think your current representation of the 'X' equation is the best version without having the full definition used to create the official TTWAs (although the 'official' version still might not be as good as yours!). I'm soon to be fully onboarded in a new team in the Department for Science, Innovation, and Technology and might send you an email about this for reasons related to work if that's okay?

jwhandley commented 11 months ago

Sure, feel free to send an email any time!