An election is coming up in Victoria on 28 November. If you’ve been following politics and polling, you’ll know it’s going to be a doozy. Since the 2025 Federal Election, where Labor won by a landslide, One Nation - a far-right party - has been bounding up the polls to have a first preference share competitive with both the major parties of Labor and the Liberal/National Coalition (L/NP). One Nation have also had some electoral success, winning their first federal lower house seat in Farrer (NSW) and four lower house and three upper house seats in the South Australian state election.

I’ve been reading some polls and have found that they report only state-wide first preferences with some demographic breakdowns. These are interesting, but do not tell me how the first preferences will be distributed spatially across electorates. Consequently, I thought it would be interesting to take some of the state-wide polls and apply the Iterative Proportional Fitting (IPF) algorithm to understand the spatial distribution of One Nation voters.

The IPF algorithm uses aggregate information to calculate estimates at a lower level of aggregation. So using this algorithm, I can combine the demographic data from the 2021 Census and the statewide demographic results from the polls to get an electorate level estimate of first preference votes.

Note, I’m not intending this to be an accurate or reliable prediction of the election outcomes, but rather I just want to get an idea of the spatial pattern of One Nation voters. This pattern can show us the implications of the statewide polls and which parties are competing for the same territory. It’s also interesting as a way to get a granular estimate of a parameter from constrained data.

In the following, I’ll start by describing how the IPF algorithm works, then I’ll describe some of the practical steps needed to prepare the data, lastly, I’ll discuss some of the results and reflect on lessons learnt. The code can be found here.

Iterative Proportional Fitting

IPF is an algorithm which can find a matrix $X$ that best matches some initial matrix $Z$ (a seed matrix), and aggregate row and column totals. Both $X$ and $Z$ must have non-negative values. Essentially, if we take the rows of our matrix to be indexed by $i$ and index the columns $j$, then for row/column totals $u_i$, $v_j$ and $x_{ij} \in X$, $z_{ij} \in Z$, we want to find $\hat{x}_{ij} = a_i b_j z_{ij}$, such that $\sum_j \hat{x}_{ij} = u_i$ and $\sum_i \hat{x}_{ij} = v_j$. Or, put in less mathematical language, we want the row and column sums to match our targets by scaling the seed matrix $Z$ with factors $a$, $b$.

To link this back to our problem, we could view the entries in our seed matrix $z_{ij} \in Z$ as the number of voters by gender in a given electorate that will vote for a given party. To simplify the problem, let’s just consider one electorate, two parties - Labor and L/NP, and one demographic (gender), so we have a simple 2x2 matrix shown below.

  Labor L/NP Total
M 100 100 220
F 100 100 180
Total 190 210 400

In the above, we have total Males, Females, and total Labor, L/NP voters in the row / column totals which we would extract from demographic data and statewide totals (we’re assuming a state of one electorate here remember). These are the $u_i$, $v_j$ we want the cell values to sum to when summed via rows and columns respectively. Note that in the table above, the cell values are italicised and do not sum to the row/column totals. This is because these are the $z_{ij} \in Z$ that we want to weight to find $X$ which will be the finalised cell values. We find these values by the IPF algorithm.

The Procedure

To find $\hat{x}_{ij}$ we iteratively adjust the initial cell values. Each full iteration $n = 1, 2, \dots$ consists of a row update followed by a column update. Before the first iteration, we initialise $\hat{b}^{(0)}_j = 1$. In the row update, we sum the row values (Gender) across the columns (party) to calculate $\hat{a}^{(n)}_i$, as shown in this equation:

\[\hat{a}^{(n)}_i = \frac{u_i}{\sum_j z_{ij}\hat{b}^{(n - 1)}_j}\]

$\hat{a}^{(n)}_i$ is set as the ratio of the total row sum ($u_i$ - or in this case, all Males in the electorate) to the weighted sum of initial cell values (so $100 + 100 = 200$). As we have $\frac{220}{200} = 1.1$ we set $\hat{a}^{(1)}_{\text{M}} = 1.1$. Similarly, we have $\hat{a}^{(1)}_{\text{F}} = \frac{180}{200} = 0.9$. In the column update of the same iteration we turn to the columns, where we take, for each party, the sum across genders to get:

\[\hat{b}^{(n)}_j = \frac{v_j}{\sum_i z_{ij}\hat{a}^{(n)}_i}\]

