Talk:Opinion polling for the 2014 New Zealand general election

Graph for Preferred Prime Minister
For the current term, would someone be keen/able to create a trending graph of the preferred Prime Minister to see how Key/Shearer/Norman etc. are trending over the multiple polls between 2011/14? Also, what application is used for the drawing of the graph? --131.203.252.214 (talk) 23:44, 3 October 2012 (UTC) (David F, Taupo NZ)

The numbers differ so widely I'm not convinced that a graph could be made that showed anything. NZH has numbers considerably higher than the other polls. We use R for the other graphs, but changing the code for those graphs to do the prefered PM would be a big job. Ridcully Jack (talk) 06:10, 4 October 2012 (UTC)

We did it for the 2008 election, but not for the 2011. The general impression I have of the poll is that it doesn't show all that much... but it can be done if there's a clamour for it.. (and enough data to warrent it!) --129.132.221.183 (talk) 07:50, 4 October 2012 (UTC)

Conservative Party column in polling table
I think we should also have a column for the Conservative Party in the table, which got more votes than 4 parties represented in Parliament. It seems likely that they'll appear in more opinion polls - and it's easier to remove a column later if the party doesn't show than to add it in when there are several polls to look back to. Ridcully Jack (talk) 08:15, 3 January 2012 (UTC)
 * I was waiting for the first post-election polls to come out to assess the situation, but I do agree that we should add a Conservative column to the end, being the largest party not to gain seats (like NZ First in the last election) Lcmortensen (mailbox) 00:31, 4 January 2012 (UTC)
 * I also agree it should be in the table, but not in the main graph (unless its popularity grows).- gadfium 03:05, 4 January 2012 (UTC)
 * We'll see how it looks with the graph once there's some data; the minor parties graph is so crowded, but will be less so if NZ First joins National, Labour and Green in the main graph. Ridcully Jack (talk) 06:51, 4 January 2012 (UTC)
 * NZ First should certainly be in the main graph, since they got over 5% in the election.- gadfium 07:43, 4 January 2012 (UTC)

"seven seat majority"
How does the government have a seven seat majority? Their majority would be based on how far past 61 seats they are surely? — Preceding unsigned comment added by 121.72.236.153 (talk) 20:01, 2 March 2012 (UTC)
 * There seems to be two different meanings of "majority". In Fifth National Government of New Zealand the majority is given as 3, ie how many seats they have past the minimum number needed to govern, 61. In New Zealand general election, 2011, at the bottom of the lead section, the majority is given as 7, ie Govt and allies have 64 seats which is 7 more than the combined opposition parties. I'm not sure which is the correct use, but we should be standardising on one or the other.- gadfium 21:52, 2 March 2012 (UTC)
 * The article on majority suggests it's the difference in seats between the government and the opposition (i.e. the difference between 64 and 57, which is 7). What makes it extra confusing is if the government had 61 seats and the opposition had 60 - would that be a zero-seat majority (61 seats won, subtract 61 needed, equals 0) or a one seat majority (61 seats in government, subtract 60 in opposition, equals 1)? Lcmortensen (mailbox) 22:51, 2 March 2012 (UTC)

R graphs
Does someone think we can get the opinion polling R graphs going? I've modified the code from the 2011 election opinion polling to produce a major party and a minor party graph per 2011, but when I run it, I get "null device" after "dev.off" for some reason.

This is the code as I have it:

rm(list=ls)

major.parties <- TRUE if(major.parties) { selected.parties <- c("Green","Labour","National", "NZ First")  #use precise names from Table headers ylims <- c(0,65)  #Vertical range output.fname <- "NZ_opinion_polls_2012-14 -parties.png" } else { #Small parties - please use "Maori" for the Maori party selected.parties <- c("ACT","Mana","Maori","United Future")  #use precise names from Table headers ylims <- c(0,6)  #Vertical range output.fname <- "NZ opinion polls 2012-14 -smallparties.png"
 * 1) Parameters
 * 1) Parameters

}


 * 1) Shouldn't need to edit anything below here
 * 1) Shouldn't need to edit anything below here

selected.parties <- gsub(" ","_",selected.parties) #Handle the space in some names
 * 1) Misc preparation

