Peter's stats stuff

Applying statistics and data science 'in the wild'

I write about applications of data and analytical techniques like statistical modelling and simulation to real-world situations. I show how to access and use data, and provide examples of analytical products and the code that produced them.

Latest post »

Recent posts

House effects in New Zealand voting intention polls

21 March 2017

I use generalized additive models to explore "house effects" (ie statistical bias) in polling firms' estimates of vote in previous New Zealand elections.

Simulations to explore excessive lagged X variables in time series modelling

12 March 2017

Adding lots of lagged explanatory variables to a time series model without enough data points is a trap, and stepwise-selection doesn't help. The lasso or other regularization might be a promising alternative.

New data and functions in nzelect 0.3.0 R package

11 March 2017

Version 0.3.0 of the nzelect R package now on CRAN includes historical polling data and a few convenience functions

Visualising relationships between children's books

04 March 2017

Statistical methods like hierarchical clustering and principal components analysis can help understand and visualise literary concepts but don't replace reading the books and engaging with them in traditional critical ways!

Success rates of appeals to the Supreme Court by Circuit

26 February 2017

It's important to use the correct denominator when considering performance. While a high percentage (more than 50%) of decisions from the US appeal circuit courts that get all the way to the Supreme Court are overturned, this is only a tiny proportion of total appeals decided by the lower courts.

Moving largish data from R to H2O - spam detection with Enron emails

18 February 2017

I finally solve my problem of writing large sparse matrices from R into SVMLight format for importing to H2O; and demonstrate application with spam detection trained on the Enron email data comparing a generalized linear model, random forest, gradient boosting machine, and deep neural network.

US Presidential inauguration speeches

23 January 2017

I do some basic textual analysis and visualization with US Presidential inauguration speeches.

Does seasonally adjusting first help forecasting?

22 January 2017

I test some forecasting models on nearly 3,000 seasonal timeseries to see if it's better to seasonally adjust first or to incorporate the seasonality into the model used for forecasting. Turns out it is marginally better to seasonally adjust beforehand when using an ARIMA model and it doesn't matter with exponential smoothing state space models. Automated use of Box-Cox transformations also makes forecasts with these test series slightly worse. The average effects were very small, and dwarfed by different performance on different domains and frequency of data.

Books I like

14 January 2017

My ten recommended books for applied statistics and data science. Then 13 more!

Cross-validation of topic modelling

05 January 2017

Cross-validation of the "perplexity" from a topic model, to help determine a good number of topics.