Note, the column update uses the newly updated $\hat{a}^{(1)}_i$ rather than 1, i.e. the values we calculated above. So we now have $\hat{b}^{(1)}_{\text{labor}} = \frac{190}{1.1 \times 100 + 0.9 \times 100} = 0.95$ and $\hat{b}^{(1)}_{\text{l/np}} = \frac{210}{1.1 \times 100 + 0.9 \times 100} = 1.05$.

We then repeat these two updates for $N$ iterations, until we reach some convergence criteria (e.g. successive estimates change by less than some small value $\epsilon \gt 0$). The final estimate is $\hat{x}_{ij} = \hat{a}^{(N)}_i \hat{b}^{(N)}_j z_{ij}$.

For our example, we can then calculate $\hat{x}_{ij}$ for each cell, e.g. for Males voting Labor we have $1.1 \times 0.95 \times 100 = 104.5$. This gives:

  Labor L/NP Total
M 104.5 115.5 220
F 85.5 94.5 180
Total 190 210 400

The cell values now sum to the row and column totals. This simple example converges after a single iteration ($N=1$), with values for $\hat{a}^{(1)}_i$, $\hat{b}^{(1)}_j$ as above. So the number of males voting Labor is given by $\hat{a}^{(1)}_M \times \hat{b}^{(1)}_{\text{labor}} \times z_{M, \text{labor}} = 1.1 \times 0.95 \times 100$. Other values are given similarly.

Further practical considerations

In the example above I use a 2-dimensional matrix, but in my actual problem there are more demographic categories, more parties and 88 lower house seats. IPF can handle these cases by iterating through each of the dimensions as required in a cycle. It is always worth pointing out that the seed matrix $Z$ will impact the final solution. IPF finds the final matrix $X$ that is closest to $Z$ subject to meeting the row / column constraints. I discuss this later as it causes some problems.

Data and input preparation

Gathering data

To apply IPF to our particular problem, we need demographic data and aggregate polling results. For aggregate polling data I used a single Demos poll for September 2026. The Demos polls provide an overall first preference vote for Victoria for:

  • Labor
  • L/NP
  • The Greens
  • One Nation
  • Other

They then further provide this for demographic sub-categories:

  • Gender (Male, Female)
  • Age (18-34, 35-54, 55+)
  • Highest Level of Education (School, TAFE, University)
  • Home Tenure (Own Home Outright, Mortgage Holder, Renter)
  • Income (<$45k, $45-125k, $125k+)
  • Region (Inner Metro, Outer Metro, Regional Vic)
  • Language Spoken at Home (Other Language at Home, English Only)

I found data for most of these variables from the 2021 Census, which provides them for the 2021 Victorian Electorates. The only variable that I was unable to get was the Region, which is apparently based on a custom model prepared by Demos themselves. For this analysis, I just excluded it.

To perform IPF I need a matrix of data which has, for each of the 88 lower house seats in Victoria, the count of all of the variables in persons of the demographic groups in Demos’ poll. This required me to make a few adjustments to the data. I’ll list these briefly below:

  1. Census data is provided in 2021 Victorian electorates. I convert these to 2022 Victorian electorates by proportionally reassigning the demographics of 2021 electorates to 2022 electorates using spatial overlap via the Geopandas library.
  2. Where possible, I use the age breakdown to calculate how many in each demographic category provided by the census are 18+
  3. Where there is no breakdown (Education and Language) I simply rescaled the total numbers to the 18+ numbers (keeping shares the same)
  4. Lastly, I rescaled electorates based on their citizenship rate. This retained the relative proportions within electorates but meant the IPF algorithm would give areas with a greater proportion of citizens more weight.

Overall, these adjustments gave me a rough approximation to the adult citizen population in Victoria. Another adjustment I did not account for was the potential change in population between now and 2021. This could also impact results because the demographic shares may have shifted during this time.

The seed matrix

One final decision that I needed for applying the model is the seed matrix $Z$. As mentioned above, this is not a neutral decision and it will materially affect the final matrix $X$. The IPF algorithm minimises the KL-divergence between $X$ and $Z$, subject to meeting the row / column totals. Essentially, the algorithm is trying to ensure that the final output $X$ is as close as possible to $Z$ within our constraints.