html <- readLines(url("http://en.wikipedia.org/wiki/Opinion_polling_for_the_next_New_Zealand_general_election",encoding="UTF-8")) closeAllConnections
 * 1) Load the complete HTML file into memory

tbl.no <- 2 tbl <- html[(grep("","",hdrs)[-c(1:2)] party.names <- gsub(" ","_",party.names) #Replace space with a _ party.names <- gsub("M.{1}ori","Maori",party.names) #Apologies, but the hard "a" is too hard to handle otherwise party.cols  <- gsub("^.*bgcolor=\"(.*?)\".*$","\\1",hdrs)[-c(1:2)] names(party.cols) <- party.names
 * 1) Extract table headers

tbl.rows <- tbl.rows[sapply(tbl.rows,function(x) length(grep("1]
 * 1) Extract data rows

survey.dat <- lapply(tbl.rows,function(x) { #Start by only considering where we have tags  td.tags <- x[grep("<td",x)]  #Polling data appears in columns 3-11  dat     <- td.tags[3:12]  #Now strip the data and covert to numeric format  dat     <- gsub(" | ","",dat)  dat     <- gsub("%","",dat)  dat     <- gsub("-","0",dat)  dat     <- gsub("<","",dat)  dat     <- as.numeric(dat)  names(dat) <- party.names  #Getting the date strings is a little harder. Start by tidying up the dates  date.str <- td.tags[2]                        #Dates are in the second column  date.str <- gsub("<sup.* ","",date.str)   #Throw out anything between superscript tags, as its an reference to the source  date.str <- gsub(" | ","",date.str)  #Throw out any tags  #Get numeric parts of string  digits.str <- gsub("[^0123456789]"," ",date.str)  digits.str <- gsub("^ +","",digits.str)    #Drop leading whitespace  digits     <- strsplit(digits.str," +")1 yrs       <- grep("[0-9]{4}",digits,value=TRUE) days      <- digits[!digits%in%yrs] #Get months month.str <- gsub("[^A-Z,a-z]"," ",date.str) month.str <- gsub("^ +","",month.str)       #Drop leading whitespace mnths    <- strsplit(month.str," +",month.str)1 #Now paste together to make standardised date strings days <- rep(days,length.out=2) mnths <- rep(mnths,length.out=2) yrs <- rep(yrs,length.out=2) dates.std <- paste(days,mnths,yrs) #And finally the survey time survey.time <- mean(as.POSIXct(strptime(dates.std,format="%d %B %Y"))) #Get the name of the survey company too survey.comp <- td.tags[1] survey.comp <- gsub("","-",survey.comp,fixed=TRUE) survey.comp <- gsub("(?U)<.*>","",survey.comp,perl=TRUE)
 * 1) Now extract the data
 * 1)  cat(sprintf("%s\t -> \t %s, %s\n",date.str,dates.std[1],dates.std[2]))

#And now return results return(data.frame(Company=survey.comp,Date=survey.time,date.str,t(dat))) })

surveys <- do.call(rbind,survey.dat)
 * 1) Combine results

selected.parties <- sort(selected.parties) selected.cols <- party.cols[selected.parties] polls  <- surveys[,c("Company","Date",selected.parties)] polls <- subset(polls,!is.na(surveys$Date)) polls <- polls[order(polls$Date),] polls$date.num <- as.double(polls$Date)
 * 1) Restrict plot(manually) to selected parties

ticks <- ISOdate(c(rep(2012,2),rep(2013,2),rep(2014,2),2015),c(rep(c(1,7),3),1),1) xlims <- range(c(ISOdate(2008,11,1),ticks)) png(output.fname,width=778,height=487,pointsize=16) par(mar=c(5,4,1,1)) matplot(polls$date.num,polls[,selected.parties],pch=NA,xlim=xlims,ylab="Party support (%)",   xlab="",col=selected.cols,xaxt="n",ylim=ylims,yaxs="i") abline(h=seq(0,95,by=5),col="lightgrey",lty=3) abline(v=as.double(ticks),col="lightgrey",lty=3) box axis(1,at=as.double(ticks),labels=format(ticks,format="1 %b\n%Y"),cex.axis=0.8) axis(4,at=axTicks(4),labels=rep("",length(axTicks(4))))
 * 1) Setup plot

smoothed <- list predict.x <- seq(min(polls$date.num),max(polls$date.num),length.out=100) for(i in 1:length(selected.parties)) { smoother <- loess(polls[,selected.parties[i]] ~ polls[,"date.num"],span=0.8) smoothedi <- predict(smoother,newdata=predict.x,se=TRUE) polygon(c(predict.x,rev(predict.x)),   c(smoothedi$fit+smoothedi$se.fit*1.96,rev(smoothedi$fit-smoothedi$se.fit*1.96)),    col=rgb(0.5,0.5,0.5,0.5),border=NA) } names(smoothed) <- selected.parties matpoints(polls$date.num,polls[,selected.parties],pch=20,col=selected.cols) for(i in 1:length(selected.parties)) { lines(predict.x,smoothedi$fit,col=selected.cols[i],lwd=2) }
 * 1) Now calculate the loess smoothers and add the confidence interval
 * 1) Then add the data points
 * 1) And finally the smoothers themselves

