Publications by Peter's stats stuff - R
Family violence and economic deprivation in New Zealand
New Zealand’s Family Violence Death Review Committee recently released their Fifth Report Data: January 2009 to December 2015, some grim reading on what it describes rightly as “the devastation of family violence”. I was interested by Figure 3 on page 21, which shows a bar chart of the number of offenders by two-classification ethnicity and...
5734 sym R (5492 sym/4 pcs) 8 img
Improving state-space modelling of the Australian 2007 federal election
After I wrote a couple of weeks back about state-space modelling of the Australian 2007 federal election, I received some very helpful feedback from Bob Carpenter, a Columbia University research scientist and one of the core developers of the Stan probabilistic language. Some of the amendments I made in response to his comments and my evolving t...
12662 sym R (6357 sym/7 pcs) 6 img
Who turned out to vote in the 2014 New Zealand general election? by @ellis2013nz
Motivation This thread on Twitter prompted some questions for me about who actually turns up to vote in New Zealand’s elections. With limited time, I can’t answer many of the important questions raised in that thread and the article it refers to critically. However, I can use the New Zealand Election Study to look into the specific question...
8158 sym R (10608 sym/1 pcs) 14 img
Inter-country inequality and the World Development Indicators by @ellis2013nz
I recently read the high quality book Global Inequality by Branko Milanovic. When reading this sort of thing, I often find I can increase my engagement with a topic by playing around with the data myself. In this day and age, this is much more likely to be possible than a couple of decades back! I remember when I first studied development econ...
9683 sym R (14189 sym/5 pcs) 14 img
Sampling distribution of weighted Gini coefficient by @ellis2013nz
Calculating Gini coefficients Stats NZ release a series of working papers, and a recent one caught my eye because of my interest in inequality statistics (disclaimer – I am working at Stats NZ at the moment, but on completely different things). Working Paper No 17–02 by Vic Duoba and Nairn MacGibbon is on Accurate calculation of a Gini index ...
9408 sym R (5597 sym/6 pcs) 8 img
Estimating Gini coefficient when we only have mean income by decile by @ellis2013nz
Income inequality data Ideally the Gini coefficient to estimate inequality is based on original household survey data with hundreds or thousands of data points. Often this data isn’t available due to access restrictions from privacy or other concerns, and all that is published is some kind of aggregate measure. Some aggregations include the i...
6252 sym R (7882 sym/8 pcs) 12 img
More things with the New Zealand Election Study by @ellis2013nz
A new cross tab tool I recently put up a simple web app, built with R Shiny, to let users explore the relationship between party vote in the 2014 New Zealand general election and a range of demographic and attitudinal questions in the New Zealand Election Study. The image below is a link to the web app: The original motivation was to answer a q...
6228 sym 12 img
The long view on New Zealand political polls by @ellis2013nz
The long view There’s been noise in the public debate on the forthcoming New Zealand election about the value of voting intention polls. There’s often not enough attention to the long view on these things, so here is a graphic of 15 years of polling data: Taken all together, the polls are probably doing better than many people think. There�...
2989 sym R (1291 sym/1 pcs) 2 img
R Markdown for documents with logos, watermarks, and corporate styles by @ellis2013nz
R Markdown in corporate settings I’ve been busy recently writing a paper at work using R Markdown, the wonderful tool provided by the folks at RStudio “to weave together narrative text and code to produce elegantly formatted output”. I don’t use R Markdown for my blog, because I prefer to separate my analytical scripts from the text and ...
10209 sym R (3946 sym/8 pcs) 2 img
Time-varying house effects in New Zealand political polls by @ellis2013nz
House effects in state space models of voting intention “House effects” is the term commonly used in models of voting intention to refer to the different statistical biases of different pollsters. In my Model B state space model of the New Zealand 2017 election, the estimated house effects look like this: What these mean, to pick the larges...
5454 sym R (253 sym/1 pcs) 4 img