The simplest choice for $Z$ is a matrix of equal values, like in our worked example. This approach is equivalent to assuming that there are no differences in first preferences across different electorates or demographics. This means when I run IPF, the final matrix $X$ will be entirely determined by the distribution of my demographic data. This also aligns with my objective - to understand the spatial distribution of voting patterns based on the aggregate polling data by demographics. As I’ll show, this approach also has significant limitations - not least that it results in a distribution of first preferences that has significantly less variance than observed at prior elections.

Overall Results

Here we discuss the results of applying our IPF model. For reference, I’ve included a plot of the 2022 Victorian election results. As you can see - One Nation was not in the picture at all. The Greens won a handful of inner city seats, while the L/NP was largely consigned to regional areas, with the exception of a small band in the inner east of Melbourne.

2022 results

Uniform Seed Matrix

Overall, setting $Z$ to uniform values appears to result in a highly unrealistic prediction of first preference votes. This is despite the IPF algorithm converging to the overall totals with minimal error.

The plot below shows that the variance of first preferences across electorates is quite narrow compared to the previous Victorian Election in 2022. This suggests that there are more factors than just the demographics that affect first preference votes. Variance comparison

First preferences are solely led by Labor or L/NP with Labor leading in only thirteen districts - mainly in the outer suburbs or right in the city centre. It seems implausible that these two parties would lead first preferences in all seats - the above image shows that in the 2022 election there were outlier districts for the Greens and Others which indicate first preference shares of above 40%. It would be highly likely that they would be the leading party in those districts. The Greens for example often lead and win in Melbourne.

First Preferences

We can try to gain some insight into which seats are non Labor / L/NP contests by looking at the modelled prediction for second highest first preference. Below I plot which seats have either Greens or One Nation in second place. It is notable that no seat has the Greens in second place. This seems patently false as the Greens currently hold three inner city seats in Melbourne, Richmond and Brunswick, and the latest Demos poll shows that there has been a slight swing towards them since the last election. If we look at the plot of first preference variance above, the range of first preferences for the Greens is significantly lower than the previous election. I’m inclined to think this is due to my method rather than due to any genuine change in polling.

One Nation on the other hand has several regional seats, particularly in east Victoria. This seems intuitive based on my understanding that One Nation is relatively more popular with older demographics with less education - which is more prevalent in regional areas. But looking at some of the Demos breakdowns suggests that there are other demographic factors at play. Furthermore, given the counter intuitive results above, perhaps there is more to the story than shown in this plot.

Second Place

In summary, using the demographic totals alone provides us with an incomplete and inaccurate picture of what first preferences may look like at the next election. It seems that there is much more behind voter preferences than just their demographic features. A few additional things worth considering are:

  1. Interactions between demographic variables - young people with high incomes may have different preferences than young people with low incomes etc. I don’t actually consider the interactions between variables but they are likely important and would potentially result in greater variation in preference results.
  2. Locally important issues and preferences - each electorate may be experiencing its own challenges, such as infrastructure projects or social or economic issues. These may result in unique impacts that buck the wider demographic trend.

While 1. could be captured by IPF if I cross-tabulated some of the demographic data, 2. would require a different approach that incorporated local information.

Trying different seed-matrices

A uniform seed matrix is a blunt assumption that assumes demographics are the only thing that matter. But as shown above, this approach leads to first preference estimates with pretty low variance that seem to favour Labor and L/NP heavily.

I try to address this by using the previous election results as a seed matrix - which will incorporate some local preferences. This approach, however, has limitations:

  • Firstly, the local preferences it encodes relate to the last election, which may not be relevant to the upcoming election.
  • Secondly, at the last Victorian election, One Nation only ran candidates in five seats, so first preferences in most districts are 0 - meaning we have no real information about how local voters feel about them.

We can address the first issue by applying the swing observed in the polls to the raw values from last election. For the second issue, we need to avoid inputting 0 values into the IPF algorithm, as cells with 0 values stay 0. We can solve this by adding a small $\epsilon > 0$ to each cell, as well as applying a smoothing term which draws values back towards the polling statewide vote share provided by Demos. The smoothed share is calculated as $\frac{\text{local_share_estimate} + \alpha \times \text{statewide_party_share_estimate}}{N_{\text{local}} + \alpha}$, where $\alpha$ is the strength of this pullback, set to $0.5$, and $N_{\text{local}}$ is the count of votes in that electorate.