legend("bottom",legend=gsub("_"," ",selected.parties),col=selected.cols,pch=20,bg="white",lwd=2,horiz=TRUE,inset=-0.225,xpd=NA) for(i in 1:length(smoothed)) { lbl <- sprintf("%2.0f±%1.0f %%",round(rev(smoothedi$fit)[1],0),round(1.96*rev(smoothedi$se.fit)[1],0)) text(rev(polls$date.num)[1],rev(smoothedi$fit)[1],labels=lbl,pos=4,col=selected.cols[i]) } dev.off
 * 1) Add best estimates

cat("Complete.\n")

Lcmortensen (mailbox) 03:43, 30 March 2012 (UTC)


 * Yep, would be good to have a graph. Coding is not my forte though. -- Alan Liefting (talk - contribs) 06:39, 24 August 2012 (UTC)


 * I have tried and failed to get the R code to work; I've asked a graduate student in the local Statistics department to take a look at the R code when she has spare time. Otherwise we might need Trevva to take a look at the code. I think it might be that the new table of data is somehow different to the 2011 article's table(?). Ridcully Jack (talk) 02:13, 27 August 2012 (UTC)


 * Trevva has not edited in a while. I will send an email. -- Alan Liefting (talk - contribs) 05:25, 27 August 2012 (UTC)

Hi everyone. Apologies for not paying attention to the page - and thanks to Alan for giving me a nudge(I don't mind at all). I have updated the script and added the graphs to the page. Note that I have used a different algorithm (a "GAM") this time around to produce the smoothers - the "smoothness" is set automatically, so hopefully this should get around the questions we had last time about smoothness. At the moment, the time series is not long enough and there is too much noise to see much of a trend - thats why we're getting lots of straight lines. At some point, the curves will start to take more shape. I'll keep an key on it over the next year or so to make sure it behaves itself. I was also uncertain about which parties to include in the minorparties graph - and where NZ First should lie. Let me know your thoughts and I can make the changes accordingly. There is also a copy of the new script in the description of the majorparties graph on wikicommons. --Trevva (talk) 20:48, 27 August 2012 (UTC)


 * Thanks for that. I am happy with how the current split is between the two graphs. -- Alan Liefting (talk - contribs) 21:04, 27 August 2012 (UTC)


 * Looks great. NZ First should probably stay in the first graph, unless we see numbers drop lower. Several months of polling always under 5% might mean a case could be made for moving them to the small parties graph; but the cut-off for inclusion might be 4% soon? Ridcully Jack (talk) 00:38, 28 August 2012 (UTC)

Significant political events
I think we should add the Labour / Greens announcement on their proposal to reform the electricity market to the table; it seems to be a significant event.  Schwede 66  21:49, 26 May 2013 (UTC)
 * Ok, I've looked a bit harder and it's there already (18 April).  Schwede 66  00:10, 30 May 2013 (UTC)

Should the main graph include Government vs Opposition totals?
Would it be an improvement for the first graphical summary to include lines for the Government parties and Opposition parties? The actual composition of parties in each government is liable to change, but we include these columns in the tables and they do indicate something about the likelihood of who would form the next government if an election was held in that period. It would also make the main graph more exciting, as these two lines would be fairly frequently crossing.- gadfium 03:56, 18 October 2013 (UTC)
 * Great idea!  Schwede 66  08:23, 18 October 2013 (UTC)

I don't think this is a good idea. By adding together all of the current government parties as one line and everyone other parliamentary party as the other, it presuupposes that the next government will be either the current parties or all the others. There are other possible coalitions that could arise. In particular, NZ First could help either National or Labour form a government. With a bit more of a swing to Labour, it might even be possible for Labour/Mana/NZFirst to form a coalition without the Greens at all. Graphing just two possible coalition governments oversimplies a complex situation. Ridcully Jack (talk) 06:08, 19 October 2013 (UTC)

Herald on Sunday/Key Research
I don'y think we should have this data in our table (and graphs).

http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=11172690

It's incomplete, and as it stands the table entry has NZ First at 1% when the article has no mention of their poll result other than lumping them in with "the smaller parties, none of whom break 1 per cent." So there's only solid data in the article on 3 of the 9 parties we typically include data for. Ridcully Jack (talk) 08:05, 15 December 2013 (UTC)
 * It certainly isn't complete enough to add to the graphs. Are the detailed figures published anywhere. I don't see them at http://www.keyresearch.co.nz/services/polls/, but perhaps they will be published there after a few days. If we can't get the detailed figures, I agree this can be removed from the table, but let's wait a little while.- gadfium 19:58, 15 December 2013 (UTC)

I've removed the Key Research poll from the graph. The sample size is tiny (500), the details of the other parties still aren't up in their web site and the results are completely different from any of the reputable polling companies. (Danyl Mclauchlan) — Preceding unsigned comment added by 130.195.249.97 (talk) 20:04, 19 December 2013 (UTC)


 * That's fine, I think we waited long enough.- gadfium 23:04, 19 December 2013 (UTC)
 * Good call, team.  Schwede 66  00:14, 20 December 2013 (UTC)

Criteria for a new column
What are the criteria we would judge making it worth adding a new column to the table (and line to the graph)? We have removed a column added for ALCP in the past (2011 election??) because it only very infrequently shows up in the polls. We might see at least two new parties begin to show (Civilian Party and Internet Party). I think we should to see a new party (or existing party) listed in polls five or so times before we include them in the table. (This would also be the beginnings of enough data to include them in the minor party graph). Ridcully Jack (talk) 00:45, 18 January 2014 (UTC)
 * I would add the criterion that a new party must be listed by at least two different polling companies. Lcmortensen (mailbox) 21:28, 3 February 2014 (UTC)
 * I note that in the below discussion about the Internet Party, the "5 polls" rule is mentioned far more confidently than seems warranted just by someone suggesting "five or so" here with one other person commenting... Has this rule been discussed in the past, enough to be considered a general rule?
 * Also, other criteria are mentioned below: polling above 0.83% (ie 1/120) in a poll and being a registered political party. I don't really disagree with any of these four rules (though the 0.83% one would have United Future removed - perhaps this page should have its own version of the "coat-tailing" exception?). But I definitely think it's a good idea to have a standard set of rules established by consensus and permanently appearing on the talk page so all can access it and add to the discussion.
 * What do other people think? 103.224.129.1 (talk) 20:04, 17 May 2014 (UTC)

Rename page
With the date of the election being announced I think this article should be renamed "Opinion polling for the New Zealand general election, 2014". However I don't know the best way of doing this. --Korakys (talk) 21:10, 23 March 2014 (UTC)
 * Good suggestion. Done.  Schwede 66  10:21, 24 March 2014 (UTC)

New Column for Internet Party
With the Internet Party registering in both the 3 News and Roy Morgan Polls I'd like to put in a request for a column to be added for this party.

Cheers,

Danyl — Preceding unsigned comment added by 130.195.249.107 (talk) 19:34, 30 March 2014 (UTC)


 * Generally we need a party to poll over 0.83% (i.e. $1/120$) and appear in five polls before we consider adding them. Lcmortensen (mailbox) 00:29, 31 March 2014 (UTC)


 * They've polled 1.5% in the latest Roy Morgan pol: http://roymorgan.com/findings/5576-roy-morgan-new-zealand-voting-intention-may-7-2014-201405070619 103.224.129.36 (talk) 21:17, 9 May 2014 (UTC)


 * So only 2 more polls to go ... NealeFamily (talk) 21:48, 9 May 2014 (UTC)
 * Nope. They've now appeared in 5 Roy Morgan polls, and at least one each of the Herald, Fairfax and 3 News polls (for references just follow the links for the last polls listed on this page). 103.224.129.33 (talk) 22:10, 14 May 2014 (UTC)


 * I would also wait until they are a registered political party – no point adding them if they can't contest the party vote (which you need to be registered to do). They applied for registration on 16 April 2014, but the process does take 6 to 8 weeks.Lcmortensen (mailbox) 02:35, 10 May 2014 (UTC)
 * They're now registered. http://tvnz.co.nz/politics-news/internet-party-formally-registered-ahead-election-5971220 103.224.129.33 (talk) 22:10, 14 May 2014 (UTC)


 * So what colour should their column be? A different shade of purple to United Future? Or should UF be changed to their secondary pale green colour? (that might be more distinct from the Greens than two shades of purple are from each other). Or should IP be an entirely new colour? Maori and Mana aren't represented by their main branding colours currently, because in both cases those main colours are red and black, and those colours are taken by Labour and NZ First already. 103.224.129.1 (talk) 19:49, 17 May 2014 (UTC)


 * The colouring is automatic, based on what is set in Template:[partyname]/meta/color (e.g. Template:Internet Party (New Zealand)/meta/color). Lcmortensen (mailbox) 01:51, 18 May 2014 (UTC)


 * Now I guess we'll need to merge the Mana and Internet columns in some way, and the graphs, for the "Internet Mana" party, once it's registered etc, and gets itself a template colour, possibly from the new logo they'll have to submit to the Electoral Commission. This might need some input from someone who knows how the R code works for the graphs, so the columns don't break the graph generation. Ridcully Jack (talk) 03:42, 27 May 2014 (UTC)
 * Will we apply the same rules - ie it has to show in 5 polls, etc? Or will we count the existing Mana and Internet poll showings as precedent enough? It's probably fair to wait until they're registered again - though that could be a month or so. 103.224.129.1 (talk) 09:43, 28 May 2014 (UTC)
 * Counting the constituent party polls will be precedent enough, and both constituent parties are registered so they can still contend the election on their own if the deal falls through. We'll just have to wait and see what the polling companies do (do they combine the two parties or leave them separate) before we add another column. She's also getting pretty crowded (I'm viewing at 1366 × 768), so we may have to move the Govt vs Opposition to a separate table. Lcmortensen (mailbox) 21:18, 28 May 2014 (UTC)
 * Whoever has kindly added the latest poll ( http://www.nzherald.co.nz/nz/news/article.cfm?c_id=1&objectid=11275259 ), the way they have assigned total Internet Mana support to the Internet Party is not ideal. In fact, "Internet Mana got 1.4 - the combined total of 0.5% for Mana, the 0.2% for Internet Party and the 0.7% who said Internet Mana." 103.224.129.1 (talk) 23:08, 16 June 2014 (UTC)

update
http://www.roymorgan.com/findings/5549-new-zealand-voting-intention-april-17-2014-201404170455 — Preceding unsigned comment added by 131.203.85.100 (talk) 06:07, 23 April 2014 (UTC)

Make the date column narrower?
There's talk below about the main graph becoming pretty crowded - especially if a new column is added for Internet Mana. Perhaps an alternative solution could be to make the date column slightly narrower? It doesn't seem to need the amount of room it has currently. 103.224.129.1 (talk) 23:12, 16 June 2014 (UTC)

Sample size and number undecided
The table's getting a little bit crowded horizontally, but do people think there might be room for these two columns? Pitakakariki (talk) 02:58, 29 June 2014 (UTC)


 * Sample size is always roughly similar for each poll isn't it? But I definitely agree that decided/undecided is worth including, especially bearing this analysis in mind: http://www.thepoliticalscientist.org/the-real-story-in-the-fairfax-polls/. In order to make room, how about the above suggestion of shrinking the date column? 118.92.242.243 (talk) 09:08, 21 July 2014 (UTC)

Election day line
For 2011, once the election was relatively close (and it's date was known), I was adding a vertical line to the poll graphs I generated which showed the election day. But I was doing this manually, editing the .png file to draw a black line in the right place. I wonder if anyone with knowledge of R could edit the code to add in the vertical line for Sep 20? Ridcully Jack (talk) 21:36, 13 August 2014 (UTC)

Fairfax Media Ipsos
I've cast my eye over the Fairfax Media Ipsos polls because I had the impression that they tell a different story from the other polls. I reckon it would be worthwhile for somebody with the skills to run the software to analyse them separately.

Since the last election, there have been 13 Fairfax Media Ipsos polls. The first three polls (until February 2013) all appear to give similar results for National as the other polls. From then on, their results are either at the upper end of polls undertaken at a similar time, or are higher than other polls. For Labour, the reverse effect appears to be less pronounced.

Would it be possible to produce the poll graph without the Fairfax Media Ipsos data, maybe just for National and Labour, and then plot the Fairfax Media Ipsos results as single events in a different colour? I'd be happy to do the underlying spreadsheet work, i.e. pulling out the 13 Fairfax Media Ipsos data lines if that would help.

There is of course quite a bit of scientific evidence out there that opinion polls do influence voters, but I’m not saying that this is what is going on here. But looking over the results without having graphed them, this does look odd. Why would one company be a strong outlier, if indeed that is what the results show when it's been graphed?  Schwede 66  00:07, 5 September 2014 (UTC)


 * Sampling can give these types of variances, especially when you consider the polls have +- 3% or thereabouts margin of error. Even on the basis of this poll, National may only have 48% support in reality. The variance can be explained within that context.


 * The real test will be on election day, but even then it will depend on who comes out to vote, the weather, and whether or not the All Blacks won a test match, etc ... NealeFamily (talk) 01:29, 5 September 2014 (UTC)


 * I'm fully aware of the margin of error concept, but the error would obviously distribute itself randomly. What we are looking at here doesn't look very randomly distributed, though.  Schwede 66  01:57, 5 September 2014 (UTC)


 * Slightly different polling approaches give slight variations. You'll notice TV3 (and sometimes Roy Morgan) are skewed a bit the other way (low for National, high for Labour and/or Greens), when compared to nearby polls. Maybe something in the way they ask their questions makes a few more people think "Change the government", while something in the way Fairfax ask their questions makes a few more people think "Keep the government". It all balances out, and there's no way to say which one is the most accurate reflection of political leaning at any given time. I think we just have to take all the large credible polls, and accept that some variation will occur, both with and between polling companies. Ridcully Jack (talk) 03:07, 5 September 2014 (UTC)


 * Hi Schwede - what I was thinking of was a book on the subject I read recently that cited examples where, despite using appropriate sampling techniques, they got a run of results sitting at the outlier rather than more evenly distributed result you would expect. Also, I accept both your and Ridcully Jack's points that there is always likely to be an element of biais in the surveys. NealeFamily (talk) 03:31, 5 September 2014 (UTC)


 * The R graph-drawer code takes into account the polling company as a variable when drawing the trendline. To double check, I ran the R code both with and without the Fairfax polls (I had to delete the results from the article temporarily to draw the latter graph). When the Fairfax results were removed, National went down 1% (to 49%) and Labour went up 1% (to 26%), and some minor parties went up or down 0.1% or 0.2% - not a large material difference. Lcmortensen (mailbox) 09:30, 5 September 2014 (UTC)

Thanks, Lcmortensen, for going to the trouble and running this through the code.  Schwede 66  19:11, 5 September 2014 (UTC)

NZ Herald 19/9 poll - early
An IP user with perhaps only one edit has updated for tomorrow's NZ Herald poll, but linked to an article without most of these numbers. linked to here It's possible that these numbers are correct, but I plan to delete them (until tomorrow morning) unless it can be properly cited. Ridcully Jack (talk) 06:58, 18 September 2014 (UTC)