I can get even better spatial distribution information by incorporating upper house results as well. In this approach, I can initialise the seed matrix using the upper house shares for lower-house districts which fall within the upper house region. One Nation received votes in all regions here, so the zeros are not a problem and I can capture some local information. Note there are only 8 upper house regions, so this information is not as granular as lower-house electorates.

With an objective of finding a reasonable seed matrix, I tasked Claude with comparing four scenarios:

  1. Uniform (all-ones) seed matrix
  2. lower house (with swing + smoothing)
  3. upper house (with swing + smoothing)
  4. combined (avg) lower and upper house (with swing + smoothing)

It provided me with a nice report you can see here. Looking at the variance, you can see a much more reasonable level of variance for most parties. One Nation is still pretty flat and most parties have significantly less variance than was observed in the previous election, but it’s a significant improvement. Note that while option 2 looks good on variance, it was overly influenced by the five electorates for which One Nation ran candidates at the last election. Scenario 4. gave a more balanced result with greater variance than the Uniform seed-matrix. Variance comparison

Combined seed matrix results

As shown above, the combined seed matrix has a wider, but not perfect variance of first preferences across seats.

The first preference plot now includes some Greens seats in the inner city - which matches the known pattern. Labor seems to have gained a bit of a wider share out West and in the South-east of Melbourne.

First Preferences

When we consider the second place plots, One Nation is more competitive in a wider swathe of regional areas, but still generally sits outside the top two spots around Victoria’s four biggest cities - Melbourne, Geelong, Ballarat and Bendigo. Interestingly there does seem to be a beachside enclave around Brighton in Melbourne, perhaps because these regions are typically more conservative.

Second Place

Overall, I would suspect that this understates how competitive One Nation will be. The estimates of first preference votes by the model are tightly clustered around One Nation’s polling average. Even with my adjustments to the seed matrix, there was limited information to draw on about local preferences for One Nation. Given that the growth in One Nation preference share has been so rapid, it is hard to use IPF as a way to model their first preference share.

Conclusion

In this article I set out to understand what the spatial pattern of One Nation voters was based on some aggregate survey data from Demos. While the IPF algorithm was able to derive the desired estimates, the requirement to choose the seed matrix meant that we always had to implicitly encode assumptions about those estimates in advance. As we saw, this was difficult to do and depending on our choice of seed matrix, we could get very different results. One particularly serious complication was the lack of data on One Nation first preferences. The rapid growth in their (putative) voting bloc is not recorded in past elections, and the IPF algorithm cannot overcome this gap.

But there were still some insights to be drawn. For example, common to both scenarios, it appears One Nation’s voters are based in regional Victoria, away from the four largest cities - Melbourne, Geelong, Ballarat and Bendigo. In these areas they will be competing with the L/NP for seats rather than Labor. But that isn’t to say they won’t impact Labor’s vote as in areas where they are not in the top two, they might accumulate sufficient votes to funnel them to L/NP.

The lack of variance in One Nation’s first preference votes may suggest that there will be several seats that have a larger first preference share than modelled, while others will be lower. Speculatively, if we adjusted the estimates we saw to account for this larger variation, I would think that regional seats would have a much higher first preference share than urban or suburban seats. If One Nation maintained its state-wide surveyed first preference vote, then this could mean One Nation votes may be even higher in regional seats, and lower in suburban seats, making them a greater threat to the L/NP.

The key lesson I take away from this article is that using IPF as a modelling tool requires careful consideration of the subtle assumptions that are made by your seed matrix. The seed-matrix is not merely an initialisation for an optimisation algorithm, but rather an input that restricts your final output. When you lack the information to build a defensible seed matrix it is quite hard to have confidence in your final outputs. If I just wanted to understand the impact of demographics alone on the distribution of One Nation voters, using the uniform seed-matrix is a reasonable way of doing so, because it makes no assumptions about any local effects. But I also saw that this leads to results that look quite incorrect, showing that aggregate demographic data does not fully explain voting behaviour.

One final note - as mentioned at the start, this article is not intended as a prediction of an election outcome. This approach would be pretty poor for that purpose, as, in addition to the reasons above, it only relies on a single survey, which will have its own biases and will be subject to a margin of error.


<
Previous Post
Diffusion Models
>
Blog Archive
Archive of all previous blog posts